🌱Configuring SAMBA
Published by Scott Kingery on
Installing Samba on Ubuntu Server
This guide installs Samba on an Ubuntu server and creates a Windows-accessible network share.
1. Install Samba
Update the package list and install Samba:
sudo apt update
sudo apt install samba
Verify the installation:
smbd --version
2. Create a Directory to Share
For this setup, the shared directory is:
/srv/share
Create it:
sudo mkdir -p /srv/share
Set the directory owner to your Ubuntu user. In this example, the user is jsmith:
sudo chown jsmith:jsmith /srv/share
Check the permissions:
ls -ld /srv/share
The result should look similar to:
drwxr-xr-x 2 jsmith jsmith 4096 Sep 3 21:28 /srv/share
3. Create a Samba User
Samba has its own password database.
Add the existing Ubuntu user to Samba:
sudo smbpasswd -a jsmith
Enter a Samba password when prompted.
Enable the Samba account:
sudo smbpasswd -e jsmith
Note: The Samba password does not necessarily have to be the same as the Ubuntu login password.
4. Configure the Samba Share
Edit the Samba configuration:
sudo nano /etc/samba/smb.conf
Add the following to the bottom of the file:
[Share]
path = /srv/share
browseable = yes
read only = no
writable = yes
valid users = jsmith
Save the file and exit Nano.
5. Check the Samba Configuration
Always test the configuration before restarting Samba:
testparm
You should see:
Loaded services file OK.
To see the active configuration:
testparm -s
The share should appear as:
[Share]
path = /srv/share
read only = No
valid users = jsmith
6. Start and Enable Samba
Restart Samba:
sudo systemctl restart smbd
Enable Samba to start automatically after reboot:
sudo systemctl enable smbd
Check its status:
sudo systemctl status smbd
Look for:
Active: active (running)
7. Verify Samba Is Listening
Check that Samba is listening on the standard SMB ports:
sudo ss -tulpn | grep -E ':(139|445)'
You should see Samba listening on port 445 and usually port 139.
For example:
tcp LISTEN ... 0.0.0.0:139 ... smbd
tcp LISTEN ... 0.0.0.0:445 ... smbd
Port 445 is the important SMB port.
8. Check the Ubuntu Firewall
Check UFW:
sudo ufw status
If UFW is active, allow Samba:
sudo ufw allow samba
If UFW is inactive, no firewall change is necessary.
9. Test Samba Locally
Install the Samba client tools:
sudo apt install smbclient
Test the share locally:
smbclient //localhost/Share -U jsmith
Enter the Samba password.
A successful connection will give you:
smb: \>
You can then test the contents with:
ls
Exit with:
quit
10. Connect from Windows
Find the Ubuntu server's IP address:
hostname -I
For example:
192.168.1.221
From Windows File Explorer, enter:
\\192.168.1.221\Share
When prompted for credentials, use:
Username: jsmith
Password: <Samba password>
If you have problems connecting from Windows 11
Run the following commands in Windows PowerShell as Administrator:
Set-SmbClientConfiguration -RequireSecuritySignature $false
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters" RequireSecureNegotiate -Value 0 -Force
Restart the computer and try connecting again
