Created
March 23, 2021 16:40
-
-
Save macsimom/a4e7c7fdab47f1be9ce3e6594e071c64 to your computer and use it in GitHub Desktop.
A short script to enable Apple Remote Desktop (aka. Remote Management) for a given user.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
function ENABLEARD(){ | |
dscl . -create "/Users/${1}" dsAttrTypeNative:naprivs -1073741569 | |
touch "/Library/Application Support/Apple/Remote Desktop/RemoteManagement.launchd" | |
if ! launchctl list|grep -q com.apple.screensharing ; then | |
launchctl load -w /System/Library/LaunchDaemons/com.apple.screensharing.plist | |
fi | |
echo "Enabled Apple Remote Desktop Management for ${1}" | |
} | |
if [ "$(whoami)" != "root" ]; then | |
echo "You must be root to run this command" | |
exit 1 | |
fi | |
if id -u "$1" &>/dev/null ; then | |
ENABLEARD "$1" | |
else | |
echo "${1} is not a valid username" | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment