Today we will learn How to configure Samba Server with Debian 11. Communication is the key point of having a server. But, what if resources are not able to communicate with each other? Yes, this could happen when you are having both Linux and Windows. Sharing resources b/w Linux and windows can be difficult. Samba is the solution for the challenge. The Samba server facilitates sharing resources in a hybrid environment.
Introduction to Samba Server.
Samba is the utility that allows communication with SMB (Server Message Block) protocol. While working in a hybrid environment, things can be challenging. Even handling routine operations like file/resource sharing or printer sharing can be a challenge.
Getting backups for the Inter-OS environment, working under MS active directories is not possible without Samba.
Key Features of Samba Server.
- Key purpose is the share printer and files between Linux and Windows.
- Samba comes as intergrated part of many MS windows Server alternatives e.g. Zentyal.
- May commercial or enen open souces NAS utilies as based on Samba. e.g. TrueNas.
- Latest version of Samba i.e. 4.0 make it possible to join Linux os as MS AD client.
- A easy and quick to deploy utility.
How to install Samba server
Check what is the IP address of the server. Our scenario will be having 192.168.135.131.
# ip addr
# apt update
Install required package for Samba server.
# apt install samba
Enable samba service on reboot.
# systemctl enable smbd
Open the following ports on the firewall.
# ufw allow 139 # ufw allow 445
Now, restart the smbd service
# systemctl restart smbd
Check running status of service.
# systemctl status smbd
Till now everything seems working file.
How to setup samba share.
We have configured the service successfully, now require to setup up a share. We have to define a folder that will be shared across the network. In our example, the scenario folder name will be smbshare.
Create a folder first.
# mkdir /smbshare
Before editing, copy the samba configuration file for the safe side.
# cp /etc/samba/smb.conf smb.conf.orig
Let’s edit the conf file and amend the following line at the bottom.
[samba-share] comment = unixcop share path = /smbshare read-only = no browsable = yes writeable=yes
Comment= A small description of your share.
Path= Absolute path of the shared folder.
read-only= no. The folder will be having read-write permission.
Browsable =yes. The resource can be listed over the network.
Save and exit that file.
Add a samba user to provide access over the internet.
# useradd smbuser
Provide smb authentication to the newly created user i.e. smbuser.
Make smbuser owner for samba share.
# chown smbuser:smbuser /smbshare/
Restart the samba service once again.
# systemctl restart smbd
Open an MS window client. Browse with the IP address of samba share and press enter.
You are able to see the shared resources.
Open share and try to create a file.
See if you are able to see that ‘test’ folder in the smb server machine? yes, we can see that folder here too.
Mount /shared folder on MS windows client permanently. Click on the computer, then select the ‘Map Network Drive’ option.
Provide samba share path. Assing a drive id and finish.
Samba share will be available for us as a drive now, we don’t require to mount that folder every time.
Now we have successfully tested and running the samba server.
Make sure to keep samba ports open on the firewall. Sometimes samba doesn’t work properly if the writeable=yes comment is not amended in conf file. Before testing share on ms windows make sure both server and client are on the same network. Refer to our other documentation for samba server configurations based on different Linux OS. Stay tuned.