8

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
13

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
3

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.

You must log in to answer this question.

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