Tag Archives: samba

Install Samba Server on Raspberry Pi to access over network

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

2-
The directory that we will share out will act as a mount point for external storage. So we will need to create the directory and set appropriate permissions to the directory. Using mkdir(/bin/mkdir) we can both create the directory and set the permissions in the one command. The -m option will allow you to set the mode or permissions of the directory.

sudo mkdir -m 1777 /data

From the above command we can see the easy part, creating the directory /data. As it is at the root of the file-system we will need administrative permissions to do this so we run it prefaced with the sudo command. The mode of the directory is set with the -m option:

1: sets the sticky bit. This set on a directory ensures that users can only delete files they own.
7: sets RWX read , write and execute for the user owner
7: sets RWX read , write and execute for the group owner
7: sets RWX read , write and execute for others
This directory will be empty at the moment and, of course, the root file-system is limited in size on the Pi to that available from the SD cards. We can use an external drive connected to the USB ports and have this mounted to the /data directory. This then can provide effective storage for your network

3-
Backup conf file and edit as following;
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.old
sudo rm /etc/samba/smb.conf
sudo nano /etc/samba/smb.conf

Add the following lines;
[global]
workgroup = HOME
netbios name = KINETIC
server string = Kinetic Server %v
map to guest = Bad User
log file = /var/log/samba/log.%m
max log size = 50
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
preferred master = No
local master = No
dns proxy = No
security = User

wins support = yes

[Data]
comment= Pi Home
path=/home/pi
browseable=Yes
writeable=Yes
only guest=no
create mask=0777
directory mask=0777
public=yes

4-
Restart Samba Server
sudo service smbd restart
sudo service nmbd restart

5-
Create users
The last part of this tutorial will involve us creating samba users. These users must represent Linux users but their password can and should be different to the Linux password for security. This is not enforced though. Using the command smbpasswd(/usr/bin/smbpasswd) as the root user we can add new samba users. A user must have a password in samba to access shares.

sudo smbpasswd -a root
sudo smbpasswd -a pi

6-
Restart Samba Server
sudo service smbd restart
sudo service nmbd restart