English

Create a sudo user on a Linux VPS

1 min
VPS/VDS Hosting

Logging in only as root is convenient but risky. This guide shows how to create a dedicated user with sudo and SSH key access — a great complement to Secure SSH and UFW.

📋 Prerequisites

  • A Linux VPS (Ubuntu/Debian) with root or sudo access and an active SSH session.

Create the user

Replace deploy with your preferred username:

Bash
sudo adduser deploy sudo usermod -aG sudo deploy

Add to the sudo group

Bash
sudo groups deploy # doit afficher : deploy sudo (ou wheel sur certaines distros)

Set up an SSH key

On your PC, generate a key if needed (ssh-keygen -t ed25519). Then copy it to the server (as root, or as the new user once sudo works):

Bash
ssh-copy-id deploy@IP_DU_VPS

Puis connectez-vous : ssh deploy@IP_DU_VPS

Test sudo

Bash
sudo apt update # ou : sudo whoami → root

Best practices

  • Disable root password login after testing (see Secure SSH).
  • Keep the SSH port allowed in UFW.
  • Use strong passwords if you keep password authentication as a fallback.

Happy deploying! 🚀

Stay up to date with the latest offers, discounts and special promotions.

View promotions

We use cookies

We use analytics cookies to improve your experience on our site. No data is sold to third parties. Learn more in our privacy policy.