Monday, 6 October 2014

Linux Samba Server Configuration

Samba server provides file and print service to SMB (Server Message Block) clients. It allows inter operation b/w Linux/Unix servers and Windows based client. It sets up network shares of Linux/Unix directories.
For windows users it appears as a normal windows folder accessible via the network and Linux/Unix
users can mount the shares directly as part of their file structure.

Here I am giving you step by step guide to setup samba server -
                         
                                   Server Configuration

Step1.  Login as root , install samba and samba-client packages -

# yum -y install samba samba-client 
# chkconfig smb on                                              [ Setting up the smb service 'on'  after every reboot ]  

Step 2. Now I am gonna create a directory which will be shared via samba -

# mkdir /var/sambashare                            
# chmod 777 /var/sambashare

[Create some files in it, so that we can test the configurtion ]
# cd /var/sambashare && touch file{1..10}

Step 3. Now I am creating users anna, rama and rahul (with no login shell). And will provide smb password for the users.

# useradd  -s /sbin/nologin anna 
# useradd  -s /sbin/nologin rama            
# useradd  -s /sbin/nologin rahul  

# smbpasswd -a anna
# smbpasswd -a rama
# smbpasswd -a rahul


Step 4. Edit the mail configuration file /etc/samba/smb.conf and go to the end. Now set the parameters like share name, share path ,valid users , permissions etc. 
....... 
[ sambashare ]
comment = This is for sales dept.
path = /var/sambashare
valid users = anna rama rahul
public = no
writable = yes
 printable = bo
 create mask = 0765

Save the file and exit. Start the smb service.
 # service smb start
                                      Client Side Configuration

For Linux as client -

To see the list Linux samba server in network

# findsmb

To see the shares -
# smbclient -L //<server ip>

* Connecting by mounting -
# mount //<server-ip>/sambashare /mnt -o username=rama
password:

# cd /mnt && ls                                                      [ Find the shared files ] 

* Connecting by smbclient utility -
# smbclient //<server-ip>/smabashare -U anna
password:


For Windows as client -
 Click on start button + run , type \\<server-ip>\sambashare
(provide username and password)

No comments:

Post a Comment