Tuesday, March 13, 2012

Samba server configuration

SAMBA(SMB server) is a file sharing server. Which is used to share files between Windows, Linux and Unix Systems. SMB(Server Message Block) is a proprietary protocol which is developed by Microsoft

This article explains how to install and configure SAMBA in Linux.

Requirement : Share a directory /sample with a share name linux throughout the example.com network to the user suri with the password redhat, and should have only read access

Step 1: Create a directory where you want to keep data and share with other remote systems(either windows/Linux/UNIX).
#mkdir /sample

Step 2 : Installing Samba server
#yum install samba* -y

Step3: Check the context of shared directory  with ls using ls –Z
[root@servername ~]# ls -dZ /sample
Change the context to samba, i.e,
[root@servername ~]# chcon –t samba_share_t /sample

 Step 4 : Now we have to configure the samba server. Edit the main configuration file (/etc/samba/smb.conf)

specify the work group where this server belongs 

#vim /etc/samba/smb.conf

search for workgroup word and specify your work group name

workgroup = SURYA

Why we require this workgroup? 
When windows user tries to access any network resource they first try to access my network places and then search for workgroup then to server. So definitely we have to specify this workgroup entry in smb.conf file.

Now specify the share details, which folder you want to share. To whom you want to share? Goto last line of the smb.conf file specify your shared folder details as follows.

comment = "This is the Sample data which is shared with my windows users"
path = /sample
valid users = suri
writable = no (or) read only=yes
browseable =yes
Hostsallow=192.168.0.  (network ip of ur domain)

After giving this seven entries just save and exit the file.

Let me explain each and every thing what we used here.
a. [linux] -- This is the share name, so whenever any user accessed the samba server through network this will be visible as folder shared.
b. comment -- This is just a comment, which will help to know what is this share for.
c. path -- This is used to specify which folder on my samba machine to share.
d. valid users -- This will specifies which user is having access on this folder.
e. writable -- This will specify whether users are able to write or not, In this example the can just read the folder and copy..
f. browseable -- This is used to specify whether the folder content is browseable or not.
g. Public -- This will indicate whether this folder is public or not
h. printable-- This will indicate whether this folder is printable or not
i. hostsallow – give ip address of ur network, so that it will allow that domain

You can specify the Read-Only and Write Access to specified using keywords "read only" and "write list"

example: write list = user1, user3
              read only = user2, user4

Step 5 : Now create passwords for the users who are going to access this samba share remotely.
#smbpasswd -a suri

generate the passwords for this user and this passwords will be stored in /etc/samba/smbpasswd

Step 6 : check for the syntax for your smb.conf file if in case you did any mistake

Step 7 : Restart the samba service
#service smb restart

Step 8 : Permanently on the smb service, So that after rebooting the system too our server will start running.
#chkconfig smb on

Step 9: To list all Samba users in local machine, use the following command
pdbedit –L

Step 10: To check it on server machine
Smbclient  // –U suri

It will ask password
Enter password
Then we can see the smb shell


Thats all. You have done configuring the samba server.

1 comment: