Last active
September 23, 2020 02:53
-
-
Save swapnilman/14bb130e3d3b5cd4ab94bdc834ceb8da to your computer and use it in GitHub Desktop.
create user with root priilages
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
| 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