BRIGADOON

Backyard Meteorological Instrumentation

Raspberry Pi 4 Set Up

Accessing Remote File Shares

Since Samba has been installed and sharing its files across the network, it is time to gain access to files that are being shared across the network by other nodes. To do this, the nodes and their shareable directories must be determined, along with the usernames and passwords require to gain that access. In this example, the same username (mine) and password is used to access each node. Post development, the sensor system will have reduced access along with a different username and password.

Setting up Samba to access remote directories has two basic parts: (1) Set up a directory structure that will be used to identify the remote directories; and (2) Link the local directories to the remote directories.

Creating Local Directory Structure

Theoretically speaking, the local directories that will be used as the link to the remote directories can be just about anywhere, however, the /mnt directory is often used to contain those local directories. This is the case in this project. Again, post development, the shared directories will be rationalised to limit the possibility of unwanted file contamination.

NOTE: The following directory structures are examples only and will depend on what nodes (and their directories) are contained in the sub-net.
/mnt                                                 Top Level Mount Directory
├──
ares                                             Raspberry Pi 4 Node running Web Server
│   └── www                                           Web Directory
├──
eros                                             Raspberry Pi 2 Node running Backup Services
│   ├── data                                             Data Backup Directory
│   └── multimedia                                   Multimedia Backup Directory
├──
typhon                                        Raspberry Pi 2 running Web Server Sandbox
│   └── www                                             Web Directory
└──
zeus                                            X86-64 Main Linux Server
    └── raid                                               RAID disks holding things like documents, photos, etc.

The following command can be used to create these directories:

$
sudo mkdir /mnt/ares /mnt/eros /mnt/typhon /mnt/zeus /mnt/ares/www /mnt/eros/data /mnt/eros/multimedia /mnt/typhon/www /mnt/zeus/raid

Setting Up Remote Links

Now that the local directory structure is in place, it is time to set up the links to the remote directories that will be created when Samba is started, or restarted. This is accomplished by altering the /etc/fstab file. There are many options for defining these links including these links but in this environment, only a basic configuration is applied.

The first thing to do is create a file that holds the username and password for each remote node. This file can be located anywhere, but as the mount process is conducted using root privileges, I place the password files in the root directory. I also make the file a hidden file so that it does not clutter up the listing of the root directory. For this example, I will use the following naming convention - the username password file is set using the following template:

.pun_<node_name>      Where the leading "." makes it a hidden file,
                                                                  "
pun" being an abbreviation for Password/Username,
                                                                  "
<node_name>" is replaced by the actual node name.

Since the password/username file is used for a global mount, only a single username and password is used for everyone. If personal mounts are permitted then each user could use a personal username and password. To create the password file for the Ares node, enter the command:

$
sudo nano /root/.pun_ares

Enter the username and password in the following format:

username=<username>
password =<secret_password>

Where
<username> is replaced by the appropriate username and <secret_password> is replaced by the password. Don't forget, the values for the username and password are defined by the remote system to which the Raspberry Pi is connecting.

Now that the password file is in place, it is time to update the
/etc/fstab file for the Ares node. First we need to determine the IP address for the Ares node. This can be determined by using the following command:

$
ping ares

You should get a result similar to below:

PING ares (10.128.0.105) 56(84) byites of data.
64 bytes from ares (10.128.0.105): icmp_seq=1 ttl=64 time=0.155 ms


So we will use 10.128.0.105 to identify the ares node.
NOTE: This assumes that the IP address of the node is statically assigned and will not change.


$
sudo nano /etc/fstab

Enter the following lines at the bottom of the file.

# Mount www Directory from Ares
//10.128.0.105/www                             /mnt/ares/www      cifs        credentials=/root/.pun_Ares,rw,no_fail 0 0

To activate access to the this remote directory, enter the following command:

$
sudo systemctl restart smbd.service

Once you have confirmed that you now have access to the remote directory, repeat the process for each of the shares.

Licenced under Creative Commons Attribution Share Alike 4.0 International or better by Mark Little (2022 - 2023)