Samba

Samba is an open source network protocol that lets you serve files to Microsoft Windows clients, and to any other operating system that supports this protocol (which is most of them).

Installing Samba Server:

sudo apt-get update
sudo apt-get install samba samba-common-bin

Create a folder for your network shares, create a public and private folder, and put some test files in them so we'll know if everything is working correctly:

cd ~/
mkdir shares
mkdir shares/public
touch shares/public/Public.txt
mkdir shares/private
touch shares/private/Private.txt

Open /etc/samba/smb.conf in your favorite text editor, as superuser:

sudo vi /etc/samba/smb.conf

Define which folders you want to share and what kind of access they will have:

[public]
    comment = Public Files
    path = /home/pi/shares/public
    browseable = yes
    writeable = yes
    guest ok = yes
    read only = no

[private]
    comment = Private Files
    path = /home/pi/shares/private
    browseable = yes
    writeable = yes
    guest ok = no
    read only = no

Restart the Samba service:

sudo service samba restart

Create a Samba user/password for accessing the private share:

sudo smbpasswd -a pi

You should be prompted to enter a new password, this is the password you will use to log into the private share from another computer on your network:

pi@raspberrypi ~ $ sudo smbpasswd -a pi
New SMB password:
Retype new SMB password:
Added user pi.

In order to be able to make changes to the public share, you need to grant write access to the /home/pi/shares/public folder:

chmod -R 777 /home/pi/shares/public

Now you should be able to connect to your server from any client computer on the same network as your NASpberry Pi and access files in the public share. The private share will require your username and password to access.


Here is a more in-depth guide to setting up a Samba server on a Raspberry Pi and configuring clients to connect to it.


comments powered by Disqus