Creating a non-root user

Create a user with sudo privileges on a Linux VPS so you can avoid using root day to day, and set up its SSH key.

Updated

Why avoid root day to day

The root account has every right on the system, without restriction. A mistyped command (a wrong path in an rm, a bad redirection) has a far wider impact as root than as a limited user. The recommended practice is to create a dedicated user with administrative privileges granted case by case through sudo, and to reserve root for the situations that genuinely require it.

Creating the new user

adduser myuser

The command asks for a password and a few optional details (full name and so on — all of which may be left blank).

Granting sudo privileges

On Debian/Ubuntu, add the user to the sudo group:

usermod -aG sudo myuser

They can now run administrative commands by prefixing them with sudo, after confirming their own password.

Setting up their SSH key

Copy your public SSH key over to the new user so you can connect directly without a password:

rsync --archive --chown=myuser:myuser ~/.ssh /home/myuser

Or, if you are already connected as that new user:

ssh-copy-id myuser@your-vps-ip-address

Test before cutting off root access

Disabling direct root SSH login

Once that is confirmed, edit the SSH configuration:

sudo nano /etc/ssh/sshd_config
PermitRootLogin no

Then restart the SSH service:

sudo systemctl restart sshd

root remains reachable through sudo from the new user, but no longer over a direct SSH connection — an extra layer of protection against automated intrusion attempts, which almost always target that account first.

Can’t find your answer?

The team answers tickets seven days a week, and the Discord is open to everyone.