Created
April 17, 2020 10:59
-
-
Save acepsaepudin/bc0d7368bb93e1949fbbba05e9737da1 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
username="" | |
publickey="" | |
create_user () { | |
sudo adduser $1 | |
sudo echo $1 | passwd --stdin $1 | |
echo "user" $1 "created" | |
sudo mkdir -p /home/$1/.ssh | |
echo "directory user" $1 "created" | |
sudo cat <<EOF >> authorized_keys | |
$publickey | |
EOF | |
sudo mv authorized_keys /home/$1/.ssh/authorized_keys | |
sudo cat /home/$1/.ssh/authorized_keys | |
sudo chmod 600 /home/$1/.ssh/authorized_keys | |
sudo chown -R $1:$1 /home/$1/.ssh | |
sudo chown -R $1:$1 /home/$1/.ssh/authorized_keys | |
sudo cat /etc/passwd | grep $1 | |
echo "DONE" | |
} | |
create_user $username $publickey |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment