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:-
- Log in to Your Server.
- Open the SSH Configuration File to enable ssh root.
- Modify the PermitRootLogin Setting.
- Save the Changes.
- Restart the SSH Service.
- 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:
ssh your_username@server_ip_address
Replace your_username and server_ip_address with your actual username and server IP. Like this: –
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:
[root@urclouds ~]vi /etc/ssh/sshd_config
3. Modify the PermitRootLogin Setting
Locate the line that reads:
#PermitRootLogin no
Uncomment this line (remove the # at the beginning) and change no to yes like below
PermitRootLogin yes
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:
[root@urclouds ~] systemctl restart sshd
6. Test SSH Root Login
Now, we can test SSH root login by connecting as the root user from remote side.
[root@urclouds ~] ssh root@192.168.1.6
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:
- Use Strong Passwords: Ensure that the root password is complex and hard to guess.
- Restrict SSH Access: Limit SSH access to specific IP addresses if possible.
- Disable Password Authentication: Consider using SSH keys for authentication instead of passwords.
To disable password authentication, open the sshd_config file again and set:
PasswordAuthentication no
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