Last active
July 22, 2016 08:20
-
-
Save gjpalau/7c58ad574f2894f0333e to your computer and use it in GitHub Desktop.
Turn on remote login ## Create the com.apple.access_ssh group ## Add the admin group to com.apple.access_ssh ## unload and load the SSH Service
This file contains 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/bash | |
# TurnOnSSHAddAdminGroup.sh | |
# | |
# Turn on remote login ## Create the com.apple.access_ssh group ## Add the admin group to com.apple.access_ssh ## unload and load the SSH Service | |
sudo systemsetup -setremotelogin on && dseditgroup -o create -q com.apple.access_ssh && dseditgroup -o edit -a admin -t group com.apple.access_ssh && sudo launchctl unload -w /System/Library/LaunchDaemons/ssh.plist && sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist | |
sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -allowAccessFor -specifiedUsers && sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -configure -users techserv -activate -access -on -privs -all -clientopts -setvnclegacy -vnclegacy yes -clientopts -setvncpw -vncpw p@55w0rd -quiet | |
/usr/libexec/PlistBuddy -c ‘Set :com.apple.screensharing:Disabled NO’ /private/var/db/launchd.db/com.apple.launchd/overrides.plist | |
launchctl load /System/Library/LaunchDaemons/com.apple.screensharing.plist | |
for userid in $(ps -Ajc | grep loginwindow | grep -v grep | awk ‘{print $1}’); do | |
if [ "$userid" = "root" ] ; then | |
launchctl load /System/Library/LaunchAgents/com.apple.screensharing.agent.plist | |
else | |
su “$userid” -c ‘launchctl load /System/Library/LaunchAgents/com.apple.screensharing.agent.plist’ | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
beware the curly quotes!
for better results, I suggest a change on line 16 from
su “$userid” -c ‘launchctl load /System/Library/LaunchAgents/com.apple.screensharing.agent.plist’
to
to
su "$userid" -c 'launchctl load /System/Library/LaunchAgents/com.apple.screensharing.agent.plist'