In this Raspberry Pi Samba tutorial, we will be showing you how you can share directories from your Raspberry Pi using the SMB/CIFS protocols.
Connect to the Raspberry Pi via ssh
### my ssh user pi ###default hostname raspberrypi.local ssh email@example.com ### you don't know ip?? find it with nmap ###if your IP address is 192.168.1.XXX. sudo nmap -sP 192.168.1.0/24` ### you don't know hostname? ###from raspberry shell hostname -I
Update the package list and all our packages
sudo apt-get update sudo apt-get upgrade
install the packages
sudo apt-get install samba samba-common-bin
create a folder that we will share.
### (my local raspberry path: /home/pi/sambashared) mkdir /home/pi/sambashared
Edit the samba config file. Add the following to the bottom
sudo nano /etc/samba/smb.conf ..... [pisamba] path = /home/pi/sambashared writeable=Yes create mask=0777 directory mask=0777 public=no.
“[pisamba]” – This defines the share itself, the text between the brackets is the point at which you will access the share. smb://raspberrypi.local/pisamba
“path” – the directory on your Raspberry Pi that you want to be shared.
“writeable” – it will allow the folder to be writable (Yes).
“create mask” and “directory mask” – Setting this to 0777 allows users to read, write, and execute for both files and folders.
“public” – If this is set to “no” the Pi will require a valid user to grant access to the shared folders. We can begin modifying the config file by running the command below.
Set up a user for our Samba server .In this example, we will be creating a Samba user called “pi”
sudo smbpasswd -a pi ### restart service sudo systemctl restart smbd
Start/stop/status samba server
sudo systemctl start smbd sudo systemctl stop smbd sudo systemctl status smbd
Connect from my mac
Connect from my Ipad