Last active
August 20, 2019 16:26
-
-
Save adithya2306/2f252a94494edf1a74161c17d905d0fb to your computer and use it in GitHub Desktop.
Create new SSH-enabled sudo user in a server
This file contains 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
shopt -s dotglob | |
sudo adduser adithya --disabled-password --gecos "" | |
sudo gpasswd -a adithya sudo | |
sudo mkdir /home/adithya/.ssh | |
sudo chmod 700 /home/adithya/.ssh/ | |
sudo sh -c "echo 'adithya ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers" | |
# Now copy paste ssh pubkey here | |
nano /home/adithya/.ssh/authorized_keys | |
sudo chmod 644 /home/adithya/.ssh/authorized_keys | |
sudo chown -R adithya:adithya /home/adithya/ | |
sudo systemctl restart ssh sshd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment