Contact for queries :
 

Samba Client Configuration in Linux

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
samba-client-3.5.4-68.el6.x86_64
samba-winbind-clients-3.5.4-68.el6.x86_64
samba-common-3.5.4-68.el6.x86_64

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]
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 172.168.1.1 -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 Chapter 4 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 //172.168.1.1/company_data /opt/test -o
username=user01,password=<password>

You can verify that the mount worked successfully by using the smbstatus command.

Syntax: smbstatus [options]
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 172.168.1.20 (172.168.1.20)
Service pid machine Connected at
——————————————————-
company_data 3378 172.168.1.20 Tue Oct 12 16:06:47 2010
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:

//172.168.1.1/company_data /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:

//172.168.1.1/company_data /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

November 15, 2015

0 responses on "Samba Client Configuration in Linux"

Leave a Message

Your email address will not be published. Required fields are marked *

About iGURKUL

IGURKUL I.T. Training Hub offering various Career Certification courses in Computer Networking, Unix, Linux, Cloud Computing and DevOps Technologies. With its rich experience in IT training service sector, iGURKUL has been able to set Industry best practices in IT Training for the past five years.

In Past five years, more than 5000 professionals have been trained by iGURKUL for System administration, Cloud Computing and DevOps Skill set through our Online Training portal www.unixadminschool.com. And , each day , more than 10000 working professionals from all over the globe visiting our knowledge base www.unixadminschool.com/blog for the best practices and Knowledge learning.

Popular Tags

Who’s Online

Profile picture of Raja Raghava
Profile picture of Mark Joe
Profile picture of Arun S Vijayan
top
Template Design © igurkul I.T. solutions. All rights reserved.
X