HowTo: Restart SSH Service under Linux / UNIX

Posted on in Categories , , , , , , last updated January 9, 2017

How do I restart SSH service under Linux or UNIX operating systems?

The command to restart ssh are as follows (you must login as root user). You must run command as per your Linux distro or Unix variant:
restart-ssh-command

CentOS / RHEL / Fedora / Redhat Linux Restart SSH

# /etc/init.d/sshd restart
OR
# service sshd restart
If you are using RHEL/CentOS/Fedora Linux with systemd, enter:
$ sudo systemctl restart sshd

Debian / Ubuntu Linux Restart SSH

# /etc/init.d/ssh restart
OR
# service ssh restart
OR
$ sudo service ssh restart
If you are using Debian/Ubuntu/Mint Linux with systemd, enter:
$ sudo systemctl restart ssh

FreeBSD Restart SSH

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

OpenBSD Restart SSH

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

UNIX Restart SSH

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

Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin and a trainer for the Linux operating system/Unix shell scripting. He has worked with global clients and in various industries, including IT, education, defense and space research, and the nonprofit sector. Follow him on Twitter, Facebook, Google+.

3 comment

  1. 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.

  2. Dan January 24, 2017, 1:39 pm
    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.

    REPLY LINK
    Kevin Casnter April 5, 2017, 9:55 am
    Your comment is awaiting moderation.

    pick it pack it fire it up come along and take a hit from the bong.

    REPLY LINK

Leave a Comment