Network shares

At the bottom of the smb.conf file, we will add two shares as shown in the following
command line snippet. One account is for guests without authentication, while the
other account will only be accessible by our new user, James Bond.

[public] comment = Media share
path = /nas/USB001/public
force user = "root"
read only = no
guest ok = yes
public = yes

[work]
comment = Work share
path = /nas/USB001/work
valid users = "bond007" #or @users to allow the group users access
force group = users
read only = no
writeable = yes

Samba can be quite difficult to understand in terms of permissions. Let's start off
with the public share. You will notice that we put a line in smb.conf that says force
user = "root". We do this because we created the public directory as root user,
so the permissions applied to the directory and all the files to be created later can
only be for the user root! So, we tell Samba to imitate guests, as root, so that they
can read/write as the root user.

It is bad practice to force the root user to use the Pi account that comes with
Raspbian instead.

The same will apply for the user James Bond and his directory. If you created the
work directory as the root user or Pi, even James Bond will not be allowed to write
new files. To overcome this problem, you can simply change the owner of the folder
by typing the following command line:

chown bond007:users /mnt/USB001/work

You can also assign a directory to an entire group by replacing bond007 with users.
The command would look like chown users:users …. This means that anybody in
the group can write and delete files on that folder now.

The configuration file has many advanced features and I recommend reading the
online manual to learn more about security, sharing printers, and even how to get
Samba to act like a Windows domain server!

You can now use any Windows computer to browse the network and access the
newly created shares. 

No comments:

Post a Comment