Skip to content

Instantly share code, notes, and snippets.

@swapnilman
Last active September 23, 2020 02:53
Show Gist options
  • Select an option

  • Save swapnilman/14bb130e3d3b5cd4ab94bdc834ceb8da to your computer and use it in GitHub Desktop.

Select an option

Save swapnilman/14bb130e3d3b5cd4ab94bdc834ceb8da to your computer and use it in GitHub Desktop.
create user with root priilages
echo "Note: Make sure to login as root user"
echo "Username ?"
read username
adduser $username
#Sudo Permission
sed "/#\ User\ privilege\ specification/a$username\ ALL=(ALL:ALL)\ NOPASSWD:ALL" /etc/sudoers --in-place
cd /home/$username
#Generate PUB Files
ssh-keygen -b 2048 -f $username -t rsa
#Create Directory Under User Home Directory
mkdir .ssh
chmod 700 .ssh
#Copy Pub File to authorized_keys
cat $username.pub >> .ssh/authorized_keys
mv $username $username.pem
chmod 600 .ssh/authorized_keys
#Change Ownerships
chown $username .ssh
chown $username .ssh/authorized_keys
chmod 600 $username.pem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment