Debian

Install Samba on Debian 13 / 12 and Create a File Share

On Debian 13 install Samba with one apt command, then add a share stanza in /etc/samba/smb.conf, a Samba password, and a firewall rule for TCP 445. The packages come from the main archive on Debian 13 (trixie) and Debian 12 (bookworm), so no extra repository is involved and the steps below are the same on both releases.

Original content from computingforgeeks.com - post 113857

We ran every step on two fresh servers and one Linux client. The group share on Samba 4.22.11 (tested November 2026 on Debian 13) negotiated SMB 3.1.1 with AES-128-GCM encryption and came back after a client reboot through an fstab automount. The Debian 12 box ran identical commands on Samba 4.17.12 and refused an SMB2 client once hardened. The release differences are tabled at the end.

What the test boxes measured

Both servers were minimal cloud images with a sudo user, and the client was a third Debian 13 VM on the same subnet. Every number in the table comes from captured output further down the page rather than from package metadata, so it shows what a clean install looks like on a small VM and nothing more. Treat the timings as relative, because a different mirror or disk changes them, while the protocol and cipher rows hold on any hardware.

MeasurementDebian 13 serverDebian 12 server
Samba version from apt4.22.114.17.12
apt install time (samba, smbclient, cifs-utils)56.9 s20.8 s
smbd memory right after start9.1 MB6.7 MB
Protocol negotiated by the Linux clientSMB 3.1.1SMB 3.1.1
Session encryption with smb encrypt = desiredAES-128-GCMnot measured
Time for a firewalled client to give up6.1 snot measured

The install time gap is mostly download size, because trixie pulls a larger dependency set and the clock includes the mirror fetch. Memory is the more useful number. An idle smbd with no clients sits under 10 MB on both releases, so Samba is never the reason a small file server runs out of RAM, and the sizing decision comes down to disk and network throughput instead.

Prerequisites

The guide assumes one server and one Linux client on the same LAN. Replace the addresses below with your own: the server commands read them from the Step 1 variables, while smb.conf, the nftables file and the client commands in Step 9 carry them as literal values to edit.

  • Server: Debian 13 or Debian 12 with a sudo user, at 10.0.1.50 in the examples. A fresh system from the Debian step by step guide is enough.
  • Client: any Linux machine on the 10.0.1.0/24 LAN for the mount test. Ours was a Debian 13 VM at 10.0.1.60.
  • Storage: a filesystem with room for the share. The test servers used a 10 GB root disk, while a real file server puts /srv/samba on a separate data disk.

Size the server by the data and the number of concurrent writers, not by Samba itself. A handful of office users on gigabit Ethernet is well served by 2 vCPU and 2 GB of RAM, and the lab boxes are a floor for testing rather than a production recommendation. If only Unix machines will ever mount the share, an NFS server on Debian is the simpler protocol to run.

Step 1: Set the share variables

The share name, path, Samba user and LAN subnet each appear several times in the steps that follow. Export them once in the server shell so every later command uses the same values. Change them here if your network or naming differs, because a typo repeated by hand in five places is harder to find than one wrong export. The password is a throwaway example from the lab, so pick your own before running anything.

export SHARE_NAME="shared"
export SHARE_DIR="/srv/samba/${SHARE_NAME}"
export SAMBA_USER="sambauser"
export SAMBA_PASS="Samba#Cfg2026"
export LAN_SUBNET="10.0.1.0/24"

Print them back before going further.

echo "Share name: ${SHARE_NAME}"
echo "Share dir:  ${SHARE_DIR}"
echo "Samba user: ${SAMBA_USER}"
echo "LAN subnet: ${LAN_SUBNET}"

All four lines should carry a value. An empty one means the export ran in a different shell, and the later commands would then create a share at /srv/samba/ with no name:

Share name: shared
Share dir:  /srv/samba/shared
Samba user: sambauser
LAN subnet: 10.0.1.0/24

The variables live only in the current session. If you log out halfway through, export them again before continuing, because a missing SHARE_DIR makes the chown in Step 3 fail with a confusing “cannot access” error rather than a clear one.

Step 2: Install Samba on Debian

Three packages cover the whole guide. samba provides the smbd and nmbd daemons, smbclient lists and tests shares from the shell, and cifs-utils provides mount.cifs for the loopback test in Step 7. Installing all three now saves a second apt run later.

sudo apt update
sudo apt install -y samba smbclient cifs-utils

Confirm the installed versions with dpkg.

dpkg -l samba smbclient cifs-utils | tail -3

These are the Debian 13 versions. The Debian 12 server showed 2:4.17.12+dfsg-0+deb12u4 for samba and smbclient and 2:7.0-2 for cifs-utils, from bookworm, which is now oldstable:

ii  cifs-utils     2:7.4-1+deb13u2          amd64        Common Internet File System utilities
ii  samba          2:4.22.11+dfsg-0+deb13u1 amd64        SMB/CIFS file, print, and login server for Unix
ii  smbclient      2:4.22.11+dfsg-0+deb13u1 amd64        command-line SMB/CIFS clients for Unix

The daemon binary lives in /usr/sbin, which is not on a normal user’s PATH on Debian. Running smbd --version without sudo returned bash: smbd: command not found on both servers even though the package was installed, so that message does not mean the install failed. The same applies to nmbd when a script runs it as a normal user. Check the version with sudo and confirm both services are up.

sudo smbd --version
systemctl is-active smbd nmbd

Debian starts and enables both daemons during the install, so there is no separate enable step:

sudo smbd --version showing Samba 4.22.11 on Debian 13 with smbd and nmbd active

smbd serves the files on TCP 445 and 139. nmbd only answers NetBIOS name queries on UDP 137 and 138, and because SMB1 is disabled by default it matters for legacy browsing alone. Windows network discovery is a separate service, covered at the end of Step 10.

Step 3: Create the share directory

The samba package creates a sambashare group (GID 988 on the Debian 13 box, 994 on Debian 12). Owning the share directory by that group with the setgid bit set makes every file written through Samba inherit the group, so all members can edit one another’s files without anyone running chgrp. The GID differs between installs, so always refer to the group by name in commands and in smb.conf rather than copying a number from another machine.

sudo mkdir -p "${SHARE_DIR}"
sudo chown root:sambashare "${SHARE_DIR}"
sudo chmod 2775 "${SHARE_DIR}"
ls -ld "${SHARE_DIR}"

The lowercase s in the group execute position is the setgid bit. Without it, a new file takes the writer’s primary group and the next user gets a permission error on it:

drwxrwsr-x 2 root sambashare 4096 Nov 22 09:04 /srv/samba/shared

Keep shares under /srv/samba rather than inside a home directory. A path under /home drags the home directory permissions into the picture, so a share that looks correct in smb.conf still returns “access denied”, and that is the most common cause of the error we see in comments. A dedicated tree also keeps backups simple, since one path holds every share and nothing else needs excluding.

Step 4: Add the share to smb.conf

Back up the stock configuration first. The default file already defines a homes, printers and print$ section, and the original copy is the fastest way back if an edit leaves smbd refusing to start.

sudo cp /etc/samba/smb.conf "/etc/samba/smb.conf.bak.$(date +%F)"

Open the configuration file:

sudo vim /etc/samba/smb.conf

Append this section at the very end of the file. The name in brackets is the share name clients connect to, and the path matches SHARE_DIR from Step 1.

[shared]
   comment = Debian Samba Share
   path = /srv/samba/shared
   browseable = yes
   read only = no
   guest ok = no
   create mask = 0664
   directory mask = 2775
   valid users = @sambashare

Three of those lines carry the access model, and they are the ones to change when you adapt the share:

  • valid users = @sambashare: only members of the Unix group can connect, so access is granted with usermod -aG instead of an smb.conf edit per person.
  • guest ok = no: anonymous connections are refused even though the stock global section sets map to guest = Bad User.
  • create mask 0664, directory mask 2775: new files are group-writable and new folders keep the setgid bit, which carries the Step 3 behaviour below the top level.

Save the file. Nothing changes yet, because smbd only rereads the configuration on a restart or reload, and that comes after the syntax check in Step 6 so a typo never reaches a running server.

Step 5: Create the Samba user

Samba authenticates against its own password database, but every Samba account must map to a Unix account. Create a Unix user with no home directory and no login shell, so the account can reach the share and nothing else on the server, and add it to sambashare in the same command.

sudo useradd -M -s /usr/sbin/nologin -G sambashare "${SAMBA_USER}"
id "${SAMBA_USER}"

The group list must include sambashare, otherwise the valid users line rejects the account:

uid=1002(sambauser) gid=1005(sambauser) groups=1005(sambauser),988(sambashare)

Now set the Samba password. The -s flag reads it from standard input, which is how we scripted the lab run, but it leaves the password in shell history. Run sudo smbpasswd -a "${SAMBA_USER}" without the flag on a real server so you type it at a prompt instead.

printf '%s\n%s\n' "${SAMBA_PASS}" "${SAMBA_PASS}" | sudo smbpasswd -s -a "${SAMBA_USER}"
sudo pdbedit -L

smbpasswd confirms the account and pdbedit -L lists every user in the Samba database with its UID:

Added user sambauser.
sambauser:1002:

For each extra person, repeat the useradd and smbpasswd pair with their name. Keep the passwords in a team vault such as 1Password rather than a shared text file, because a Samba password is also the key to every file on the share.

Step 6: Check the configuration with testparm

testparm parses smb.conf the same way smbd will and prints the effective settings, so it catches a misspelled option before the restart does. Limit it to the new share to keep the output short.

testparm -s --section-name=shared

“Loaded services file OK” is the line that matters. testparm leaves default values such as browseable = yes out of the listing and prints the mask as 02775, so a shorter section than you typed is expected:

testparm -s output for the shared section on Debian 13 with valid users @sambashare

The “Weak crypto is allowed by GnuTLS” line appeared on both releases with a stock config. It reports that NTLM is still available as a fallback for old clients, which makes it a notice rather than an error, and Step 10 is where you push clients to SMB3 with encryption if that fallback bothers you. Leave it alone for now, because changing crypto policy before the share works makes any later failure harder to place.

Step 7: Restart Samba and test the share locally

Restart both daemons to load the new share, then confirm smbd listens on the SMB ports.

sudo systemctl restart smbd nmbd
sudo ss -tlnp | grep -E ':(445|139) '

smbd binds 445 and 139 on IPv4 and IPv6:

LISTEN 0      50           0.0.0.0:445       0.0.0.0:*    users:(("smbd",pid=3172,fd=30))
LISTEN 0      50           0.0.0.0:139       0.0.0.0:*    users:(("smbd",pid=3172,fd=31))
LISTEN 0      50              [::]:445          [::]:*    users:(("smbd",pid=3172,fd=28))
LISTEN 0      50              [::]:139          [::]:*    users:(("smbd",pid=3172,fd=29))

Next, list the shares as the Samba user. Doing this on the server first proves the password database and the share definition together, before a firewall or a remote client can muddy the result.

smbclient -L //localhost -U "${SAMBA_USER}%${SAMBA_PASS}"

The shared share appears next to a home share named after the user, which the stock homes section exposes:

smbclient -L localhost listing the shared Samba share on Debian 13

“SMB1 disabled, no workgroup available” is normal on both releases, because workgroup browsing needs SMB1 and Samba stopped enabling it by default years ago. The sambauser home share points at a directory that does not exist, since useradd -M skipped it. Comment out the homes section in smb.conf if you do not want it advertised, then restart smbd. Leaving it in place does no harm on this setup, though, since a connection to that share simply fails on the missing path.

A loopback mount checks the write path and the setgid inheritance in one go, so it is worth the extra minute before moving to a remote client.

sudo mkdir -p /mnt/sambatest
sudo mount -t cifs "//localhost/${SHARE_NAME}" /mnt/sambatest -o "username=${SAMBA_USER},password=${SAMBA_PASS}"
echo "hello from cifs mount" | sudo tee /mnt/sambatest/hello.txt
ls -la "${SHARE_DIR}"
sudo umount /mnt/sambatest

The file on disk belongs to sambauser and the sambashare group with mode 664, exactly what the share masks asked for:

total 12
drwxrwsr-x 2 root      sambashare 4096 Nov 22 09:04 .
drwxr-xr-x 3 root      root       4096 Nov 22 09:04 ..
-rw-rw-r-- 1 sambauser sambashare   22 Nov 22 09:04 hello.txt

If hello.txt is missing from the listing, the write went to the empty /mnt/sambatest directory on the local disk rather than through the mount, which happens when the mount command failed and the tee carried on regardless. Check findmnt /mnt/sambatest before writing, and fix the mount error first.

Step 8: Open the firewall for Samba

Neither test image had a firewall installed: ufw and nft were both missing on the Debian 13 and Debian 12 cloud images. A server with no filtering exposes SMB to anything that can route to it, so add one now. Pick UFW or plain nftables, not both, because two tools writing rules to the same kernel tables is how rules end up silently overridden. UFW suits a box you manage by hand, while a plain nftables file suits configuration management that ships whole files.

Option A: UFW

Install UFW and look at the Samba application profile it ships.

sudo apt install -y ufw
sudo ufw app info Samba

The profile covers both the NetBIOS UDP ports and the SMB TCP ports:

Profile: Samba
Title: LanManager-like file and printer server for Unix
Description: The Samba software suite is a collection of programs that
implements the SMB/CIFS protocol for unix systems, allowing you to serve
files and printers to Windows, NT, OS/2 and DOS clients. This protocol is
sometimes also referred to as the LanManager or NetBIOS protocol.

Ports:
  137,138/udp
  139,445/tcp

Allow SSH before you enable UFW. Enabling it over an SSH session without that rule cuts your own connection, and the only way back is the provider console. Then allow Samba from the LAN subnet only and switch the firewall on.

sudo ufw allow OpenSSH
sudo ufw allow from "${LAN_SUBNET}" to any app Samba
sudo ufw --force enable
sudo ufw status numbered

The Samba rule shows the subnet in the From column, while SSH stays open from anywhere:

ufw status numbered allowing the Samba profile from the 10.0.1.0/24 LAN on Debian

Rule 2 is the one to tighten later. Replacing the subnet with a single workstation address limits the share to that one machine, and rule 1 is worth narrowing the same way once you know where your SSH sessions come from.

Option B: nftables

We tested this variant on the Debian 12 server. Install nftables if your image lacks it, then replace its configuration file.

sudo apt install -y nftables
sudo vim /etc/nftables.conf

The input chain drops everything by default, so the SSH line is not optional: leave it out and the box locks you out the moment the rules load. Set the subnet to your own LAN.

#!/usr/sbin/nft -f
flush ruleset

table inet filter {
  chain input {
    type filter hook input priority filter; policy drop;
    iif "lo" accept
    ct state established,related accept
    ct state invalid drop
    meta l4proto { icmp, ipv6-icmp } accept
    tcp dport 22 accept

    ip saddr 10.0.1.0/24 tcp dport { 139, 445 } accept
    ip saddr 10.0.1.0/24 udp dport { 137, 138 } accept
  }
}

Check the syntax with -c before loading anything, then load the file and enable the service so the rules return after a reboot.

sudo nft -c -f /etc/nftables.conf && echo syntax-ok
sudo nft -f /etc/nftables.conf
sudo systemctl enable --now nftables.service
sudo nft list chain inet filter input

The loaded chain matches the file line for line, and the client at 10.0.1.60 listed the files in the share with smbclient -c ls straight after the rules went live:

table inet filter {
	chain input {
		type filter hook input priority filter; policy drop;
		iif "lo" accept
		ct state established,related accept
		ct state invalid drop
		meta l4proto { icmp, ipv6-icmp } accept
		tcp dport 22 accept
		ip saddr 10.0.1.0/24 tcp dport { 139, 445 } accept
		ip saddr 10.0.1.0/24 udp dport { 137, 138 } accept
	}
}

The flush ruleset line at the top wipes every table on each load, including rules another tool such as Docker added, so this file suits a dedicated file server better than a shared host. On a box that also runs containers, drop that line and add only the Samba rules to the existing input chain. If you already manage the host with zones, the firewalld guide for Debian covers that route instead.

Step 9: Mount the share on a Linux client

Run this step on the client, not the server. Install the CIFS tools and smbclient, then list the server’s shares over the network, because a working listing here rules out the firewall and routing before fstab gets involved.

sudo apt install -y smbclient cifs-utils
smbclient -L //10.0.1.50 -U 'sambauser%Samba#Cfg2026'

The listing matches the one from Step 7:

	Sharename       Type      Comment
	---------       ----      -------
	print$          Disk      Printer Drivers
	shared          Disk      Debian Samba Share
	IPC$            IPC       IPC Service (Samba 4.22.11-Debian-4.22.11+dfsg-0+deb13u1)
	sambauser       Disk      Home Directories
SMB1 disabled -- no workgroup available

Store the credentials in a root-only file so the password never appears in /etc/fstab, which every user on the client can read.

printf '%s\n' 'username=sambauser' 'password=Samba#Cfg2026' | sudo tee /root/.smbcredentials >/dev/null
sudo chmod 600 /root/.smbcredentials
sudo mkdir -p /mnt/shared

Our first fstab attempt hard-coded uid=1000. It mounted fine and then refused every write with “Permission denied”, because the logged-in user on the client was UID 1001. CIFS presents every file as owned by the uid and gid in the mount options, so take both from id instead of guessing. Run the line below as the user who will work in the share, since $(id -u) expands before sudo runs and captures that user rather than root.

echo "//10.0.1.50/shared  /mnt/shared  cifs  credentials=/root/.smbcredentials,uid=$(id -u),gid=$(id -g),file_mode=0664,dir_mode=0775,_netdev,nofail,x-systemd.automount  0  0" | sudo tee -a /etc/fstab
sudo systemctl daemon-reload
sudo mount -a

Run that tee only once. Our second run appended an identical line, and mount -a then failed with mount error(16): Device or resource busy until the duplicate was deleted. The three options after the modes decide how the client behaves at boot:

  • _netdev: orders the mount after the network is up, so boot does not try SMB before the interface has an address.
  • nofail: lets the client finish booting when the server is down, instead of dropping to emergency mode.
  • x-systemd.automount: defers the real mount until something opens the path, which keeps boot fast and retries on first access.

We rebooted the client to test the line. After boot the path was an autofs trigger, and the first ls mounted the share:

findmnt -t cifs /mnt/shared
ls -l /mnt/shared

Look for vers=3.1.1 in the options and your own user as the file owner:

findmnt showing the Samba share mounted over CIFS vers 3.1.1 on a Debian client after reboot

Both files belong to the client user locally, while on the server they still belong to sambauser and sambashare. That split is how CIFS works without the Unix extensions. The uid and gid options therefore matter more than server permissions for client-side writes. Two users on one client need two mounts if each should own their own files, because a single mount maps everything to one local owner.

Step 10: Harden the server (SMB3, encryption, host limits)

The default config still accepts SMB2 clients and does not ask for encryption. Four global settings change that, and we applied them on both the Debian 13 and Debian 12 servers without touching the client. Open the file again.

sudo vim /etc/samba/smb.conf

Add these lines directly under the existing [global] header, with your own subnet in hosts allow:

   server min protocol = SMB3
   smb encrypt = desired
   hosts allow = 127.0.0.1 10.0.1.0/24
   hosts deny = 0.0.0.0/0

Confirm Samba parsed them, then restart smbd.

testparm -s | sed -n '/\[global\]/,/^$/p' | grep -E 'hosts|min protocol|encrypt'
sudo systemctl restart smbd

The protocol floor and both host lists come back, but the encryption line did not come through this filter in our run. Do not rely on testparm for that setting, because the smbstatus check below is what proves encryption is actually on:

	server min protocol = SMB3
	hosts allow = 127.0.0.1 10.0.1.0/24
	hosts deny = 0.0.0.0/0

Each setting closes a different gap, and only the last one needs a judgment call:

  • server min protocol = SMB3: Samba reads SMB3 as the SMB3_11 dialect, so it refuses SMB2 and also SMB 3.0 and 3.0.2 clients such as older NAS units and scanners. Use SMB3_00 instead if one of those must keep working.
  • hosts allow and hosts deny: a second filter inside Samba for IPv4 clients. 0.0.0.0/0 never matches an IPv6 address and smbd also listens on [::], so on a host with routable IPv6 the smb.conf manual’s hosts deny = ALL form is the one to use, with ::1 added to hosts allow so local tests keep working (we tested the IPv4 form).
  • smb encrypt = desired: encrypts every client that supports it and still admits the rest unencrypted; required refuses a client that cannot encrypt.

With the client still mounted, smbstatus on the server shows what each session negotiated.

sudo smbstatus --shares

Both the share and the IPC connection run AES-128-GCM encryption with AES-128-CMAC signing:

smbstatus --shares showing AES-128-GCM encryption and AES-128-CMAC signing for a Debian Samba client

We would keep desired on a mixed office network and move to required only once smbstatus shows every regular client already encrypting, because a printer or scanner that cannot encrypt simply stops saving to the share. The smb.conf manual documents the exact behaviour of each server smb encrypt value.

Windows users who expect the server under Network in Explorer need a WS-Discovery responder, because nmbd only answers the SMB1-era NetBIOS browse. Debian 13 ships wsdd2 but no longer ships wsdd, while Debian 12 has both. The install is one command and the service starts on its own.

sudo apt install -y wsdd2
sudo ss -ulnp | grep 3702

wsdd2 listens on UDP 3702 for discovery probes:

UNCONN 0      0              0.0.0.0:3702      0.0.0.0:*    users:(("wsdd2",pid=3932,fd=3))
UNCONN 0      0                 [::]:3702         [::]:*    users:(("wsdd2",pid=3932,fd=4))

Discovery is a convenience, not a requirement, so skip it on a server that only Linux machines use. Our Linux client never needed it, because smbclient and mount.cifs connected by address in every test above. Neither firewall from Step 8 opens UDP 3702 either, so allow it from the LAN as well if you rely on discovery. Our lab had no Windows client, which means the Explorer side was not tested here; the Windows and Linux Samba guide covers the Windows end of an SMB share.

Troubleshooting Samba on Debian

Every error below was produced on the test boxes, either on purpose or through our own mistakes during the run. Each one names a different layer, so read the exact message before changing anything.

session setup failed: NT_STATUS_LOGON_FAILURE

smbclient prints this when the user name or Samba password is wrong. Reaching this message proves the network path is fine, because the server had to answer to reject you.

session setup failed: NT_STATUS_LOGON_FAILURE

Check that the account exists in the Samba database with sudo pdbedit -L. A Unix password does not count here, since only smbpasswd -a creates the Samba entry. If the account is listed, reset its password with sudo smbpasswd sambauser and try again.

mount error(13): Permission denied

The same bad password through mount -t cifs gives a less helpful message, because error 13 covers both credentials and permissions. The kernel log tells you which one it was.

sudo dmesg | grep -i cifs | tail -3

STATUS_LOGON_FAILURE in dmesg means credentials, not file permissions:

[  286.831961] CIFS: Status code returned 0xc000006d STATUS_LOGON_FAILURE
[  286.839237] CIFS: VFS: \\10.0.1.50 Send error in SessSetup = -13
[  286.847307] CIFS: VFS: cifs_mount failed w/return code = -13

Fix the credentials file, which needs one username= and one password= line with no quotes, and run sudo mount -a again.

do_connect: Connection failed (Error NT_STATUS_IO_TIMEOUT)

We removed the UFW Samba rule and connected from the client to reproduce this one. smbclient gave up after 6.1 seconds:

do_connect: Connection to 10.0.1.50 failed (Error NT_STATUS_IO_TIMEOUT)

A timeout means packets are dropped on the way, almost always by the server firewall or a cloud security group. Run sudo ufw status or sudo nft list ruleset on the server and check that the client address sits inside the allowed subnet. A refused connection would point the other way, to smbd not listening at all. The 6.1 second wait is itself a clue, so a fast failure and a slow one deserve different first checks.

Protocol negotiation failed: NT_STATUS_NOT_SUPPORTED

After Step 10 we pointed the client at the hardened Debian 12 server (10.0.1.51) and forced it down to SMB 2.1 with smbclient -m SMB2_10 to see what an old client gets.

Protocol negotiation to server 10.0.1.51 (for a protocol between SMB2_02 and SMB2) failed: NT_STATUS_NOT_SUPPORTED

That is server min protocol = SMB3 doing its job, and an SMB 3.0 client would hit the same wall. Upgrade the client if you can, or lower the minimum to SMB2_10 for as long as an old appliance has to keep writing to the share.

Permission denied when writing to the mounted share

The mount succeeds, ls works, and every write fails. On our client the mount carried uid=1000 while the user was UID 1001, so the files showed up as owned by someone else with mode 755. Remount with uid=$(id -u),gid=$(id -g) and group-writable modes as in Step 9. When the server side is the cause instead, the setgid bit has usually dropped off a subdirectory, and sudo find /srv/samba/shared -type d -exec chmod 2775 {} + puts it back.

Debian 13 vs Debian 12: what differs for Samba

The steps are identical on both releases. What changes is the version apt installs and a few package details, all read from the two test servers.

ItemDebian 13 (trixie)Debian 12 (bookworm)
samba package2:4.22.11+dfsg-0+deb13u12:4.17.12+dfsg-0+deb12u4
cifs-utils2:7.4-1+deb13u22:7.0-2
sambashare GID on the test box988994
Windows discovery packageswsdd2 onlywsdd and wsdd2
UFW Samba profile137,138/udp and 139,445/tcpsame
SMB3 minimumapplied, confirmed by testparmapplied, SMB2 client refused
Session encryption checked with smbstatusAES-128-GCMnot measured

The Debian 12.15 server listed the same share set from the same smb.conf, with only the version string in the IPC comment changed:

Debian 12.15 running Samba 4.17.12 with the shared share listed by smbclient

For a new file server, use Debian 13: its Samba line is five minor releases newer and it is the release where we confirmed encryption end to end. A Debian 12 box that already serves files has no Samba reason to rush the upgrade, because the share definition, users and firewall rules carry over as they are. Ubuntu readers can follow the Samba guide for Ubuntu 26.04, and the RHEL family has its own walkthrough for Samba on AlmaLinux and Oracle Linux.

Whatever the release, a share on one server is a single copy of the data. Keep anything irreplaceable somewhere else as well, and one of the external drives that hold up for backups, rotated off site, covers the failures a single box cannot.

Need a Samba server, Active Directory integration, or migration off Windows file servers done right the first time? The ComputingForGeeks team deploys and supports file-sharing infrastructure for teams in AWS, GCP, Hetzner, and on-prem. Reach us at [email protected].

Keep reading

Free CCNA Practice Test: 600+ Questions for 200-301 v2.0 Networking Free CCNA Practice Test: 600+ Questions for 200-301 v2.0 Best NAS Hard Drives for 2026: WD Red vs IronWolf, Price per TB Storage Best NAS Hard Drives for 2026: WD Red vs IronWolf, Price per TB Backup and Restore Linux Systems with Timeshift Debian Backup and Restore Linux Systems with Timeshift AI NAS Explained: Is Local AI on a NAS Worth It? AI AI NAS Explained: Is Local AI on a NAS Worth It? TrueNAS Proxmox Plugin: iSCSI and NVMe/TCP Setup Guide Storage TrueNAS Proxmox Plugin: iSCSI and NVMe/TCP Setup Guide Configure Chrony NTP Server on Debian 12/11/10 Debian Configure Chrony NTP Server on Debian 12/11/10

11 thoughts on “Install Samba on Debian 13 / 12 and Create a File Share”

  1. This was super helpful but I’m running into a problem when trying to create or edit files from the windows file explorer. I followed your guide up to that point and had no problems, but when I try to log in to the /private folder from windows I get:

    “\\192.168.1.5\private is not accessible. You might not have permission to use this network resource.”

    I can map the network location and open files inside, but any time I try to edit them or create a new file I get permissions errors.

    Here’s my permissions settings for my shared folders:
    drwxrwsr-x 2 root smbshare 4096 May 19 09:20 public
    drwxrws— 2 root smbshare 4096 May 19 08:45 private

    Reply
  2. Ok I think it’s working now. I had to run these commands:

    sudo chown -R my_username /public
    chmod -R a+w /public
    sudo systemctl restart nmbd

    Now when I map the network drive in windows (\\192.168.1.5\public) I have write privileges.

    Reply
  3. Starting here:

    Now edit the Samba conf and add the two directories.

    sudo vim /etc/samba/smb.conf
    At the end of the file, add the shares and authentication methods to access it.

    I have no idea as to what directory or where in the directory tree to put these /public and /private directories.

    Reply
  4. The instructions on the linux side worked flawlessly for me on Raspberry Pi OS:

    # lsb_release -a
    No LSB modules are available.
    Distributor ID: Raspbian
    Description: Raspbian GNU/Linux 11 (bullseye)
    Release: 11
    Codename: bullseye

    I have an old embroidery machine that mounts as a DOS disk via USB and that’s the only way to transfer files to the machine for sewing / embroidery. Using a Raspberry Pi and a wifi dongle, I was able to create a samba share using these instructions and then mount that share on my remote MacOS MacBook Pro. I can now create the files on the MacBook and transmit them over to the rPi using samba. I could not get the DOS disk to directly work as the share, so there is still an intermediary step of having to copy them from the rPi storage to the mounted embroidery machine, but that is really easy-peasy compared to having to bring the laptop over to the machine, plug it in via USB, etc. Thank you!

    Reply
  5. I’m running into this error when trying to set the password

    “sudo (echo “${SAMBA_PASS}”; echo “${SAMBA_PASS}”) | smbpasswd -s -a “${SAMBA_USER}”
    -bash: syntax error near unexpected token `echo’

    Not sure what the problem is in this case.

    Reply
    • Bash cannot parse “sudo (subshell)” because “(” is not a command argument. Either run the whole step as root (sudo -i) or move sudo to the right side of the pipe:

      (echo “${SAMBA_PASS}”; echo “${SAMBA_PASS}”) | sudo smbpasswd -s -a “${SAMBA_USER}”

      Or cleaner with printf:

      printf ‘%s\n%s\n’ “${SAMBA_PASS}” “${SAMBA_PASS}” | sudo smbpasswd -s -a “${SAMBA_USER}”

      Tested on Debian 13. Article updated to use the printf form.

      Reply
  6. Good guide, and it got me going, but there are a couple of mistakes (I think) in the step 9 block that reads:

    SERVER_IP=10.0.1.50
    mkdir -p /mnt/samba-shared
    mount -t cifs “//${SERVER_IP}/${SHARE_NAME}” /mnt/samba-shared \
    -o credentials=/root/.samba/shared.creds,vers=3.0,uid=1000,gid=1000
    ls /mnt/samba-shared

    Since at this point we’re over on the Linux client, ${SHARE_NAME} is undefined. So I substituted its actual value of “shared”. Further, the value of ${IP_ADDRESS} should be the actual IP address of the server, not “10.0.1.50” (unless it just happens to be that, due to wild coincidence).

    Reply
    • You are right on both counts. The Step 1 variables only exist in the server’s shell, and 10.0.1.50 is a placeholder for your Samba server’s address. Step 9 now exports SERVER_IP and SHARE_NAME on the client and tells you to swap in your server’s IP, including in the fstab line.

      Reply

Leave a Comment

Press ESC to close