Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

3 Answers

up vote 3 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
add comment

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
add comment

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
add comment

Your Answer

 
discard

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.