10 September 2016

Communicating between 2 Raspberry Pi"s using sshpass

Communicating between 2 Raspberry Pi

In my home automation project, I sometimes need to run (background) commands from my web server towards another Raspberry Pi. Communicating between 2 Raspberry Pi"s using sshpass was the best way to go.

Author: Renier Delport. Reposted from Behind The Scenes - Communicating between 2 Raspberry Pi"s using sshpass

07 September 2016

Understanding common network protocols

Understanding common network protocols

Understanding common network protocols is intended to be a basic, easy to understand guideline for the most used network protocols and mainly covers networked computers linked to the same network - such as a home network.

Author: Renier Delport. Reposted from Behind The Scenes - Understanding common network protocols

18 July 2016

Don"t Wait for Pokémon - Go!

Don

If you are reading this, you probably already know about Pokémon Go, so I"m not going to say anything more about this awesome game. I was very reluctant at first, but after the upgraded "bootleg" version was released I was Poké-balled right into it. My thought being that this was going to be the next best thing for this decade - and it will. #pokemonkznsc

Author: Renier Delport. Reposted from Behind The Scenes - Don"t Wait for Pokémon - Go!

01 June 2016

Using WinSCP to Connect to a Raspberry Pi

Using WinSCP to Connect to a Raspberry Pi

WinSCP is a free and open-source file transfer emulator, almost like Windows Explorer. We will be using WinSCP to connect to a Raspberry Pi, which will enable us to easily copy files and directories from other sources and easily set their permissions.

Author: Renier Delport. Reposted from Behind The Scenes - Using WinSCP to Connect to a Raspberry Pi

18 May 2016

How to Share a Raspberry Pi Folder on a Network

How to Share a Raspberry Pi Folder on a Network

This is a tutorial on how to share a Raspberry Pi folder on a network to be accessed by other users. Apart from being available to Microsoft Windows operating systems, the shared directory will can also be mounted to other Raspberry Pi"s.

For this we will be using Samba to create a (non-secure) connection where everyone on the network will have reading and writing privileges to this directory. Non-secure just refers to the fact that, with this tutorial, within your local network you won"t have control of which users can and cannot connect to it.

Requirements


Fully functional Raspberry Pi with Raspbian installed. You will obviously also need the Pi to be connected to a local network. If your Pi is not connected to a screen with a keybord and mouse, this process can also be done with PuTTY.

How to Share a Raspberry Pi Folder on a Network


First of all, we need to broadcast the share directory onto the network. We will need to install and configure Samba, configure guest privileges and configure the shared folder.

To install Samba run the following terminal command from the root directory of the Pi where the folder you want to share is on:

sudo apt-get install samba samba-common-bin

To configure Samba, we need to edit the /etc/samba/smb.conf file. This file determines what folders are to be shared and who gets access to them. Use

sudo nano /etc/samba/smb.conf

to open the file and in the [global] section, under Authentication ensure you have the following settings:
[global]
security = user
guest account = nobody
map to guest = bad password

Don"t exit yet.

Linux has a special guest user named "nobody" - which has very little privileges, even less than a regular user.

To be able to share a folder without the user having to supply a password the folder needs to be mapped to the "nobody" user and the password for this user needs to be removed.

To remove the password from the ‘nobody’ user use the following:

smbpasswd -an nobody

To configure your shared folder add the following at the bottom of the file:
[shared-folder]
comment=Shared Folder
browseable=yes
path=/media/share
public=yes
writable=yes
guest ok=yes

Now you can save on exit (Ctrl + X then Y).

At this point I recommend rebooting your Pi (sudo reboot).

Testing Samba


First of all, see what Samba is doing by using:

service samba status to test status

If Samba is not running, you can activate it by using:

sudo service samba start

After doing everything as described, Samba should start automatically on after a reboot.

Connecting to the Share


Microsoft Windows


From Windows you can type \\hostname (your own host name) in your browser to access the shared directory. To see the network name of the Pi with the shared directory use hostname in the terminal.

Raspberry Pi


From another Raspberry Pi (or Linux) it"s a bit more complicated. You will need the IP address of the Pi with the shared directory (use hostname -I in the terminal) where you will either see one, or two IPs depending on your setup.

If you have one IP it is probably a dynamically IP obtained during the boot process. This IP might change from time to time! If you have two, one of them is dynamic and one is static. Either way, I recommend using a static IP on the Pi sharing the directory, so if you haven"t done this yet, see Set Up A Static IP Address On The Raspberry Pi or Set Up A Static IP Address On The Raspberry Pi Using Wi-Fi to do so.

When you have the IP address of the Pi with the share directory, we can use the CIFS to mount Samba shares to another Raspberry Pi. The newest Raspbian have it installed, but to make sure run in the terminal:

sudo apt-get install cifs-utils

Now you can use:

sudo mount -t cifs //192.168.1.xx/shared-folder /mnt/share-folder -o password=

Where the 192.168.1.xx is the IP of the sharing Pi, shared-folder is the name configured earlier and /mnt/share-folder is the mounting folder. The password can be anything or nothing.

To unmount the share from user side use umount /mnt/share-folder.

Other Useful Samba Commands


Temporarily stop Samba: sudo service samba stop

Even if you stopped Samba as above it will start again on reboot.

Remove Samba from the boot sequence: sudo update-rc.d -f samba remove

This will not stop Samba, but will prevent it from running on reboot. To add Samba back to the boot sequence use:

sudo update-rc.d samba defaults

Please Rate, Share, Comment & Disqus


Was this Post Helpful?


[ratings]

Author: Renier Delport. Reposted from Behind The Scenes - How to Share a Raspberry Pi Folder on a Network