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

You can use all three methods to manage your SSH server on most platforms. Common options include the availability to start, restart and stop the service along with the option to view detailed status of the running OpenSSH server.

System V. Init scripts /etc/init.d/ssh/[start|restart|stop|status]
Systemd systemctl [start|restart|stop|status] 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. Restart SSH service using System V. Init scripts.
    $ sudo /etc/init.d/ssh restart
    Restarting ssh (via systemctl): ssh.service.
  4. 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)
        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 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.
Share this guide!
Discuss the article:

Comment anonymously. Login not required.