Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angelospanag/8b7c0722e52b07132fa74da825f01371 to your computer and use it in GitHub Desktop.
Save angelospanag/8b7c0722e52b07132fa74da825f01371 to your computer and use it in GitHub Desktop.
Add a custom user to Ubuntu with sudo privileges, disabled password and SSH access
# Create user with disabled password
sudo adduser angelospanag --disabled-password
# Switch to the new custom user (example angelospanag)
sudo su - angelospanag
# Create .ssh folder
cd
mkdir .ssh
chmod 700 .ssh
# Create authorized_keys file that will hold SSH public keys
cd
touch .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
## Now you should add your public SSH key to the authorized_keys file in a new line
# Use the following command to open the Ubuntu sudoers file
sudo visudo -f /etc/sudoers.d/90-cloud-init-users
## Add the following line to the file: angelospanag ALL=(ALL) NOPASSWD:ALL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment