SSH in CentOS 7: install - start & stop - enable & disable SSH server

OpenSSH Server is available under default yum repositories. We can install or update the latest OpenSSH server using following command available under yum repositories.

Should the service not be installed, you can then install all the necessary files with the following command:
(the installation process will download the SSH server, install it and start the service, at the same time)

#yum install -y openssh openssh-server openssh-clients openssl-libs && systemctl start sshd


Enable SSH Root Login
In order to enable login as root, you may need to modify the main SSH configuration file  “sshd_config” with a text editor of your choice. In our example, we will use vim as an editor.
Note: To edit with vim you use "INSERT" key to go into edit mode, and "ESC" key to exit edit mode, when your editing is done, you have two options to save the file and quit the editor, as follows:
1. Press "ESC" key, and type :wq (yes the colon is included) and hit/press "ENTER"
2. Press "ESC" key, and type :x and hit/press "ENTER"


So 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’ like in the examples shown below.
#PermitRootLogin without-password
PermitRootLogin yes
After you save 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
Alert: Do not run the command if you are connected thru ssh based session, then you will end up getting ‘network connectivity lost'.

systemctl stop sshd.service
Restart sshd
#systemctl restart sshd.service
Reload sshd (after config changes)
#systemctl reload sshd.service
If you think this is too complicated or feel insecure in doing this, you can simply ask our system admins to Enable or Disable root login through SSH on your CentOS server. By opening a ticket or use Live Chat



  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

How to connect to VPS with SSH Using Windows, Linux or macOS

Connecting with SSH (Secure Shell)There are 2 primary ways to connect to a Linux VPS. The first...

SSH in CentOS 6: install - start & stop - enable & disable SSH server

  To accept SSH connections, the system must first be running the SSH server.CentOS 6 installs...

SSH in Debian & Ubuntu: install SSH

Install SSH on Debian System #apt-get -y update && apt-get -y install openssh-server...