Macos – How to disable Guest Access from Terminal in Mac OS X

bashcocoamacosterminal

I'm trying to disable Guest Account from terminal.

I need the same effect like disabling System Preferences → Accounts → Guest Account → Allow guests to connect to shared folders.

I think Guest Access is disabled by default on Lion, So I need it for 10.5, and 10.6.

Best Answer

On OS X Lion, the preference is internally realized as two separate options:

In /Library/Preferences/com.apple.AppleFileServer, it's the guestAccess flag, and in /Library/Preferences/SystemConfiguration/com.apple.smb.server.plist, it's the AllowGuestAccess flag.

To change these, execute the following with root permissions:

defaults write /Library/Preferences/com.apple.AppleFileServer guestAccess -bool NO
defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server AllowGuestAccess -bool NO

Not sure if these are the same in previous versions of OS X. Use defaults read <path> to find out if these options exist on your system.

You might need to relaunch the sharing service for the changes to take effect.

Related Question