There are several ways to enable screen sharing on OS X El Capitan from the command line. The first method is an old standby:
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -off -restart -agent -privs -all -allowAccessFor -allUsers
This will work in 99% of the cases, but there may be some situations when it’s not quite enough. The above command enables Screen Sharing by enabling Remote Management; however, we lose the ability to add fine-grained control to who can connect & those who can’t.
Here’s another way to enable screen sharing from the command line:
sudo defaults write /var/db/launchd.db/com.apple.launchd/overrides.plist com.apple.screensharing -dict Disabled -bool false sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
In the second example, we enable only Screen Sharing, not Remote Management. This allows us to use System Preferences to restrict who can screen share to our machine (e.g. local administrators, network administrators). We use the second example when configuring our authentication servers remotely.
About the Author
BiographyMore Content by Abby Kearns