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 ability to start, stop and restart the SSH
. You can also view detailed status of the running sshd
daemon and set to whether or not to automatically start sshd
during system startup.
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.
SSH
service using service
command. $ sudo service ssh stop
SSH
service using systemd
. $ sudo systemctl start ssh
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.
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.
SSH
service using System V. Init scripts
. $ sudo /etc/init.d/ssh restart Restarting ssh (via systemctl): ssh.service.
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.
Comment anonymously. Login not required.