Skip to main content

๐Ÿ‘ค Create a Sudo User

Instead of using the root account, it's best to create a regular user with sudo privileges.


โœ… Step 1: Create the New Userโ€‹

adduser yourusername

Follow the prompts to set a password and optional user info.


๐Ÿ”‘ Step 2: Grant Sudo Accessโ€‹

usermod -aG sudo yourusername

This allows the new user to execute administrative commands with sudo.


๐Ÿงช Step 3: Test SSH Loginโ€‹

Before moving on, test logging in with the new user from another terminal:

ssh yourusername@your_vps_ip

Once confirmed, proceed.


๐Ÿšซ Step 4: Disable Root SSH Loginโ€‹

Now that your sudo user works, you can disable remote root login.

Edit the SSH config:โ€‹

sudo nano /etc/ssh/sshd_config

Find this line:

PermitRootLogin yes

Change it to:

PermitRootLogin no

Then restart SSH:

sudo systemctl restart ssh

โœ… Now only your sudo user can log in via SSH.

ยฉ 2025 TokioStack. All rights reserved.
DMCA.com Protection Status