Setting up Samba Server for Managed Storage

To install Samba, we run:

sudo apt update -y
sudo apt install samba -y


both the Samba server smbd and the Samba NetBIOS server nmbd.

nmbd is not required for this tutorial, so in the interests of security you can stop and disable it with systemctl

sudo systemctl stop nmbd.service
sudo systemctl disable nmbd.service

The sudo systemctl disable nmbd.service command will produce the following output when run:

Output

nmbd.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install disable nmbd
insserv: warning: current start runlevel(s) (empty) of script `nmbd' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `nmbd' overrides LSB defaults (0 1 6).

This output communicates that because nmbd does not have native systemd management configuration, it is being disabled by the older SysV init system.

To avoid security issues that can arise from running an unconfigured, network-enabled service, let's stop the Samba server until configuration details are in place:

sudo systemctl stop smbd.service


Now that Samba is installed, we need to create a directory for it to share.

The command below creates a new folder /data/filecloud and will set proper samba permissions by  an authenticated user  which should be having full permissions to the share


mkdir -p /data/filecloud
chown :sambashare /data/filecloud
adduser --home /data/filecloud --no-create-home --shell /usr/sbin/nologin --ingroup sambashare filecloud
sudo chown filecloud:sambashare /data/filecloud 
sudo chmod 2770 /data/filecloud


Samba keeps its own database of users and passwords, which it uses to authenticate logins. In order to log in, all users must be added to the Samba server and enabled.

Execute the following smbpasswd commands to accomplish both of these tasks:

sudo smbpasswd -a filecloud
sudo smbpasswd -e filecloud


The configuration file for Samba is located at /etc/samba/smb.conf. To add the new directory as a share, we edit the file by running:

sudo nano /etc/samba/smb.conf


The Below is a samba conf sample which we used in this setup


[global]
        server string = samba_server
        server role = standalone server
        interfaces = 192.168.101.188
        bind interfaces only = yes
        disable netbios = yes
        smb ports = 445
        log file = /var/log/samba/smb.log
        max log size = 10000
[filecloud]
        path = /data/filecloud
        browseable = yes
        read only = no
        force create mode = 0660
        force directory mode = 2770
        valid users = filecloud

You can mount the samba share in your filecloud web server nodes using the documentation here.