How to create a sudo user on Ubuntu VPS
Creating a sudo user is one of the recommended first steps when setting up an Ubuntu VPS. This avoids always working as root and keeps administrative tasks associated with an identifiable account.
1. Create the user
Replace administrator with the desired name:
adduser administrador
Set a strong password. The remaining fields are optional.
2. Add to sudo group
usermod -aG sudo administrador
groups administrador
The output must include sudo.
3. Test permission
su - administrador
sudo whoami
After entering the password, the expected result is:
root
4. Test a new SSH connection
In another terminal:
ssh administrador@IP_DA_VPS
Keep the root session open until you confirm that login and sudo work.
5. Set up an SSH key
On your computer:
ssh-keygen -t ed25519
On Linux or macOS, send the key with:
ssh-copy-id administrador@IP_DA_VPS
If ssh-copy-id is not available, copy the public key. On the VPS, logged in as the new user:
mkdir -p ~/.ssh
chmod 700 ~/.ssh
nano ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
Paste the public key into a single line and test a new connection.
6. Optional: Disable root login
Do this only after testing the new user and key.
sudo nano /etc/ssh/sshd_config.d/99-nicehosting-security.conf
Add:
PermitRootLogin no
Validate and recharge:
sudo sshd -t
sudo systemctl reload ssh
Do not close the current session before testing another connection.
How to remove sudo
sudo deluser administrador sudo
This does not delete the account or its files.
Frequently asked questions
What is the difference between root and sudo?
Root has full control at all times. With sudo, the user elevates permission to only one administrative command.
Can I create more than one sudo user?
Yes. Separate accounts for each administrator improve organization and prevent password sharing.
Is it safe to disable root login?
Yes, as long as another user with sudo and SSH has been tested. Incorrect configuration may block remote access.
What are the other initial settings?
See Getting Started on a Linux Ubuntu VPS.
If you need help, open a ticket with Nice Hosting support.