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.
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
- How to install Samba server on Ubuntu 12.04
- ServerFault - How do I force specific permissions for new files/folders on Linux file server?
- Ask Ubuntu - I cant get samba to set proper permissions on created directories
- Configure permissions and ownership for Samba on Linux
- How-To Geek - Create a Samba User on Ubuntu
- NixCraft - Test your Samba server for configuration errors
First published: 11th January 2025