Call 1 (201) 549-9007 (US) | +91 - 836-854-5467 (WhatsApp) Email: [email protected]

How To Deploy Samba Server on Local Host?


How-To-Deploy-Samba-Server

Installing Samba on Ubuntu:

Samba is a suite of Unix applications that speak the Server Message Block (SMB) protocol. Microsoft Windows operating systems and the OS/2 operating system use SMB to perform client-server networking for file and printer sharing and associated operations.

A Samba file server enables file sharing across different operating systems over a network. It lets you access your desktop files from a laptop and share files with Windows and macOS users.

Samba is available from the official Ubuntu repositories. To install it on your Linux system, follow the steps below:

Start by updating the apt packages index:

update

Install the Samba package in your Linux machine with the following command:

install-samba

Once the package is installed, check the status of the Samba server with the following command. It should be showing active status if the samba is installed successfully.

samba-running

SMB requires network ports on a computer or server to enable communication to other systems. We will have to run a command that will allow the smbd server to listen on port 139 and 445 (TCP ports) and nmbd server on port 138 and 139 (UDP ports).

Use the following command to start smbd and nmbd.

The smbd server daemon provides file sharing and printing services to Windows clients. The nmbd server daemon understands and replies to NetBIOS name service requests such as those produced by SMB/CIFS in Windows-based systems.

Opening Ports in Firewall:

If the firewall is enabled in your Linux machine, it will not allow our samba traffic. We will have to open the ports 139, 445, 137 and 138 on firewall to allow samba traffic to pass. Use the command below to allow ufw firewall for samba:

allow-samba

Open the ports: 139, 445, 137 and 138

virtual-box

Check the status of ufw with the following command:

ufw-status

Creating Samba Users on Samba Server:

We will add two users to the samba server so that we can connect to samba using these users. I will add users named “bob” and “jim”.

Run the following command to add the users:

user-add-bob

Note: we have provided nologin shell to these users by adding “-s /sbin/nologin” command. This is because we are creating these users as samba users and not as system users.

Now set the passwords for these samba users by using the following commands:

a-bob

We have added samba password for user “bob”. Similarly add for “jim”.

Configure the share access on samba server:

First of all, create a directory that you want to share on samba server. Change the permissions on the directory with “chmod” command (777 means read, write and execute permissions to everyone). Use the commands as shown below.

mkdir/share

It will create a directory named “share” in path “/”.

Our next step is to edit the main configuration file of samba that is located at /etc/samba/smb.conf

Open the smb.conf file with the following command:

sbm.conf

It will open the file as below. You can edit the name of the workgroup here.

workgroup

Go to the end of this file and add the following parameters:

[my-samba-share] It is the name of the share that will be discovered by client.

path = /share It is the path of the directory that we want to share

public = no It means no-one can access the share without authentication

valid users = bob, jim These are authenticated users that can connect to samba share

read list = bob It means, user bob has read access to samba share

write list = jim It means, user jim has write access to samba share

browsable = yes All the users will be able to discover the network share on client-side

comment = “My Samba File Server” You can add any comment

samba-share

Save changes to the file.

Access the Samba Share with Localhost:

Put a file in your /share directory. I have put a file named css.txt in /share directory. Now move to the client-side to check if samba share is accessible with the authenticated users. I have accessed the Samba-share with localhost IP. Go to file manager of your machine and go to other locations and enter the command as shown below:

Deploy Samba Server on Local Host

It will pop up a window for credentials. I have entered the credential for user “bob”.

Deploy Samba Server on Local Host

I got connected to the samba server and could access the file named css.txt.

Comments

Leave a Reply

Your email address will not be published.

Open chat
Hello 👋
Can we help you?
  • Contact Us

    Contact Us