How to Enable SSH Root Login on CentOS

Secure Shell (SSH) is a widely used protocol for accessing remote machines securely over the network. It is often used to administer servers and network devices, and it provides a more secure alternative to Telnet and other remote login protocols.

By default, most Linux distributions do not allow root logins via SSH for security reasons. This is because an attacker can use brute-force techniques to try and guess the root password, which can compromise the entire system.

However, there are some situations where it may be necessary to enable root logins over SSH. In this guide, we will show you how to enable SSH root login on CentOS.

Step 1: Login as Root User

To enable SSH root login on CentOS, you must first log in as the root user. If you are currently logged in as a regular user, you can switch to the root user by running the following command:

su -

You will then be prompted to enter the root password.

See also  How to Create a File With a touch Command on CentOS

Step 2: Edit SSH Configuration File

Once you are logged in as the root user, you can edit the SSH configuration file to allow root logins. The configuration file is located at /etc/ssh/sshd_config. You can open the file using your favorite text editor. For example, to open the file using the nano text editor, run the following command:

nano /etc/ssh/sshd_config

Step 3: Enable Root Login

In the SSH configuration file, you will need to find the line that contains the following text:

#PermitRootLogin yes

Uncomment the line by removing the ‘#’ character and change the ‘no’ to ‘yes’ like below:

PermitRootLogin yes

Step 4: Restart SSH Service

See also  How to Install Git-GUI on CentOS

After you have made the changes to the SSH configuration file, you will need to restart the SSH service for the changes to take effect. You can do this by running the following command:

systemctl restart sshd

Step 5: Test SSH Root Login

Now that you have enabled root logins over SSH, you can test to make sure that everything is working as expected. From another machine, try to SSH into your CentOS server as the root user:

ssh root@your-server-ip-address

If everything is working correctly, you should now be logged in as the root user over SSH.

See also  3 Ways to Configure Persistent Static Routes on Linux CentOS

Commands Mentioned:

  • su – Substitute user identity
  • nano – Command-line text editor
  • systemctl – Command-line tool to manage system services


Enabling SSH root login on CentOS can be useful in some situations, but it should be done with caution. By default, CentOS disables root logins over SSH to improve security. However, if you need to enable root logins for a specific task, you can easily do so by following the steps outlined in this guide. Remember to always use strong passwords and keep your system up-to-date with the latest security patches to minimize the risk of compromise.

Please feel free to leave any comments or suggestions for improvements.


Leave a Reply

Your email address will not be published. Required fields are marked *