SSH server service by OpenSSH is normally provided by the sshd daemon. In most Unix-based operating systems, systemd, System V. Init scripts, or the service command service.

You can use all three methods to manage your SSH server service on most platforms. Standard options include the ability to start, stop and restart the service. You can also view the detailed status of the running sshd daemon and set whether to start sshd during system startup automatically.

Method Command
System V. Init scripts /etc/init.d/ssh [start|restart|stop|status]
Systemd systemctl [start|restart|stop|status|enable|disable] ssh
service command service ssh [start|restart|stop|status]

Some distributions use sshd instead of ssh as the name of their init script.

Steps to manage OpenSSH server from command line:

  1. Stop SSH service using service command.

    $ sudo service ssh stop

  2. Start SSH service using systemd.

    $ sudo systemctl start ssh

  3. Configure SSH to automatically start during system boot.

    $ sudo systemctl enable ssh Synchronizing state of ssh.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable ssh Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service. Created symlink /etc/systemd/system/multi-user.target.wants/ssh.service → /lib/systemd/system/ssh.service.

  4. Configure SSH service to not automatically start during system boot.

    $ sudo systemctl disable ssh Synchronizing state of ssh.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install disable ssh Removed /etc/systemd/system/multi-user.target.wants/ssh.service. Removed /etc/systemd/system/sshd.service.

  5. Restart SSH service using System V. Init scripts.

    $ sudo /etc/init.d/ssh restart Restarting ssh (via systemctl): ssh.service.

  6. View SSH status using systemd.

    $ sudo systemctl status ssh ● ssh.service - OpenBSD Secure Shell server      Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: >      Active: active (running) since Sun 2020-07-12 08:33:28 +08; 1s ago        Docs: man:sshd(8)              man:sshd_config(5)     Process: 3608 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCES>    Main PID: 3629 (sshd)       Tasks: 1 (limit: 4624)      Memory: 1.3M      CGroup: /system.slice/ssh.service              └─3629 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups  Jul 12 08:33:27 host systemd[1]: Starting OpenBSD Secure Shell server... Jul 12 08:33:28 host sshd[3629]: Server listening on 0.0.0.0 port 22. Jul 12 08:33:28 host sshd[3629]: Server listening on :: port 22. Jul 12 08:33:28 host systemd[1]: Started OpenBSD Secure Shell server.