
SMB (Server Message Block) is the protocol behind Windows file sharing and network drives. Creating a share takes a minute; getting the permissions right so the correct people can read, write or see nothing at all is where most setups go wrong. This guide shows how to create SMB shares on Windows Server or Windows 10/11 and on Linux with Samba, how share and NTFS permissions work together, and how to reach a share remotely without exposing it to the internet.
Quick answer
New-Item -Path D:\Shares\Finance -ItemType Directory
New-SmbShare -Name Finance -Path D:\Shares\Finance `
-ChangeAccess "CORP\Finance" -ReadAccess "CORP\Auditors" `
-FolderEnumerationMode AccessBased -EncryptData $true
How SMB permissions work
On Windows, two layers of permissions apply to every file opened over the network:
- Share permissions (Full Control, Change, Read) apply only when the folder is accessed over the network.
- NTFS permissions apply to everyone, locally and over the network, and are much more detailed.
The most restrictive of the two wins. Microsoft's recommended practice is to keep share permissions simple (for example, Authenticated Users or a single group with Change or Full Control) and do the real access control with NTFS permissions. That way there's only one place to look when someone can't open a file.
Step 1: Create the share on Windows
On Windows Server
- If the File Server role isn't installed, add it:
Install-WindowsFeature FS-FileServer(it's present by default on most installs). - Create the folder, for example
D:\Shares\Finance. Avoid sharing the system drive root. - In Server Manager → File and Storage Services → Shares, choose Tasks → New Share → SMB Share – Quick, pick the folder and give it a name.
- On the Other Settings page, tick Enable access-based enumeration (users only see folders they can open) and Encrypt data access.
On Windows 10 or 11
Right-click the folder → Properties → Sharing → Advanced Sharing, tick Share this folder, then click Permissions. Remove Everyone and add the specific users who need access. The network profile must be set to Private for file sharing to work.
Step 2: Set NTFS permissions
Open the folder's Properties → Security tab, or use icacls:
# remove inherited permissions, keep a copy as explicit entries
icacls D:\Shares\Finance /inheritance:d
# Finance group: modify; Auditors: read; remove general Users access
icacls D:\Shares\Finance /grant "CORP\Finance:(OI)(CI)M"
icacls D:\Shares\Finance /grant "CORP\Auditors:(OI)(CI)RX"
icacls D:\Shares\Finance /remove "BUILTIN\Users"
(OI)(CI) makes the entry apply to all subfolders and files. Always grant to groups, not individual users, so access changes are made in one place.
Step 3: Manage share access later
Get-SmbShareAccess -Name Finance
Grant-SmbShareAccess -Name Finance -AccountName "CORP\Managers" -AccessRight Read -Force
Revoke-SmbShareAccess -Name Finance -AccountName "Everyone" -Force
Get-SmbSession # who is connected right now
Get-SmbOpenFile # which files are open
Create an SMB share on Linux with Samba
On Ubuntu or Debian, install Samba and create a folder owned by a group:
sudo apt install samba
sudo groupadd finance
sudo mkdir -p /srv/shares/finance
sudo chown root:finance /srv/shares/finance
sudo chmod 2770 /srv/shares/finance
Add the share at the end of /etc/samba/smb.conf:
[finance]
path = /srv/shares/finance
valid users = @finance
read list = auditor1
write list = @finance
create mask = 0660
directory mask = 2770
browseable = yes
smb encrypt = required
Samba keeps its own passwords, so add each user to Samba, then check the config and restart:
sudo usermod -aG finance alice
sudo smbpasswd -a alice
testparm
sudo systemctl restart smbd
Step 4: Test the share
- From Windows: press Win + R and open
\\server-name\Finance, or map it withnet use Z: \\server-name\Finance /persistent:yes. - From Linux:
smbclient -L //server-ip -U alicelists shares;smbclient //server-ip/finance -U aliceopens one. - Test with a user who should not have access as well. A denied user should get "Access is denied", and with access-based enumeration the folder shouldn't even be visible.
Remote SMB access: do it safely
Never open TCP port 445 to the internet. Internet-exposed SMB is constantly scanned and attacked, and many ISPs block it anyway. Safer ways to reach a share from outside:
- VPN: connect to the network with WireGuard, OpenVPN or a site-to-site VPN, then use the share as if you were local.
- SMB over QUIC: available in all editions of Windows Server 2025. It tunnels SMB inside TLS 1.3 over UDP 443 and works with Windows 11 clients.
- Remote desktop: keep the files on a server and work on them through an RDP session, so the share never leaves the private network.
Best practices for SMB access control
- Disable SMBv1 everywhere:
Set-SmbServerConfiguration -EnableSMB1Protocol $false. - Use groups, least privilege and separate shares for separate teams.
- Enable encryption (
-EncryptData $trueorsmb encrypt = required) for sensitive data. - Turn on access-based enumeration so users don't see folders they can't open.
- Review access regularly and audit file access on sensitive shares.
- Back up shares, and keep a copy that ransomware on a client PC can't reach.
Frequently asked questions
What is the difference between share and NTFS permissions?
Share permissions only apply over the network; NTFS permissions apply everywhere. When both apply, the more restrictive one wins.
What are the best practices for share permissions?
Keep share permissions broad but limited to authenticated users or one group, and control real access with NTFS permissions granted to groups.
How do I access an SMB share remotely?
Use a VPN, SMB over QUIC on Windows Server 2025, or remote desktop. Don't expose port 445 to the internet.
How do I set up an SMB share on Windows 10?
Folder Properties → Sharing → Advanced Sharing, tick Share this folder, set Permissions for specific users, and make sure the network is set to Private.


