2. Set the samba server
Initial steps
I do this every time I work with Linux or raspberry pi, and I advise you to do it too.
sudo apt-get update
sudo apt-get upgrade
Next, let’s get samba.
sudo apt-get install samba samba-common-bin
Prepare the shared directory/folder
Now we need to define the folder/directory we are going to use, this will be the folder that PC A and B will have access to.
The folder can be located anywhere, even in an external folder. the SDcard I was using died a few days after and because I set the folder in a thumb drive I didn’t last the information, I just need it to bake another SDCard install samba and I was up and running.
mkdir /home/pi/shared
Access configuration
The next step is to modify the file smb.conf to let samba knows where the folder to share is and how to handle the access.
sudo nano /etc/samba/smb.conf
at the end of the file add:
[pimyshare]
path = /home/pi/sharedwriteable=Yescreate mask=0777directory mask=0777public=no
atau ini5. Within this file, add the following to the bottom. This text defines various details of our share.
For this example to work, ensure that you replace “
<USERNAME>
” with the name of your user.
[pimyshare]
the text in brackets defines the point where we will access the folder itself, for example//raspberrypi/pimyshare
. this will be important later when we configure PC a and B to access the folder.path
is the path to the directory we are going to share.writeable
set as yes allow the user to write in the folder (we need this to add new files to the folder).create mask
anddirectory mask
define the permission for both folder and files, it is set as 07770777 users are allowed to read, write and execute (some cases will be better to avoid the execution for security reasons).public
set tono
it will require a valid user to grant access to the folder.
Save the document in this case Ctrl + X
and Y
.
Set a user for the samba share
To control the access to this folder, I add a user and a password.
With this command we can set the password, the user will be pi
sudo smbpasswd -a pi
Restart the server.
sudo systemctl restart smbd
If we need to get the hostname, we can obtain it with hostname -I
https://pimylifeup.com/raspberry-pi-samba/
https://fernandezvictor.medium.com/raspberry-pi-as-samba-server-to-create-shared-folder-between-computers-cdea979092b8