This guide will help you set up a Samba server on your Raspberry Pi. Once this is setup and configured you can send files to your Raspberry Pi remotly
Setting up Samba on your Pi
First make sure your pi is up to date by running these two commands
sudo apt-get update
sudo apt-get upgrade
Next we install Samba
sudo apt-get install samba samba-common-bin
Now we need to create a folder that we will share. This can be anywhere including on a mounted external hardrive. More info on how to mount an external harddrive can be found here
mkdir /home/data/share
Now we can configure samba to share this folder by modifying this file
sudo vi /etc/samba/smb.conf
and adding these lines to the bottom of the file
[shared] path = /home/data/share writeable=Yes create mask=0777 directory mask=0777 public=no
“[shared]” – Defines the name of the share itself. We will use this later to connect to the share
“path” – Specifies the directory on your Pi that you want to share
“writeable” – When set to yes allows you to write to this folder
“create mask” and “directory mask” – this option defines the maximum permissions for the files and folders
“public” – if this is set to no the Pi will require a user to grant access to the shared directory
Once those changes are made and saved we need to set up a user for our Samba share on the Raspberry Pi. For this example we will be creating a user pi
with the password raspberry
Run this command to create a user named pi
sudo smbpasswd -a pi
You will be prompted to enter a password.
Finally, we need to restart Samba
sudo systemctl restart smbd
For the next sets you will need to know the local IP Address of your Pi. If you do not know it you can run this command.
hostname -I
Connecting to your samba drive from Windows
- Start by opening up the File Explorer
- Within the File Explorer click the Computer tab
- Then click Map network drive
- You will see a popup asking for a folder
- Set the Folder text box to be
\\raspberrypi\share
- If you changed the name of your share then make sure you replace “share” with the name that you chose
- Make sure that the “Connect using different credentials” is selected
- If for and reason the connection fails replace “raspberrypi” with the local IP address that you got from above
- Set the Folder text box to be
- Once you hit finish you will be asked for login details
- Enter the username and password we created above. For this example the username is
pi
and the password israspberry
- Once done hit OK
- Enter the username and password we created above. For this example the username is
You should now be able to see your remote drive and be able to add/remove data
Connecting to your samba drive from Mac
- Start by opening the Finder app
- Within Finder click the Go button in the toolbar
- Then click the Connect to Server option
- This will ask you for a server
- In the address box enter
smb://192.168.0.159/share
- You will need to swap ou the IP Address “192.168.0.159” with the address that you got above
- You will also need to swamp “share” if you renamed your share to something else
- In the address box enter
- Click Connect
- Before the connection is complete it will ask for a username and password
- Enter the username and password we setup above. For this example the username is
pi
and the password israspberry
- Make sure the Registered User option is selected
- Enter the username and password we setup above. For this example the username is
- Click Connect
You should now be able to see your remote drive and be able to add/remove data