Skip to main content

CONFIGURING SAMBA MULTIUSERS ON CENTOS 7

This article we will be going through setting up SAMBA server with Window/Linux and Linux clients respectively. This article will definitely help you if you are called up for setting up file servers in enterprise environments where we will likely find different type of devices and operating systems .

Our current testing environment persist of 2 Centos 7 boxes and one Windows 10 machine.

SAMBA Server : 192.168.6.232
SAMBA Client (Linux) : 192.168.6.233
SAMBA Client (Windows) : 10.10.16.16

SERVER SIDE

INSTALL PACKAGE

Firstly , we will need to install the respective package in the server side .

# yum install samba samba-client -y

START THE SAMBA SERVICE

After installing the package we will need to start up the service as well as enable the service.

# systemctl start smb
# systemctl enable smb

FIREWALLD

After starting and enabling the service we will need to add the service in the firewall . 

# firewall-cmd --add service samba --permanent
# firewall-cmd --reload

CONFIGURING SAMBA SHARE

We will need to create a folder which we want to share and also dive into the main configuration file /etc/samba/smb.conf. In this particular example we would like Harry to be given full permission where as the user Andrew to be given Read Only permission.

1.     CREATE A DIRECTORY YOU WANT TO SHARE

 # mkdir    /local

2.      CREATE MULTIPLE USER TO READ/WRITE

# useradd harry –s /sbin/nologin
# useradd andrew -s /sbin/nologin

3.      ASSIGN   SMBPASSWD TO THE USERS

# smbpasswd –a harry
New Smb Password:
Retype new Smb Password :

#smbpasswd -a andrew
New Smb Password:
Retype new Smb Password :

4.      CHANGE SELINUX SECURITY CONTEXT TO THE SHARE DIRECTORY

We will either need to disable the selinux or set the correct security context for the file to be shared in proper way otherwise selinux will prevent user from accessing the share file.

# chcon –t samba_share_t /local

5.      CHANGE THE MAIN CONFIGURATION FILE

[ ]           = Share name
comment = Brief introduction about the share optional parameter 
path =  It specifies  absolute path of the directory
browseable = If 'Yes' = visible share
                       If 'No' =  Read-write enable share
writable = If  'no' = Read only share 
                 If 'yes' =  Read-write enable share
valid users =   To allow access of the given shared directory to the specified users only
write list =      To allow write privilege to the given user only
hosts deny =   To deny access of the given folder to the specified host.
hosts allow =  To allow access of shared directory from the specified host only.
create mask = To force files to be created with

#vim /etc/samba/smb.conf

[local]
comment = my local
path = /local
browseable = yes
write list = harry
hosts allow = 192.168.6. (Overall Network)                  
hosts deny = 192.168.6.20 (Single Host)


Note: In our example Write List is only given to Harry because the user Harry is only allowed to Read/Write where as for the user Andrew we will keep it as Read Only .

6. SET ACL (for the user Harry) 
             
We have set ACL permission of rwx to the user harry for  the folder (local) .

#setfacl -m u:harry:rwx /local

                     
7.    VERIFY THE FILE IS BEING SHARED 

#smbclient -L localhost
      OR
#testparm


CLIENT SIDE (LINUX)


INSTALL THE PACKAGE

1.      You just need to install the samba-client package

# yum install samba-client
# yum install cifs-libs
      
2.  Make sure that the folder you want to share is visible

#  smbclient –L 192.168.6.232

3.  Create file for storing the username and password for samba client

# vim /root/pass.txt

username=harry
password=redhat ( write the password which you kept in the server side) (No Space)

MOUNTING THE SAMBA SHARE IN LINUX

# vim /etc/fstab
//192.168.6.232/local        /mnt    cifs    credentials=/root/pass.txt,sec=ntlmssp  0 0 

CHECK THE FOLDER

We will need to first create user harry in our client end 

# useradd harry
# passwd harry
New Password : 
Retype new Password : 

After we create a user then we will need to switch our user from root to user Harry

# su - harry

# cifscreds add 192.168.6.232

# cd /mnt

Then we can create a file inside /mnt which is the folder where we have mounted for our folder /local .

# touch file1

The file which we have recently created should have the user and group permission of the user Harry and our tasks finally gets completed .

CLIENT SIDE (WINDOWS)


The folder can also be shared in windows which we have already discussed about it earlier. In order to mount the folder in Windows PC go to MY PC and the choose Computer then map the network drive . After that we will need to assign a letter for the drive to be mapped check the box where it is written "Connect using different credentials". You can check the screenshot which I have captured below


We can create a file and check the permission for the created file in our linux server  . The file permission should belong to user Harry. 


CONCLUSION

In the above article we have discussed about how we can share folder in linux as well as windows platform using samba multiusers share. We have also learned about managing firewall, selinux as well as accessing the folder with  an particular user .

Please, feel free to drop a comment using the form below if you have any comments or suggestions.

Comments

Popular posts from this blog

High Availability Palo Alto (Active/Standby)

 High Availability is usually performed in most of the data centers networks today which ensures application availability . High Availability is usually achieved in case one of the appliance goes down or have some physical or logical connectivity issues.  Achieving high availability in Palo Alto firewall is relatively very easy. Palo Alto firewall can work in both Active/Standby mode or in Active/Active. We will basically be talking about Active/Standby mode in this article. There are basically two links that needs to be configure in Palo Alto for HA. 1. Control Links Control Links are associated with control plane traffic which is mainly used for heartbeat exchanged, configuration synchronization. Dedicate HA ports are available in higher series of Palo Alto or even a HA interface can be created for some inband ports.   2. Data Links Data Links are mainly used for session synchronization, forwarding table synchronization. Dedicated HSCI Ports are available for highe...

SSL Decryption FortiGate

  We have pretty much heard about SSL decryption and of malware hiding inside an encrypted traffic. A large amount of traffic in the internet is pretty much encrypted which basically means that bad things like malware, virus, ransomware can hide inside this encrypted traffic. If majority of these traffic are encrypted our Firewalls are not able to analyze these traffic which can easily infect our organization and the investment which we have done in these firewalls are wasted. There does come around a solution for this and as my topic suggest SSL Decryption also know as Deep Packet Inspection as by some IT folks. The image that I have attached down below clearly suggest about what I am trying to explain. Using deep packet inspection, the firewall simply decrypts the encrypted traffic happening  between client and server, inspects the content to find the threats and block them , then forwards it to the destination re-encrypting it . We will need to first setup the SSL/SSH in...

Virtual Chassis Juniper EX 3400 (PREPROVISONED)

Juniper has always been an technology that I have always liked right from the beginning of my career when I was working as an Jr Network Administrator. The logical command as well as the hierarchy based Juniper devices has always made me love the device. Let me today talk about a very useful and an interesting topic which we usually called stack in the world of Cisco and virtual chassis in the world of Juniper, both of them mean the same thing logically make two or more than two switch as a one and configure and manage the device as a single unity. High Availability, managed configuration and maintenance are few of the benefits that a virtual chassis can provide. The configuration for virtual chassis can be found easily in the juniper sites but my objective about writing this is making it more simpler in context to Juniper's document. There are basically two ways of configuring virtual chassis in Juniper. 1.   Nonprovisioned configuration  :  The master switch assig...