how to turn on and off remote login in terminal (or applescript)

applescript, macos, terminal

Solution

I haven't fully checked, but I think these'll work as far back as v10.4. To turn remote login (ssh) on:

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

To turn it off:

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

Note that these don't adjust the service access control list, i.e. which accounts are allowed to ssh in. That's controlled by membership in a hidden system group named "com.apple.access_ssh" (long name: "Remote Login ACL").

Problem

I need to turn on and off remote login through terminal or applescript. I need it to be compatible with os x leopard. Thanks!

Original source