OpenSSH Server Installation and Configuration
OpenSSH Server is available under default yum repositories. Use the following command to install or update the latest OpenSSH server:
#yum install -y openssh openssh-server openssh-clients openssl-libs && systemctl start sshd
Enable SSH Root Login
To enable login as root, modify the main SSH configuration file "sshd_config" with a text editor of your choice. In this example, we'll use vim:
Note: To edit with vim, use "INSERT" key to go into edit mode, and "ESC" key to exit edit mode. After editing, you have two options to save and quit:
- Press "ESC" key, and type
:wq
(yes, the colon is included) and hit/press "ENTER" - Press "ESC" key, and type
:x
and hit/press "ENTER"
To edit the file:
#vi /etc/ssh/sshd_config
Find the following line in the file:
#PermitRootLogin without-password
Remove ‘#’ at the beginning of the line, and change ‘without-password’ to ‘yes’ as shown below:
#PermitRootLogin without-password
PermitRootLogin yes
After saving the file with "ESC" :wq
or "ESC" :x
, restart the sshd service:
#systemctl restart sshd.service
Quick Guide Commands:
Check sshd status:
#systemctl status sshd.service
Install sshd:
#yum install -y openssh openssh-server openssh-clients openssl-libs
Start sshd:
#systemctl start sshd.service
Stop sshd (Do not run if connected via SSH):
#systemctl stop sshd.service
Restart sshd:
#systemctl restart sshd.service
Reload sshd (after config changes):
#systemctl reload sshd.service
If you find this complex or feel insecure, contact our system admins to Enable or Disable root login through SSH on your CentOS server by opening a ticket or using Live Chat.