Reliable control of the SSH server service keeps remote administration available while allowing configuration changes and maintenance windows. Cleanly starting, restarting, or stopping the sshd daemon avoids half-applied settings and reduces the chance of unexpected lockouts during critical work.
On most Unix-like systems, the SSH server is provided by the OpenSSH sshd daemon and managed through init systems such as systemd, System V. Init scripts, or the legacy service wrapper. Each mechanism ultimately controls the same underlying service unit, usually named ssh or sshd, with standard actions for start, stop, restart, status, enable, and disable.
Controlling the SSH server requires root privileges and immediately affects remote sessions when the daemon is stopped or restarted. Remote-only systems should always have an alternate access path in case a configuration error prevents the service from starting again. Service names and unit files differ slightly between distributions, so confirming whether the local system uses ssh or sshd as the service name avoids confusing errors.
Related: How to check and validate SSH server's configuration
Related: How to configure the log level for an SSH server
| 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:
- Stop the SSH service using the service wrapper.
$ sudo service ssh stop
- Start the SSH service using systemd.
$ sudo systemctl start ssh
- Configure the SSH service 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.
Enabling the unit ensures sshd is started whenever the system reaches the multi-user target.
- Configure the 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.
Disabling the SSH service prevents automatic startup after reboot and can block remote logins until the service is manually started.
- Restart the SSH service using System V. Init scripts.
$ sudo /etc/init.d/ssh restart Restarting ssh (via systemctl): ssh.service.
Restarting applies configuration changes by stopping and starting the sshd daemon in a single operation.
- View the SSH service status using systemd to confirm that it is running.
$ sudo systemctl status ssh ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: active (running) since Sun 2020-07-12 08:33:28 +08; 1s ago ##### snipped #####State active (running) indicates a healthy sshd daemon that is ready to accept incoming connections.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
Comment anonymously. Login not required.
