This post will cover how to enable (or disbale) Root login via SSH.
It’s always best practice that any machine on the internet not allow direct Root login via SSH.
To allow Root to log in, we need to update our sshd_config file located at /etc/ssh/sshd_config.
To update this file, we need to switch over to Root:
- [[email protected]~]$ su root
- Password:
- [[email protected] ~]#
Go to the /ect/ssh directory:
- [[email protected] ~]# cd /etc/ssh
- [[email protected] ssh]#
Now, let’s edit our sshd_config file using vi:
- [[email protected] ssh]# vi sshd_config
Look for the following section (about 1/3 of the way down):
- #LoginGraceTime 2m
- PermitRootLogin no
Hit “i” to insert and then change the value for PermitRootLogin from no to yes.
Hit Escape and then :wq! to save changes and close the file.
Finally, still as Root, we need to restart SSHD using /etc/init.d/sshd restart.
- [[email protected] ssh]# /etc/init.d/sshd restart
- Stopping sshd: [ OK ]
- Starting sshd: [ OK ]
Exit your session, open a new terminal and confirm you are now able to login as Root:
- login as: root
- [email protected]’s password:
- Last login: Mon Jun 28 16:21:53 2010
- [[email protected] ~]#
To prevent Root log in, simply set to (or change to) PermitRootLogin no in your sshd_config