Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Debian 11 - Create Samba Share

The following tutorial will show you how to quickly set up a samba share that can only be accessed by a logged in user. This is useful for things like setting up a SAMBA area to act as a Proxmox backups storage location.

If deploying a SAMBA server to act as a Proxmox backup location, be sure to give it enough RAM. I would recommend at least 2GB.

Related Posts

Steps

Install Packages

First install the required packages:

sudo apt-get update
sudo apt-get install samba samba-common -y

Backup

Let's take a backup of the default SAMBA configuration file first, in case we need it later:

sudo mv -i \
  /etc/samba/smb.conf \
  /etc/samba/smb.conf.bak

Run Script To Create SAMBA Configuration

Then edit the following BASH script with the details of which folder you wish to share, and for which the user and group the files should be owned by. When you have done this, run it.

#!/bin/bash

# Set the windows home group. On windows this defaults to WORKGROUP but you may
# have set up a custom home group name, in which case change it here.
HOME_GROUP="WORKGROUP"


# Define the path the the folder that you wish to make available.
SHARED_FOLDER='/path/to/samba/share'

# Define who the owner and group should be 
# for any files that are created
USER="programster"
GROUP="programster"

############################ END OF SETTINGS ###################################

echo "[global]
workgroup = WORKGROUP
server string = Samba Server %v
netbios name = samba
security = user
map to guest = bad user
dns proxy = no
force user = $USER
force group = $GROUP
guest account = $USER

# prevent weak cryptography
server min protocol = SMB3_11
client min protocol = SMB3_11

# disable weak auth
ntlm auth = no

# Disable weak ciphers
smb encrypt = mandatory
disable netbios = yes
server signing = mandatory

[my_shared_folder]
public = no
path = $SHARED_FOLDER
browsable = yes
writable = yes
guest ok = no
read only = no
create mask = 0755" | sudo tee /etc/samba/smb.conf

sudo service smbd restart
echo "Your SAMBA share is now set up."

Debugging

If you experience issues, you may find it useful to run the testparm command. This will tell you if there are any issues with your samba configuration.

References

Last updated: 19th January 2025
First published: 11th January 2025

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch