Create a sudo user (without root login)
Good practice: never use root on a daily basis, create a dedicated user.
What this tutorial does
The tutorial "Create a sudo user (without root login)" helps you achieve this goal:
Good practice: never use root on a daily basis, create a dedicated user.
Debian/Ubuntu
-
Create user: adduser deploy - Add to sudo group: usermod -aG sudo deploy
- Test by connecting: su - deploy
- Check sudo rights: sudo whoami (must return root)
- --- Optional: allow sudo without password ---
- visudo and add at the end of the file: deploy ALL=(ALL) NOPASSWD:ALL
-
--- Copy SSH keys from root to new user --- -
mkdir -p /home/deploy/.ssh -
cp /root/.ssh/authorized_keys /home/deploy/.ssh/ -
chown -R deploy:deploy /home/deploy/.ssh -
chmod 700 /home/deploy/.ssh && chmod 600 /home/deploy/.ssh/authorized_keys