๐ค 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.