How to Enable SSH Root Login on CentOS 9 Stream?

Dear friends, Today we will see how to enable ssh root login on Centos 9 Stream. So let’s start this session and see step by step this process.

By default, SSH root login is disabled in CentOS for security reasons. However, if we need to enable it for administrative purposes, we have to follow these steps:-

  1. Log in to Your Server.
  2. Open the SSH Configuration File to enable ssh root.
  3. Modify the PermitRootLogin Setting.
  4. Save the Changes.
  5. Restart the SSH Service.
  6. Test SSH Root Login.

1. Log in to Your Server

Start by logging into your CentOS server using an account with sudo privileges. Open your terminal and run:

Replace your_username and server_ip_address with your actual username and server IP. Like this: –

Enable ssh root

You can see hare we are not able to login as root user from remote side.

So, in this case we have to login on console with root user and password, and we have to change this configuration in sshd_config file to access our server from remote side.

2. Open the SSH Configuration File to enable ssh root

Once logged in, you need to edit the SSH configuration file. Use a text editor like nano or vi:

3. Modify the PermitRootLogin Setting

Locate the line that reads:

Uncomment this line (remove the # at the beginning) and change no to yes like below

4. Save the Changes

If you’re using nano, save your changes by pressing CTRL + O, then hit Enter. Exit the editor with CTRL + X. If you’re using vi, type :wq and hit Enter to save and exit.

5. Restart the SSH Service

To apply these changes, we have to restart the SSH service:

6. Test SSH Root Login

Now, we can test SSH root login by connecting as the root user from remote side.

you will be prompted for the root password. Enter the root password to log in as a root user. After that you will be successfully login as a root user.

Important Security Considerations to enable ssh root

Enabling root login can expose your server to potential security risks. Here are a few recommendations to enhance security:

  1. Use Strong Passwords: Ensure that the root password is complex and hard to guess.
  2. Restrict SSH Access: Limit SSH access to specific IP addresses if possible.
  3. Disable Password Authentication: Consider using SSH keys for authentication instead of passwords.

To disable password authentication, open the sshd_config file again and set:

Conclusion

Enabling SSH root login on CentOS is straightforward, but it’s essential to understand the security implications. Always ensure that your server is well-protected to avoid unauthorized access.

If you want to know more about SSH then you can Click_Here

How to Increase SSH Connection Timeout in Linux

Leave a Reply