Loading...
 

Samba Server on ESPRESSObin

This tutorial will show how to setup a password-protected Samba share on your ESPRESSObin running Ubuntu 16.04. As an implementation of the Server Message Block (SMB)/Common Internet File System (CIFS) protocol for Unix systems, Samba provides support for cross-platform file and printer sharing with Microsoft Windows, OS X, and other Unix systems.

Installation


In the Ubuntu console insert:

user@localhost:~$ sudo apt-get update
user@localhost:~$ sudo apt-get install samba

 
Now that Samba is installed, create a directory which will be shared (here /home/user/ebinsamba):

user@localhost:~$ mkdir ebinsamba

 

Setup Samba user and password


Accessing samba shares from a remote computer requires a distinct set of Samba user accounts separate from the main accounts. A separate Samba password needs to be created for every user you want to access your file shares. Let's create a password for the user account:

user@localhost:~$ sudo smbpasswd -a user

 

Configuration


Main samba configuration is located in /etc/samba/smb.conf file which is divided into several sections. Make sure to create a backup of the default configuration file:

user@localhost:~$ cp /etc/samba/smb.conf /etc/samba/smb.conf.backup


Once done, open the file:

user@localhost:~$ sudo vim /etc/samba/smb.conf


and add our newly created directory at the bottom of the file (modify the path and username according to your setup):

[ebinsamba]
    comment = Samba on ESPRESSObin
    available = yes
    valid users = user
    path = /home/user/ebinsamba
    read only = no
    browsable = yes
    public = yes


where:

  • [ebinsamba] - The name of the file share.
  • comment - A short description of our share.
  • path is the full path to the directory. By standard, these shares are placed in /srv/samba/. Alternatively, you can add a Samba share anyhwere on the filesystem provided that you configure permissions accordingly.
  • browsable - Enabling Windows clients to browse through our Samba share using Windows Explorer.
  • valid users - Defining which users are allowed to access the file share.
  • available - The file share will be available to clients on the network.
  • read only - Defining whether clients will be allowed to write to the file share or not.


With the above setting we allow only for the user account to write and read to the file share. Save your configuration and exit the editor.

Now restart the Samba service for the configuration changes to take effect:

user@localhost:~$ sudo service smbd restart

 

Client


On UNIX machines we can connect to our newly made share using smbclient tool. First we can list the shares on our host machine (IP address 192.168.22.1) to see if the /ebinsamba share has been added. We do this with:

espressobin@buildserver:~$ smbclient -L \\\\192.168.22.1\\ebinsamba -U user


Make sure to set the username (here user) to the one created previously in this tutorial. You will be prompted to enter the defined password for that user.

This command should generate an output similar to this one:

Enter WORKGROUP\user's password: 

Sharename       Type      Comment
---------       ----      -------
print$          Disk      Printer Drivers
ebinsamba       Disk      Samba on ESPRESSObin
IPC$            IPC       IPC Service (Samba Server)
...


We can see that our ebinsamba share is being exported and can be accessed. We access it with:

espressobin@buildserver:~$ smbclient \\\\192.168.22.1\\ebinsamba -U user


after typing the password we should see smb: \> prompt from which we can manage shared files. For example, to see which files are in the share:

smb: \> ls
  .                                   D        0  Mon May 28 12:09:29 2018
  ..                                  D        0  Mon May 28 12:06:04 2018
  Yes - Roundabout.mp3                N 12446272  Thu Jan  4 12:47:35 2018

3744792 blocks of size 1024. 2383208 blocks available


Find out more on smbclient commands on the official smbclient man pages.

That is it, you have successfully setup a Samba server on your ESPRESSObin board.