Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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). – Gordon Davisson Sep 22 '12 at 1:47
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 – James Webster Sep 22 '12 at 8:10
up vote 8 down vote accepted

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
share|improve this answer
This one gets me launchctl: Error unloading: com.openssh.sshd – NicolasMiari Apr 25 '14 at 4:27

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
share|improve this answer
on moutain lion: launchctl stop error: No such process – RickyA Oct 10 '13 at 8:45
@RickyA: Worked fine on OSX Mavericks – neu242 Oct 31 '13 at 9:19
Doesn't work here (launchctl stop error: No such process) – NicolasMiari Apr 25 '14 at 4:26
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 Apr 25 '14 at 13:06
This no longer works in OS X Yosemite, attempting to stop sshd (as root) results in exit status of 3, and the service continues running. – RCross Mar 7 '15 at 20:01

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.