Back to Homepage

Quick guide in setting up file server using Samba

Article written based on Debian 11

Simple guide for setting up your Samba file server. Saving and protecting your data is a habit worth having. Before we continue, please make sure you have a static IP configured on your server.

Lets start with updating your system and installing the Samba package. sudo apt-get update;
sudo apt-get install samba -y;
Now stop the Samba process until we have finished configuring it. sudo systemctl stop smbd.service Create a copy of the config file incase of any issues sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.backup Lets move onto configuring Samba sudo nano /etc/samba/smb.conf Now configuring Samba can become quite complex, but I will provide a basic configuration template to get you started. [global]
  server string = %h file server
  server role = standalone server
  workgroup = WORKGROUP
  bind interfaces only = yes
  disable netbios = yes
  smb ports = 445
  log file = /var/log/samba/smb.log
  max log size = 10000

  server signing = mandatory
  server min protocol = SMB3
  server smb encryption = mandatory
  security = user
  encrypt passwords = true
  passdb backend = tdbsam
  obey pam restrictions = yes
  unix password sync = yes
  client plaintext auth = no

  passwd program = /usr/bin/passwd %u
  passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully*.
  pam password change = yes
  map to guest = bad user

  load printers = no
  printcap name = /dev/null
  disable spoolss = yes

The base configuration is now complete, now we can move onto creating a user and a shared folder. sudo mkdir /samba/"
sudo chown :sambashare /samba/
Create your user and its shared folder. I will be using the user "bobbybills" and the folder "bobbybillshome". sudo mkdir /samba/bobbybills
sudo adduser --home /samba/bobbybillshome --no-create-home --shell /usr/sbin/nologin --ingroup sambashare bobbybills
Configure the user data directory owner and permissions sudo chown bobbybills:sambashare /samba/bobbybillshome/
sudo chmod 2770 /samba/bobbybillshome
Now we add and enable your user to the Samba users list, you will get the option to input your password for this user as well, this will be the password you will use to access the Samba share. sudo smbpasswd -a bobbybills;
sudo smbpasswd -e bobbybills;
Lets add the newly created Samba share directory to the configuration file, by adding the configuration after the [global] section sudo nano /etc/samba/smb.conf and using the following configuration template: [bobbybills]
  path = /samba/bobbybillshome
  browseable = no
  read only = no
  force create mode = 0660
  force directory mode = 2770
  valid users = bobbybills
Now we can start Samba process back up again sudo systemctl start smbd.service Me, myself and I prefer a reboot, due to how software is being written these days sudo reboot Now you should have a functioning file server to work with. On Windows 10, the Samba share you created can now be mapped using the following URL format: \\your_samba_server_ip_address\bobbybillshome A prompt will appear asking for your username and password, use the username and password you have created, in this case bobbybills.

Explore a similar article on this topic

Create automatic mounting of storage devices for your file-server