Raspberry Pi : install Samba
Have full-featured it is but above all, What we want, It is a space of storage. This is what we put in place today with Samba.
We will share multiple directories. We will therefore need more users for the common share but also for so-called private parties.
So, I will create in addition to the root user (and timemachine for those using the Time Machine service of this article) , a user a private ' chris’ for me, a user for Madam and a guest for common sharing zone.
let's go !
- Install the Samba packages
apt-get install apt-transport-https samba samba-common-bin
- Save the configuration file. On ne sait jamais 😉
CP /etc/samba/smb.conf /etc/samba/smb.conf.old
- Create the user guest to access sharing zone “share”
adduser guest - home = / home/public - shell = / bin/false-disabled-password
- Change the rights on sharing/media/usbdrive/share zone
chown-r guest:guest /media/usbdrive/share
- Allow users to connect to Samba in // etc/Samba/SMB.conf
## Browsing/Identification ### # Change this to the workgroup/NT-domain name your Samba server will part of workgroup = WORKGROUP ####### Authentication ####### security = user
- Always in // etc/Samba/SMB.conf Add the public share at the end of the configuration file
[Sharing] how = sharing read only = no writable = yes locking = no path = / media/usbdrive/share guest ok = yes force user = guest
- Restart the Samba service
service smb restart service nmbd restart
At this stage, on computers on the network the Raspberry Pi is visible
It is sufficient to connect in being invited and the directory will be mounted automatically
Good now let's get to the sharing of private areas !
Always in preparing article, We created a partition for storing documents but unlike sharing zone, each user will have its directory, not visible to other registered users of the Raspberry Pi.
- Add a user
- The directory update ‘Home‘ to be installed on external drive
usermod -m -d /media/usbdrive/private/chris chris
A small ‘ls/media/usbdrive/private.‘ vous affichera le répertoire avec les bons droits 😉
- Enable the directory created in Samba-sharing by adding a section in /etc/samba/smb.conf
[Chris Home] path = %h how = %U Home writable = yes username = chris only user = yes create mode = 0600 Directory mask = 0700
- Add the user created in the basic Samba. It will ask you a password. You choose what you want. This is the password that will be asked when the connection from an external machine.
And so much for Samba.
If you connect to the Pi Raspberry with a guest user, you go to the shared area. You connect with a registered user, you access the private zone.
I await your comments and suggestions because I'm not expert Samba. Your comments ! 🙂