Disable guest file sharing over SMB
- macOS onlyThis script improves your privacy on macOS
- Single actionThis page belongs to a script, containing basic changes to achieve a task.
- Impact: Medium
System Functionality / Data Loss Risk: Moderate
This action improves privacy with minimal impact when you run the recommended script.
This action improves privacy with some impact when you run the recommended script. - Bash (Shell script)These changes use macOS system commands to update your settings.
- Administrative (sudo) access requiredThis script requires privilege access to do the system changes
- Fully reversible
You can fully restore this action (revert back to the original behavior) using this website.
The restore/revert methods provided here can help you fix issues.
Overview
This script prevents anonymous (guest) users from accessing files shared over the SMB protocol.
By default, macOS allows guest users to access shared folders without authentication 1 2.
macOS allows users to share entire systems or specific folders with others on a network 3. This script impacts only SMB sharing 4, meaning that it has no impact on other file sharing alternatives. SMB (Server Message Block) is a network system that allows computers to share files 4 5 6. It is commonly used to share files between Mac and Windows computers 7.
The Guest User feature in macOS lets people temporarily access a Mac without creating standard user accounts 8. Additionally, Guest User accounts on macOS:
- Do not require a password to log in 8
- Are restricted from changing system settings 8
- Cannot access the Mac remotely 8
- Automatically delete all files when logging out 8
- Can only use Safari when FileVault encryption is enabled 8
- Enable Mac location through Find My app if lost 8
Disabling SMB guest sharing blocks unauthorized access to shared folders. This improves your security and privacy by preventing unauthorized users from:
- Accessing your shared files and folders 4 9
- Performing network reconnaissance 4
- Potentially exploiting system vulnerabilities for privilege escalation 4
This security measure is recommended by major security organizations:
- NIST (National Institute of Standards and Technology) - The official US government cybersecurity standards agency 9
- Center for Internet Security (CIS) - A leading nonprofit organization that creates security guidelines used worldwide 4
This script may also provide a performance benefit by reducing overhead for guest connections.
After using this script, you must manually add user accounts for anyone who needs to access your shared files 3.
Technical Details
The script:
- Configures the system preference for guest access
(
/Library/Preferences/SystemConfiguration/com.apple.smb.server!AllowGuestAccess
) 4 9 - Disables SMB guest access using the
sysadminctl
with-smbGuestAccess off
option 10sysadminctl
is a tool used to administer system user accounts 10.
This script is only recommended if you understand its implications.
Some non-critical or features may no longer function correctly after running this script.
This script can be fully reversed to restore changes if something goes wrong.
Sources
- 6.1.3 Disable guest account login. Tenable®. www.tenable.com. (2025).
Original: https://www.tenable.com/audits/items/CIS_Apple_macOS_11_v1.1.0_L1.audit:153219403c9d852b574cc5ef59902392
Archived: https://web.archive.org/web/20250123200241/https://www.tenable.com/audits/items/CIS_Apple_macOS_11_v1.1.0_L1.audit:153219403c9d852b574cc5ef59902392 - SecPod SCAP Repo, a repository of SCAP Content (CVE, CCE, CPE, CWE, OVAL and XCCDF). www.scaprepo.com. (2025).
Original: https://www.scaprepo.com/view.jsp
Archived: https://archive.ph/2025.01.12-201010/https://www.scaprepo.com/view.jsp?id=CCE-50057-9 - Set up file sharing on Mac. support.apple.com. (2024).
Original: https://support.apple.com/en-gb/guide/mac-help/mh17131/mac
Archived: https://web.archive.org/web/20240728041621/https://support.apple.com/en-gb/guide/mac-help/mh17131/mac - SecPod SCAP Repo, a repository of SCAP Content (CVE, CCE, CPE, CWE, OVAL and XCCDF). scaprepo.com. (2025).
Original: https://www.scaprepo.com/control.jsp
Archived: https://web.archive.org/web/20250113201942/https://www.scaprepo.com/control.jsp?command=relation&relationId=CCE-50149-4 - Microsoft SMB Protocol and CIFS Protocol Overview. learn.microsoft.com. (2024).
Original: https://learn.microsoft.com/en-gb/windows/win32/fileio/microsoft-smb-protocol-and-cifs-protocol-overview
Archived: https://web.archive.org/web/20241125012504/https://learn.microsoft.com/en-gb/windows/win32/fileio/microsoft-smb-protocol-and-cifs-protocol-overview - Overview of file sharing using the SMB 3 protocol in Windows Server. learn.microsoft.com. (2024).
Original: https://learn.microsoft.com/en-us/windows-server/storage/file-server/file-server-smb-overview
Archived: https://web.archive.org/web/20241226114905/https://learn.microsoft.com/en-us/windows-server/storage/file-server/file-server-smb-overview - File Services. High-performance workgroup and Internet file sharingfor Mac, Windows, and Linux clients.. www.apple.com. (2025).
Original: https://www.apple.com/server/docs/File_Services_TB_v10.4.pdf
Archived: https://web.archive.org/web/20250113191313/https://www.apple.com/server/docs/File_Services_TB_v10.4.pdf - Guest user - Apple Support. support.apple.com. (2025).
Original: https://support.apple.com/guide/mac-help/aside/glos8c20ac45/15.0/mac/15.0
Archived: https://archive.ph/2025.01.12-195712/https://support.apple.com/guide/mac-help/aside/glos8c20ac45/15.0/mac/15.0 - NIST Special Publication 800-179 (December 2016). nvlpubs.nist.gov. (2024).
Original: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-179.pdf
Archived: https://web.archive.org/web/20240928201604/https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-179.pdf - bg Man Page - macOS - SS64.com. ss64.com. (2024).
Original: https://ss64.com/mac/sysadminctl.html
Archived: https://web.archive.org/web/20241125024856/https://ss64.com/mac/sysadminctl.html
Apply Now
Choose one of three ways to apply:
Help
How to apply or restore "Disable guest file sharing over SMB" using script
- ≈ 3 min to complete
- Tools: Web Browser
- Difficulty: Medium
- ≈ 5 instructions
- 1
Download
Download the script file by clicking on thebutton above.
Use button above to restore changes. - 2
Keep the file
If warned by your browser, keep the file. - 3
Open
Open the downloaded file. - 4
Exit
Once it's done, press any key to exit the window. - 5
Restart
Restart your computer for all changes to take effect.
Apply with privacy.sexy
Guided, automated application with safety checks- Recommended for most users
- Includes safety checks
- Free
- Open-source
- Popular
- Offline/Online usage
Help
How to apply or restore "Disable guest file sharing over SMB" using privacy.sexy
- ≈ 3 min to complete
- Tools: privacy.sexy
- Difficulty: Simple
- ≈ 4 instructions
- 2
Choose script
- Search for the script name: Disable guest file sharing over SMB
- Check the script by clicking on the checkbox.
- 3
Run
Click on ▶️ Run button at the bottom of the page.This button only appears on desktop version (recommended). On browser, use 💾 Save button.
- Apply
- Revert
sudo defaults write '/Library/Preferences/SystemConfiguration/com.apple.smb.server' 'AllowGuestAccess' -bool NO
if ! command -v 'sysadminctl' &> /dev/null; then
echo 'Skipping because "sysadminctl" is not found.'
else
sudo sysadminctl -smbGuestAccess off
fi
InN1ZG8gZGVmYXVsdHMgZGVsZXRlICcvTGlicmFyeS9QcmVmZXJlbmNlcy9TeXN0ZW1Db25maWd1cmF0aW9uL2NvbS5hcHBsZS5zbWIuc2VydmVyJyAnQWxsb3dHdWVzdEFjY2VzcydcbmlmICEgY29tbWFuZCAtdiAnc3lzYWRtaW5jdGwnICY+IC9kZXYvbnVsbDsgdGhlblxuICAgICAgICA+JjIgZWNobyAnQ2Fubm90IHJldmVydCBiZWNhdXNlIFwic3lzYWRtaW5jdGxcIiBpcyBub3QgZm91bmQuJ1xuICAgIGVsc2VcbiAgICAgICAgc3VkbyBzeXNhZG1pbmN0bCAtc21iR3Vlc3RBY2Nlc3Mgb25cbiAgICBmaSI=
Help
How to apply or restore "Disable guest file sharing over SMB" using commands
- ≈ 2 min to complete
- Tools: Terminal app
- Difficulty: undefined
- ≈ 3 instructions
- 1
Open terminal
Open Terminal app. - 2
Copy code
Copy the code: - 3
Paste & run
Paste the code into Terminal and press Enter to run.Some changes require a system restart to take effect
Similar Guides
Wider Goal
Guides below includes this guide to achieve a wider goal.See other more general settings that includes this one as one of its actions.
These plans combine multiple privacy settings, including this one, for stronger protection.
- Disable guest accounts
- Security improvements
These scripts control guest access on macOS to protect your system's security and privacy. Guest access lets anyone use your Mac without a password or account. Thi...
This document —security improvements— provides guidance on how to establish robust privacy protection on macOS. What's more, you'll learn how to reset the changed ...
Same Goal
Other guides in Disable guest accountsSee settings that are in the same category as this guide.
Using other actions in the same category may help you achieve your goal better.
About the Creators
These people have authored this documentation and written its scripts:
Reviewed By
This guide has undergone comprehensive auditing and peer review:Expert review by undergroundwires
- Verified technical accuracy and editorial standards
- Assessed system impact and user privacy risks
Public review by large community
- Privacy enthusiasts and professionals peer-reviewed
- Millions of end-users tested across different environments
History
We continually monitor our guides, their impact and all other privacy options. We update our guides when new information becomes available. On every update, we publicly store who made the change, what has been changed, why the change was made and when the change was made.