OS X : Terminal command to turn ON/OFF SSH server

I know how to turn on SSH server from System preferences :-

(System preferences -> Sharing -> Remote Login )

Now I am looking for a terminal command for the same.

By knowing it I can use the command in my Python Script (for project work).


Solution 1:

You can stop the ssh service by typing the following:

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

To start it again, use this:

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