How to install, manage, start and autostart ssh service on RHEL 7 Linux

systemctl command is used on RedHat 7 linux to manage services system wide. It allows administrators to manage ssh service to start, restart, stop or enable autoload after system startup.

In install ssh service on your RHEL 7 linux run a following linux command:

# yum install openssh

By defalt SSH service or to be more precise sshd ( daemon ) is disabled. Once the opensshd package installed, you can check the status of SSHD service by using the below command:

# systemctl status sshd
sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled)
   Active: inactive (dead)

To start ssh daemon (sshd) on RHEL 7 run:

systemctl start sshd

After you have successfully started SSHD daemon check the sshd service status by:

# systemctl status sshd
sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled)
   Active: active (running) since Mon 2014-09-01 09:35:17 EST; 2s ago
  Process: 6191 ExecStartPre=/usr/sbin/sshd-keygen (code=exited, status=0/SUCCESS)
 Main PID: 6194 (sshd)
   CGroup: /system.slice/sshd.service
           └─6194 /usr/sbin/sshd -D

Sep 01 09:35:17 localhost.localdomain systemd[1]: Started OpenSSH server daemon.
Sep 01 09:35:17 localhost.localdomain sshd[6194]: Server listening on 0.0.0.0 port 22.
Sep 01 09:35:17 localhost.localdomain sshd[6194]: Server listening on :: port 22.

Next, time you reboot your RHEL 7 Linux box you will need to manually start ssh service again. To start sshd service automatically after reboot enter a following linux command into your terminal:

# systemctl enable sshd
ln -s '/usr/lib/systemd/system/sshd.service' '/etc/systemd/system/multi-user.target.wants/sshd.service'

To disable sshd on your RHEL 7 linux system amend the above command to:

# systemctl disable sshd
rm '/etc/systemd/system/multi-user.target.wants/sshd.service'