Skip to content

Instantly share code, notes, and snippets.

@henri
Last active February 9, 2024 22:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henri/bdac9b92e91a5e9d01a581a62ae4c5ec to your computer and use it in GitHub Desktop.
Save henri/bdac9b92e91a5e9d01a581a62ae4c5ec to your computer and use it in GitHub Desktop.
macOS sharing command line shortcuts
# Sometimes GateKeeper / SIP / FullDisk Access gets in the way of enableing various services on recent version of macOS
# It is possible to check if this is the case using these commands. The GUI tends to just hang. The apprach below will
# provide you with some feedback. Perhaps an update to macOS at some point will display a dialog box telling you why
# the service is not abe to start.
# check sshd status
sudo systemsetup -getremotelogin
# enable sshd
sudo systemsetup -setremotelogin on
# enable sshd (forcefully)
sudo systemsetup -f -setremotelogin off
# disable sshd
sudo systemsetup -setremotelogin off
# disbale sshd (forcefully)
sudo systemsetup -f -setremotelogin off
# sometimes, on some version of MacOS things are really broken with the built in SSHD system.
# you can try the following command to turn on sshd
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist
# to turn off this will do the job
sudo launchctl unload /System/Library/LaunchDaemons/ssh.plist
# If that fails then the next step may be to ditch the system (re-insteall) or possibly use your own seperate
# (non-native apple sshd server) - openssh is a good choice.
# This command may assist you with issues starting ARD / ScreenSharing Server / VNCD on macOS
# It is possible you may need to write the launchd override .plist file. (do not do unless you need to).
sudo defaults write /var/db/launchd.db/com.apple.launchd/overrides.plist com.apple.screensharing -dict Disabled -bool false
# configure a shortcut for kickstart
ardkickstart="/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart"
# This kickstart appraoch is generally a better approach if you do not want to use the GUI to set up users (modify as needed)
sudo ardkickstart -activate -configure -users localadmin -access -on -privs -all
# enable remote management # seems to work if kickstart or GUI fails
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist
# restart ard
ardkickstart -restart -agent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment