Created
March 19, 2019 11:47
-
-
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
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
# 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