Skip to content

Instantly share code, notes, and snippets.

@epcim
Last active December 21, 2021 08:12
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 epcim/d85a7415e2bc8cf69149ba24b350cd5b to your computer and use it in GitHub Desktop.
Save epcim/d85a7415e2bc8cf69149ba24b350cd5b to your computer and use it in GitHub Desktop.
#!/bin/bash
# /System/Library/CoreServices/Screen Sharing.app
# https://ss64.com/osx/kickstart.html
# https://apple.stackexchange.com/questions/30238/how-to-enable-os-x-screen-sharing-vnc-through-ssh
SWITCH=${1:-on}
[[ "$SWITCH" == "on" ]] && {
echo "Enter VNC PASS"
read -s VNCPASS
export PARAM="-clientopts -setvnclegacy -vnclegacy yes -clientopts -setvncpw -vncpw "$VNCPASS" \
-restart -agent -privs -all -users $USER"
} || {
SWITCH="off"
export PARAM=""
}
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
-deactivate -configure -access -${SWITCH} ${PARAM}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment