This post is about gaining samba access to our Domoticz installation. With Samba access, we can read, manipulate and backup our Domoticz files directly from Windows with our default file explorer.
This how-to is part of a bigger series of Domoticz how-to’s on sancla.com!
This tutorial has been verified with:
- Running Domoticz installation with stable Raspbian Buster release and SSH access. See my previous post for a how-to:
- Raspberry Pi 4 (MEM 2GB with 16GB sd-card)
- Raspbian Buster Lite 4.19, Februari 2020
- Domoticz Stable 2020.1 (compile date 22-3-2020)
Step 1: Install Samba
Connect with SSH to your Domoticz installation and follow these steps. Samba is installed and configured rather quickly so we should be done in no time…
Let’s start by installing Samba with the following commands:
sudo apt update && sudo apt install samba samba-common-bin cifs-utils -y
During installation you get the question if you wish to enable WINS. Although I know about only a handful occasions where this is still necessary (legacy situations), you do not need it in this case. WINS is a dinosaur from Microsoft that you should not need anymore…
Step 2: Create a dedicated samba account
The next step is to create a user account for authentication later on. For this example we are going to create the user “pi_samba” with password “sancla.com”.
sudo useradd pi_samba sudo smbpasswd -a pi_samba
Step 3: Configure samba
Add the following lines to the samba “smb.conf” file. You can do this with the nano editor by executing the following command:
sudo nano /etc/samba/smb.conf
Next is to add these lines to the smb configuration file. Scroll all the way down and add the configuration lines below. If you have selected a different username at step 2, make sure to change this “valid users = ” value in below example. This configuration example gives you access to the “/home/pi” folder and not the full Raspbian root.
You can save the file with key combination “CTRL+O” and close the editor with “CTRL-X”.
[pi] browseable = yes writeable = yes path = /home/pi/ revalidate = yes comment = Share to pi home folder valid users = pi_samba create mask=0777 directory mask=0777 available = yes
Should you wish to gain access to the root of your raspberry pi, you could add (or replace above example) with the following configuration:
[root] browseable = yes writeable = yes path = / revalidate = yes comment = Share to root valid users = pi_samba create mask=0777 directory mask=0777 available = yes
Your configuration file should resemble something like this (in this example I included the root configuration):
Step 5: Restart the service
Finally, before we connect to our Raspberry Pi Samba share, we need to restart the samba service so that it loads in our configuration changes.
sudo systemctl restart smbd
Step 4: Open shares with Windows Explorer
Now, in Windows you can use your regular Windows Explorer to access the network shares we just created. You can open Explorer like your are used to, but it is also possible with the key combination ” ⊞ Win + E”. Now surf in the address bar to your raspberry pi with the IP address like \\<ip-address> .
In my example the IP address of my Raspberry PI is 10.1.3.51, so I enter “\\10.1.3.51”.
When you try to open one of the shares we created, Windows asked your to authenticate. You can do so with the “pi_samba” user we created earlier on.
And we, we have access :-)!