How do I restart sshd daemon on Linux or Unix?

last updated in Categories , , , , , , ,

I made changed to my /etc/ssh/sshd_config file. How do I restart sshd daemon on Linux or Unix systems?

SSH is an acronym for Secure Shell. It is an Internet communication protocol that allows log into Linux or Unix bases systems and runs commands. One can exchange files using a secure channel over an insecure network such as the Internet. OpenSSH is developed as part of the OpenBSD project and by default installed on modern Linux and *BSD family of operating systems including macOS. This page shows how to restart sshd daemon using the command line option.

Procedure to restart sshd daemon

  1. Open the terminal application
  2. Edit the file /etc/ssh/sshd_config using a text editor such as vi or nano
  3. Restart sshd service on an Ubuntu or Debian Linux using the sudo systemctl restart ssh.serivce
  4. RHEL/CentOS Linux user run sudo systemctl restart sshd.serivce

The command to restart sshd varies from one variant of Linux or Unix distro to another. Hence, we will see all other commands below. Please note that you must login as root user to restart services. Either use the su command or sudo command.
Command to restart sshd daemon on Linux or Unix

How to restart the SSHD daemon in Debian / Ubuntu Linux

Type the systemctl command:
$ sudo systemctl restart ssh

CentOS / RHEL / Fedora / Redhat Linux Restart SSHD server

$ sudo systemctl restart sshd

Restating the SSHD daemon on FreeBSD Unix

# /etc/rc.d/sshd restart
OR
# service sshd restart

OpenBSD Unix restart the SSHD service

# /etc/rc.d/sshd restart
OR
# /etc/rc.d/sshd restart

Solaris 10 command

# svcadm disable ssh
# svcadm enable ssh

Solaris version 9 and older users, try:
# /etc/init.d/sshd stop
# /etc/init.d/sshd start

AIX Unix command

# stopsrc -s sshd
# startsrc -s sshd

HP-UX Unix command

To restart sshd daemon on HP-UX, first stop it and again start it as follows:
# /sbin/init.d/secsh stop
# /sbin/init.d/secsh start

Command line SSHD restart for Apple macOS based laptop or desttop

Open the terminal application and type the following two commands
$ sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
$ sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist

Conclusion

This page explained how to restart sshd daemon on Linux or Unix-like operating systems using various command-line options. For more information, see the official OpenSSH documents here. Another option is to read more about ssh client and sshd server by typing the following man command:
man ssh
man sshd

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

Start the discussion at www.nixcraft.com

Historical Comment Archive

2 comment

    Still, have a question? Get help on our forum!