Last active
December 12, 2017 06:24
-
-
Save Edison-Hsu/4b0c7e7c515e6ac4fdf67e3031aba06b to your computer and use it in GitHub Desktop.
add_user.sh
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/sh | |
| user=$1 | |
| group=${2:-wheel} # wheel/sudo | |
| if [ -z "$user" ]; then | |
| exit 1 | |
| fi | |
| home=/home/$user | |
| ssh_folder=$home/.ssh | |
| # Use the adduser command to add a new user to your system. | |
| adduser $user | |
| passwd $user | |
| # Use the usermod command to add the user to the sudo group. | |
| usermod -aG $group $user | |
| # create .ssh folder | |
| cd $home | |
| mkdir .ssh | |
| chmod 700 .ssh | |
| # create authorized_keys file | |
| cd $ssh_folder | |
| touch authorized_keys | |
| chmod 600 authorized_keys | |
| chown -R $user:$user $ssh_folder | |
| # add key |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment