Customer Support

  1. Support
  2. How to disable root login via SSH on your VPS (Linux)
  1. Home
  2. Dedicated / VPS Management
  3. How to disable root login via SSH on your VPS (Linux)

How to disable root login via SSH on your VPS (Linux)

VPS servers are often targeted by automated bots. On Linux servers, these bots typically scan for the SSH port (usually port 22) and attempt to gain root access via brute-force attacks.

To improve your server's security, it's highly recommended that you change the default SSH port and disable root login via SSH. This setting is applied automatically if you're using DirectAdmin, Plesk, or cPanel, but you can also configure it manually by following this guide.

Below is a step-by-step guide on how to do it:

Steps to Disable SSH Root Login

1. Connect to Your VPS

Access your VPS via SSH as root:

ssh root@your-server-ip

2. Open the SSH Configuration File

Run the following command to edit the sshd_config file:

sudo nano /etc/ssh/sshd_config

3. Edit the PermitRootLogin Setting

Inside the file, locate the # Authentication section and change or add the following line:

PermitRootLogin no

To save the changes:

  • Press Ctrl + O to write (save) the changes
  • Then press Y to confirm
  • And finally press Enter to save the file
  • Press Ctrl + X to exit the nano editor

4. Restart the SSH Service

Apply the changes by restarting the SSH service:

sudo systemctl restart ssh

Important: If you’re already disconnected from root, make sure you’ve created a non-root user with sudo access to log back in.


What This Achieves

  • Prevents brute-force attacks targeting root login.
  • Keeps your SSH logs cleaner and easier to review.
  • Strengthens the overall security of your server.

As an extra security step, you might also consider changing the default SSH port or creating a new user with sudo privileges. Let me know if you’d like guides for those too.


You haven't found what you are looking for?

Contact our experts, they will be happy to help!

Contact us