How to Configure Samba Server Multiuser in Centos 7 , Redhat 7 - Linux tech Solutions

Share on :

How to Configuer Samba Server Multiuser in Centos 7 , Redhat 7

 configure Samba Server Multiuser

Samba is a free software re-implementation of the SMB/CIFS networking protocol, and was originally developed by Andrew Tridgell. Samba provides file and print services for various Microsoft Windows clients and can integrate with a Microsoft Windows Server domain, either as a Domain Controller (DC) or as a domain member. As of version 4, it supports Active Directory and Microsoft Windows NT domains.

Samba runs on most Unix, OpenVMS and Unix-like systems, such as Linux, Solaris, AIX and the BSD variants, including Apple's macOS Server, and macOS client (Mac OS X 10.2 and greater). Samba is standard on nearly all distributions of Linux and is commonly included as a basic system service on other Unix-based operating systems as well. Samba is released under the terms of the GNU General Public License. The name Samba comes from SMB (Server Message Block), the name of the standard protocol used by the Microsoft Windows network file system.

Server Side Configuration

1) Firstly install the packages samba, samba-common, samba-client package.

[email protected]  #  yum  install  samba  samba-common  samba-client  -y

Note:If you don't know how to configure yum server you can refer the link given below
href="http://linuxtechsolutions.blogspot.in/2018/01/how-to-create-ftp-server-in-redhat7.html">Yum Server

2) Now create Directory you want to share.

[email protected] # mkdir /share

3) Now give full Permission on the directory.

[email protected] # chmod 777 /share

4) Now Apply the selinux context on the shared directory.
The selinux context of samba is samba_share_t

[email protected] # semanage fcontext -a -t samba_share_t '/share(/.*)?'

5) Now we will restore the context on the shared directory.

[email protected] # restorecon -vvRF /share

6) Now move to the configuration file of samba.

[email protected] # vim /etc/samba/smb.conf

7) Now go to the last line by pressing (shift + g) togethere and you have to give the share name, path, public, browseable, valid users, read list, write list, comment to both the shares.

[samba-share]   # Share Name
 path=/share
 public=no
 browseable=yes
 valid users=user1,user2
 write list=user1
 read list=user2
 comment=Samba Multiuser

8) To check that the configuration is correct.
#testparm [Press enter two times to check]

9) Now create two users.

[email protected] # useradd user1
[email protected] # useradd user2

10) Now give smb password and it is mandatory to give the smb password.

[email protected] # smbpasswd -a user1
[email protected] # smbpasswd -a user2

11) Now start and enable the service of the samba.

[email protected] # systemctl start smb nmb
 [email protected] # systemctl enable smb nmb

12) Now apply the firewall rule.

[email protected] # firewall-cmd --permanent --add-service=samba
[email protected] # firewall-cmd --reload

Now Our Server Side Configuration is Complete.

Client Side Configuration

1) Install two packages samba-client and cifs-utils.

[email protected] # yum install samba-client cifs-utils -y

2) Check the connnection between the server and client.

[email protected] #smbclient -L [Server IP]

[email protected] #smbclient -L 172.25.1.30

[Don't enter the root password just press enter]

3) Now we will mount the shared directories from the server Permanently:-
//[server ip/share name] /mnt cifs defaults,_netdev,creds=/etc/abc.txt 0 0

[email protected] #vim /etc/fstab
//172.25.1.30/samba-share /mnt cifs defaults,_netdev,sec=ntlmssp,multiuser,creds=/etc/abc.txt 0 0

4) Now we will create a file and give user credentials to mount.

[email protected] #vim /etc/abc.txt

 username=user1
 password=redhat

The Password in this file you have to give is smbpassword.

5) Change the permission of abc.txt file to 600 so others cant access the file.

[email protected] # chmod 600 /etc/abc.txt

6) Now mount and check the directory.

7) Go to the mount directory and make any file.

file created because here we have used the credentials of user2 who have read and write permission on the directory

8) Now umount the mount directory.

[email protected] #umount /mnt

9) Again go to the abc.txt file and change the credential to user2.

[email protected]  #vim  /etc/abc.txt

 username=user2
 password=centos

The smbpassword of user2.
10) Now again mount the directory.

[email protected]   # mount -a
 [email protected]  #  mount

11) Go to the mount directory and create a file.

[email protected]  #  cd  /public
 [email protected]  # touch  file2 [It will show the error permission denied because it uses the user credentials which is having read only permission]  [email protected]  #  ls
 [email protected]  #  file [but the user2 to has read permission ad hence and read the content of the directory ]

file created because here we have used the credentials of user2 who have read and write permission on the directory

The Video Below is a Guide for Samba Multiuser.


Share on :

You may also like...

5 Responses

  1. Unknown says:

    Now you buy one the top rate bitcoin mining machine asic antminer s9 for sale at very low price, it is on sale direct from china, Yes, 100% brand new working fine with complete packing and free shipment

  2. manisha says:

    Thank you for sharing such great information very useful to us.
    RHCE Training in Delhi

  3. Ram Niwas says:

    Your blog is really Very interested. Please keep sharing more blogs.

    Red Hat Virtualization Training

  4. Pradhan mantri yojana says:

    This content is really great. Thanks for sharing..
    শেয়ার ব্যবসা
    অল্প পুজিতে লাভজনক ব্যবসা

  5. Rajani says:

    Thanks for sharing Very Useful Blog…
    Docker Online Training
    Kubernetes Online Training
    Kubernetes Training in Hyderabad
    Docker and Kubernetes Training in Hyderabad

Leave a Reply

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