How To Restart SSH Service under Linux / UNIX

How do I restart SSH service under Linux or UNIX operating 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 ssh service.

Restart SSH Service Command

The command to restart sshd are as follows (you must login as root user). You must run command as per your Linux distribution or Unix variant.
Restart ssh service in Linux or Unix

CentOS / RHEL / Fedora / Redhat Linux Restart SSH

Type the following command:
# /etc/init.d/sshd restart
One can use the service command:
# service sshd restart
If you are using RHEL/CentOS/Fedora Linux with systemd (e.g. RHEL or CentOS v7/8), enter:
$ sudo systemctl restart sshd

How to restart the SSH in Debian / Ubuntu Linux

Restarting ssh is simple job, exeute:
# /etc/init.d/ssh restart
# service ssh restart
$ sudo service ssh restart
If you are using Debian/Ubuntu/Mint Linux with systemd, use the systemctl command:
$ sudo systemctl restart ssh

FreeBSD Restart SSH

# /etc/rc.d/sshd restart
$ sudo service sshd restart

OpenBSD Restart SSH service

# /etc/rc.d/sshd restart
$ doas /etc/rc.d/sshd restart

UNIX Restart SSH

# kill -HUP `cat /var/run/`
# kill -HUP $(cat /var/run/
Please note that the location of /var/run/ may change. So just search a bit through /var/run/ directory.

OpenSUSE/SUSE Enterprise Linux restart sshd

Type the following command:
$ sudo systemctl restart sshd

Arch Linux restart sshd server

Execute the follwoing command:
$ sudo systemctl restart sshd.service

Command line SSH restart for Apple macOS

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

$ sudo launchctl stop com.openssh.sshd
$ sudo launchctl start com.openssh.sshd

Slackware Linux restart the SSH server

Restarting ssh is pretty easy on Slackware, just run the following command as root user:
# /etc/rc.d/rc.sshd restart


This page explained how to restart ssh service on Linux or Unix-like operating systems using various 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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 3 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersncdu pydf
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
3 comments… add one
  • Matt Nov 2, 2016 @ 20:34

    If you are running Raspbian with OpenBSD then you can use:
    $ sudo service ssh restart

  • Dan Jan 24, 2017 @ 13:39

    I made an error following what I assumed (yes I know) was starting up a service but in fact I changed permissions. Is there a way to redact the change? I don’t have yum installed (policy) and now cannot start a PuTTy session to load files on a remote server through port 22. I’m at a stand still.

  • Kevin Casnter Apr 5, 2017 @ 9:56

    But, why restart the ssh server? To make sure the SSH server takes the new configuration into account, we need to restart the SSH server with the command such as

     /etc/rc.d/rc.sshd restart

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum