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.

Installation 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 !

  1. Install the Samba packages
    apt-get install apt-transport-https samba samba-common-bin
  2. Save the configuration file. On ne sait jamais 😉
    CP /etc/samba/smb.conf /etc/samba/smb.conf.old
  3. Create the user guest to access sharing zone “share”
    adduser guest - home = / home/public - shell = / bin/false-disabled-password
  4. Change the rights on sharing/media/usbdrive/share zone
    chown-r guest:guest /media/usbdrive/share
  5. 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
  6. 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
  7. Restart the Samba service
    service smb restart
    service nmbd restart

At this stage, on computers on the network the Raspberry Pi is visible

Raspberry Pi visible by samba on Mac Os

Raspberry Pi visible by samba on Mac Os

It is sufficient to connect in being invited and the directory will be mounted automatically

Se connecter en tant qu'invité

To connect as a guest

Choose sharing zone

Choose sharing zone

Display of sharing Samba on Mac OS

Display of sharing Samba on Mac OS

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.

  1. Add a user
    adduser chris
  2. 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 😉

  3. 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
  4. 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.
    smbpasswd-a chris

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 ! 🙂

Like this article ? Bear with me on patreon!

You may also like...