Colocation is here. $10/mo off all plans, 1U from $50/mo. Sign up and ship your servers whenever you're ready. First servers go online April 13th!
Fyra Stack Stack

Adding a Non-Root User

Use a personal admin user for day-to-day access instead of logging in as root. This gives you a safer default workflow while still allowing administrative commands through sudo.

Replace stackuser in the examples below with your preferred username.

1. Create the User

Fedora

sudo adduser stackuser
sudo passwd stackuser
sudo usermod -aG wheel stackuser

Debian / Ubuntu

sudo adduser stackuser
sudo usermod -aG sudo stackuser

2. Add your SSH Key

If your root account already has the correct public key in authorized_keys, copy it to the new user:

sudo mkdir -p /home/stackuser/.ssh
sudo cp /root/.ssh/authorized_keys /home/stackuser/.ssh/authorized_keys
sudo chown -R stackuser:stackuser /home/stackuser/.ssh
sudo chmod 700 /home/stackuser/.ssh
sudo chmod 600 /home/stackuser/.ssh/authorized_keys

If you want to add a different key, create the file and paste your public key instead:

sudo mkdir -p /home/stackuser/.ssh
sudo nano /home/stackuser/.ssh/authorized_keys
sudo chown -R stackuser:stackuser /home/stackuser/.ssh
sudo chmod 700 /home/stackuser/.ssh
sudo chmod 600 /home/stackuser/.ssh/authorized_keys

Alternatively, you can also copy the key from your local machine to the VPS:

ssh-copy-id stackuser@your_vps_ip

Note that this will not work if you have disabled password-based authentication.

Optional - Edit your SSH Configuration

If you previously created an SSH config shortcut for your root account, you can update it to use the new user by editing ~/.ssh/config:

Host my-vps
  HostName your_vps_ip
  User stackuser
  IdentityFile ~/.ssh/id_ed25519
  AddKeysToAgent yes

3. Test the New Login

Keep your current session open, then open a new terminal and confirm the new user can log in:

ssh stackuser@your_server_ip

Once connected as the new user, confirm sudo works:

sudo whoami

The command should print root.

4. Next Steps

After you have confirmed the new user can log in and run sudo, continue with Initial server hardening to lock down SSH, configure a firewall, and set up fail2ban.