Key takeaways
- Day-to-day work as root makes mistakes and break-ins more dangerous.
- Members of the sudo group can run admin commands with their own password.
- Copy your SSH key to the new user before disabling root login.
Create the user
Log in as root, then:
adduser deploy
Set a strong password and press Enter through the optional details.
Grant sudo rights
usermod -aG sudo deploy
Copy your SSH key
If you log in as root with a key, give the new user the same access:
rsync --archive --chown=deploy:deploy ~/.ssh /home/deploy
Test
Open a new terminal:
ssh deploy@203.0.113.10
sudo whoami # should print: root
Once this works, you can disable direct root login (PermitRootLogin no in /etc/ssh/sshd_config).
Frequently asked questions
What's the difference between su and sudo?
su switches to another user (often root) entirely. sudo runs a single command with elevated rights and logs it, which is safer and auditable.
Does this work on Debian?
Yes. On Debian you may need to install sudo first with apt install sudo.