SudoUsersSecurity5 min read

Create a user with sudo permissions

Create a user with administrator privileges to operate your VPS without using root directly.


Using root directly is a security risk. Create a personal user with administrator privileges to operate your VPS safely.

Step 1 — Create the user

Connect as root and run:

bash
adduser deploy

The system asks for a password and optional details (name, phone). Complete the password and leave the rest empty.

Step 2 — Add to the sudo group

bash
usermod -aG sudo deploy

This grants administrator permissions to the deploy user.

Step 3 — Verify permissions

Switch to the new user and test sudo:

bash
su - deploy
sudo whoami

If it returns root, permissions are configured correctly.

Step 4 — Configure SSH access for the new user

From your local machine, copy your public key:

bash
ssh-copy-id deploy@YOUR_VPS_IP

If you don't have an SSH key, generate one first:

bash
ssh-keygen -t ed25519 -C "your-email@example.com"

Step 5 — Disable root SSH access (recommended)

Edit the SSH configuration:

bash
sudo nano /etc/ssh/sshd_config

Find and modify:

terminal
PermitRootLogin no

Restart the service:

bash
sudo systemctl restart sshd

Important

Before closing the root session, verify you can connect with the new user in another terminal. If something goes wrong, you still have access from the VNC console in the Baires Host panel.


Was this guide helpful?