How can I restart the SSH service via the command line on Mac OSX Mountain Lion please?

Using ps aux | grep 'ssh', I was able to deduce that the process is most likely /usr/sbin/sshd.

From here I searched the sshd documentation for references to 'restart' but found none.

I don't know what my next step should be.

  • 4
    What are you actually trying to accomplish? If it's something like reloading the sshd config, you don't need to -- launchd starts a new sshd process on demand when an incoming connection is received, which means that the config is automatically reread for each new connection. OTOH, if you're trying to change the listener settings, those are controlled by launchd not the sshd config at all (see here). Commented Sep 22, 2012 at 1:47
  • 1
    This was just one test of debugging a password request from supposedly passwordless ssh using public keys. Turns out the thing I has missed was to turn off StrictMode Commented Sep 22, 2012 at 8:10

5 Answers 5


See this answer to a similar question on ServerFault. The command should be the same in Mountain Lion.

You can stop the service using the 'unload' subcommand.

sudo launchctl unload  /System/Library/LaunchDaemons/ssh.plist

Update suggested by @MattClark: To restart the service use load after unload:

sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist

Note that existing SSH sessions will be terminated, so you need to run this independent of the current user session.

  • This one gets me launchctl: Error unloading: com.openssh.sshd Commented Apr 25, 2014 at 4:27
  • 4
    You are correct, I did misread this, that was my fault. However, this also did not answer the question as it was asked.
    – Matt Clark
    Commented Jun 21, 2016 at 16:34
  • You can run this in one go with C-x C-e (C stands for Control). Paste it into the terminal, then C-x C-c to execute the emacs kill command, which will prompt you to save. I did this remotely and it did not kill my connection... given your config is correct.
    – Ray Foss
    Commented Jun 24, 2019 at 14:20

There is no reason to 'unload' the sshd service, when instead you can just 'Stop' the sshd service. It will restart on it's own.

sudo launchctl stop com.openssh.sshd
  • 2
    on moutain lion: launchctl stop error: No such process
    – RickyA
    Commented Oct 10, 2013 at 8:45
  • 1
    @RickyA: Worked fine on OSX Mavericks
    – neu242
    Commented Oct 31, 2013 at 9:19
  • Doesn't work here (launchctl stop error: No such process) Commented Apr 25, 2014 at 4:26
  • 1
    You need to sudo since that is how it is launched. Compare the running daemons/agents launchctl list | grep -i openssh vs sudo launchctl list | grep -i openssh. For reference read the launchctl link
    – glenschler
    Commented Apr 25, 2014 at 13:06
  • 2
    This should be accepted answer.
    – o01
    Commented Sep 16, 2020 at 5:54

I couldn't confirm Ansgar's answer worked as there were no messages / obvious signs though I'm confident it did.

I also found killall sshd which kills and restarts sshd processes with the disadvantage that any connections are stopped.


You can restart sshd on macOS by running:

sudo launchctl kickstart -k system/com.openssh.sshd

This command slightly improves on launchctl stop because this does not rely on sshd automatically starting after you stop it. However, similar to launchctl stop this preserves existing ssh connections.


The question and answers seen here are too old (2012-2013). I tried them in Ventura (released in 2022) but none do work.

I conclude my testing on my two mac's (10.11.6/El Capitan@2016 and 13.1/Ventura@2022): both provide a GUI switch in Preferences|Common|Shares|RemoteLogin.

You just turn it off and on. sshd will be restarted and read the sshd_config file to reflect your changes.

(Although there are corresponding command-line commands for the two actions, I don't think you bother to know them.)

  • In my Ventura this setting is under System Settings > General > Sharing. It was already off, though, and turning it on didn't help.
    – Noumenon
    Commented Apr 5, 2023 at 16:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .