I’ve got a file server at home where I store both shared files (which should be available to everyone on my network), as well as private files (which must be readable only by my user). These are my notes on how I set it up.
The private directory
We’ll start with the private directory because it’s a lot easier.
- only I can read and write files and directories, and
- same user is used for creating files on the server and over SMB.
First, let’s create the directory:
sudo mkdir /data/private sudo chown andrei:andrei /data/private sudo chmod 750 /data/private
Now we’ll need to add the
andrei user to Samba’s
sudo smbpasswd -a andrei
And now the Samba config (note that some of these options may be set to their defaults, but I prefer to be explicit):
[private] comment = My private files path = /data/private browsable = no ; don't list it in available shares public = no ; will require a password writeable = yes ; the inverse of 'read only' create mask = 0640 directory mask = 0750