Skip to content

Instantly share code, notes, and snippets.

@adithya2306
Last active August 20, 2019 16:26
Show Gist options
  • Save adithya2306/2f252a94494edf1a74161c17d905d0fb to your computer and use it in GitHub Desktop.
Save adithya2306/2f252a94494edf1a74161c17d905d0fb to your computer and use it in GitHub Desktop.
Create new SSH-enabled sudo user in a server
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