Menu

1/24/25

Open ssh for root user on Centos 10

 

Step 1: Edit the SSH Configuration File

  1. Open the SSH configuration file using a text editor. You can use nanovi, or any other text editor you prefer. Here, we'll use nano:

    bash
    1sudo nano /etc/ssh/sshd_config
  2. Look for the line that says:

    plaintext
    1PermitRootLogin no

    If it exists, change it to:

    plaintext
    1PermitRootLogin yes

    If the line does not exist, you can add it.

  3. Save the changes and exit the editor. In nano, you can do this by pressing CTRL + X, then Y to confirm, and Enter to save.

Step 2: Restart the SSH Service

After making changes to the SSH configuration, you need to restart the SSH service for the changes to take effect:

bash
1sudo systemctl restart sshd

Step 3: Configure Firewall (if applicable)

If you have a firewall enabled, ensure that SSH traffic is allowed. You can do this with the following commands:

bash
1sudo firewall-cmd --permanent --add-service=ssh 2sudo firewall-cmd --reload

Step 4: Set a Strong Password for the Root User

If you haven't already set a strong password for the root user, you can do so with the following command:

bash
1sudo passwd root

Step 5: Verify SSH Access for Root

You can now attempt to SSH into your CentOS 9 server as the root user. Use the following command, replacing server_ip with the actual IP address of your server:

bash
1ssh root@server_ip