Created
January 2, 2017 20:56
-
-
Save csabatini/d58bbb76aafe9e77d2df6330956f0434 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| function add_user_and_key() { | |
| USER=$1 | |
| KEY=$2 | |
| useradd $USER | |
| mkdir -p /home/${USER}/.ssh/ | |
| cp {~/.bashrc,~/.bash_profile} /home/${USER} | |
| sh -c "echo ${KEY} >> /home/${USER}/.ssh/authorized_keys" | |
| chown ${USER}:${USER} -R /home/${USER} | |
| chmod -R 700 /home/${USER} | |
| chmod 640 /home/${USER}/.ssh/authorized_keys | |
| } | |
| add_user_and_key csabatini "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment