For my job, before I deploy a new Mac laptop, I need to enable these two settings:

  1. System Preferences - Sharing - Remote Login. Once enabled I also need to add the admin account that previously I have created by selecting the little + symbol under Only these users:

  2. System Preferences - Sharing - Remote Management - (the little pop up windows comes out) and I select all the features

How do I achieve the above two process via command line?

  • Which deployment solution do you use? DeployStudio, Casper or scripts? – klanomath Apr 5 '17 at 18:50
  • neither. i just ssh into the machine to do stuff. But I need to enable the two steps above before I do that for different reasons. – Fabio Viola Apr 5 '17 at 19:32

Modifying remote login and remote management settings is done with two different commands - both executed as root:

  • systemsetup
  • kickstart

To enable remote login for members of the admin group enter:

sudo systemsetup -setremotelogin on

To restrict access use dseditgroup. First check if it exists and add it if necessary:

dseditgroup com.apple.access_ssh
dseditgroup -o create -q com.apple.access_ssh

and add a user group:

sudo dseditgroup -o edit -a admin -t group com.apple.access_ssh

To enable remote management for admin users enter:

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -users admin -privs -all -restart -agent -menu

To check other options enter:

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart --help
  • 2
    since 10.14 you cannot enable via ssh. If Yo connect via ssh, You got: Warning: macos 10.14 and later only allows control if Screen Sharing is enabled through System Preferences. – ingconti Mar 25 '20 at 7:00

Enabling SSH:

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

Disabling SSH:

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

(the alternative, systemsetup is deprecated)

This command still works, but it is deprecated. Please use launchctl(8) instead.
  • Very helpful. I had a script, running as root, that used the systemsetup command. However, in Catalina, it was not working, as it needed Full Disk Access (SystemPolicyAllFiles) but did not have a way to prompt the user for it. Using the launchctl command worked perfectly. – Tim Dearborn Jun 18 '20 at 21:07

You must log in to answer this question.

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