Search Engine



RedhatEnterpriseLinux Blog

Samba configuration Step by Step Part-3

Connecting Samba Clients and Users
Now that all your Samba shares are set up, you can access them from one of the client systems (Client02). Be aware that you need to install the client Samba packages before you can connect to any Samba shares.

Step 1. Install the client packages:
# yum install -y samba-client samba-common
Step 2. Verify that the install was successful:
# rpm -qa | grep samba

Step 3. Create a local directory where you will mount your Samba share. For this example, make it the same as the Samba share directory to keep things simple:
# mkdir /opt/company_data
Using the smbclient command, you can now mount the Samba share.
Syntax: smbclient [options]
-L         Lists Samba shares
-U        Defines the user to connect with
-P        Defines the password to connect with
-A        Gets credentials from a file

Step 4. List the Samba shares on the RHEL01 Samba server:
# smbclient -L -U user01%<you password here>
Domain=[RHEL01] OS=[Unix] Server=[Samba 3.0.33-3.29.el5_5.1]
Sharename Type               Comment
---------           ----                  -------
company_data       Disk                Directory for all employees
within the company

IPC$   IPC      IPC Service (My Samba Server)
Domain=[INET] OS=[Unix] Server=[Samba 3.5.4-68.el6]
Server                        Comment
---------           -------
Workgroup Master
---------           -------
INET               RHEL01

You can see here that the share named company_data is available for access. Recall from Mount that the mount command allows you to connect additional resources to the file system hierarchy. You can use the mount command here with the cifs option to mount the Samba share.

Step 5. Mount the remote Samba share:
# mount.cifs // /opt/test -o
You can verify that the mount worked successfully by using the
smbstatus command.
Syntax: smbstatus [options]
-p                    Shows processes only
-v                    Provides verbose output
-S                    Shows shares only
-L                     Shows locks only

Step 6. Verify the mount was successful:

# smbstatus
Samba version 3.5.4-68.el6
PID     Username     Group            Machine
3378 user01           user01  (

Service          pid      machine        Connected at
company_data       3378          Tue May 12 16:06:47 2012

No locked files
So far, you are doing well with the client being able to connect to the Samba server. You need to know that any share that is mounted without being added to the /etc/fstab file will be unmounted after the system is rebooted. To remedy this situation, you can create an entry in the /etc/fstab file.

Step 1.Create an entry in the /etc/fstab file:
// /opt/test cifs user=user01,pass=
<password> 0 0

Can anyone find a problem with this entry? The problem here is that the username and password are exposed in clear-text for anyone to see. Another way that you can create an entry in the /etc/fstab file without exposing credentials is to put the credentials inside a file to be referenced from the /etc/fstab file.

Step 2. Add the credentials that you’d like to use to a file:
# echo “username=user01” > /etc/samba/smbcred
# echo “password=password” >> /etc/samba/smbcred

Step 3. Update the entry in the /etc/fstab file to reflect the changes to how the
credentials are read:
// /opt/test cifs credentials=/etc/samba/smbcred 0 0

You can use the umount.cifs command to unmount the Samba share and reboot the system to make sure that the share mounts correctly when the system reboots.


Post a Comment

Powered by Blogger.


Copyright © Redhat Enterprise linux. Original Concept and Design by My Blogger Themes
My name is Abdul Razaq but people call me Raziq. Here is my home page: I live in Quetta, Pakistan and work as an IT-Engineer.