Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ascdso2020/c110ae556c0249649de3754ce08c1670 to your computer and use it in GitHub Desktop.
Save ascdso2020/c110ae556c0249649de3754ce08c1670 to your computer and use it in GitHub Desktop.
Disable macOS Guest user account script
#!/usr/bin/osascript
-- License: https://justinpawela.github.io/default-gist-license/
(*
1) Disables signing in as Guest from the login screen.
2) Disables Guest access to file shares over AFP.
3) Disables Guest access to file shares over SMB.
Commands are chained together so that the user only needs to authorize once.
*)
set shellCommands to ¬
"sudo /usr/bin/defaults write /Library/Preferences/com.apple.loginwindow GuestEnabled -bool NO; " & ¬
"sudo /usr/bin/defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -bool NO; " & ¬
"sudo /usr/bin/defaults write /Library/Preferences/com.apple.AppleFileServer guestAccess -bool NO"
try
-- Run the shell commands, after requesting user authorization.
do shell script shellCommands ¬
with prompt "Attempting to disable the Guest user account." ¬
with administrator privileges
on error number -128
-- User cancelled. No further action required.
end try
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment