Setup Samba Server
Linux Samba

How To Setup SAMBA Server Share On RHEL/CentOS 6/7 For Linux/Windows Hosts

Before Getting Start, Know About SAMBA

Well, when it comes to file sharing between windows user or Linux user or file sharing for Linux -Linux user then SAMBA comes into the picture. Samba is a free/open source and popularly used for the same work of file sharing and printing services between Unix-like systems including Linux and Windows host.

In this article, we will setup Samba4 for file sharing for Linux and Windows hosts machines. Also, we will learn password protected mode i.e secure mode and anonymous (unsecured) for SAMBA.

Scenario:

Host OS: CentOS/RHEL 6/7
Host IP: 192.168.1.19
RAM: 4GB Memory

Note: If you are a SUDO user then prefix every command with sudo, like #sudo ifconfig

Let’s Start

STEP 1: Install Samba Packages

To install required packages and dependencies to set up use the following yum command

STEP 2: Adding Exception For SAMBA In Firewall

This is a requirement when you have a running firewall so if you are not running firewall-cmd then you may skip this step else add samba service in the firewall.

STEP 3: Getting Windows Host Work Group

Well, to create a configuration for windows hosts we need to get the windows Machine “Workgroup” settings. So, log into your windows machine and hit the Following commands

Getting workgroup Name

STEP 4: Creating SAMBA Share Directory

Before configuring samba take a backup for default SAMBA configuration file “/etc/samba/smb.conf” by the following command

To use a shared directory without any password i.e. non-secured use the following command to create a shared directory with appropriate permission.

Also, if you have SELinux enabled then set up the context for the samba and turn the samba_enable_home_dirs Boolean on if you want to share home directories via Samba.

STEP 5: Configuring SAMBA Secure And Non-Secure Shares

Here in this step, we will step up both secure and non-secure samba share so firstly let’s start with configuring non-secure samba share.

5.1-Configuring SAMA NON- SECURE

To set up non-secure samba share follow 3 simple steps and you are done.

  1. Now edit the samba configuration file and append given configuration.

  1. Now, append the following line in this configuration file

save and quit using ESC :wq! .  Well you may verify the configuration with given command and if you find any issue fix that issue and proceed

3. The final step in this section is to restart the service and enabling samba to start up automatically after any reboot.

You may check status of the running service by these commands

Note: We Will test our work in step 6 and if you want to test it right now then you may move to step 6 right now.

5.2-Configuring SECURE SAMBA Share

To set up secure samba share follow 4 simple steps and you are done.

1. Create a group for the authorized users e.g. sambauser system group, and then add users to the group and set a password for each user.

2. Now create the directory in /var/samba to mentioned in samba secure configuration. Also, setup permissions and SELinux context as well using following commands.

3. Now, append the following line in samba configuration to make it available for accessing files by editing smb.conf

Now, append the following line in this configuration file

save and quit using ESC :wq! .  Well you may verify the configuration with given command and if you find any issue fix that issue and proceed

4. Now, restart the service to make the changes in effect.

STEP 6: Verifying Your Work

Well, we have done configuration for secured and non-secured samba share. Now, we need to check these configurations. So again, you need to login into your window host and follow some simple steps. Firstly, we will check the non-secure samba share.

6.1 Test Non-Secure Samba File Sharing

1. First Login to your windows host and try to access the samba server using its IP address

2. Now you will see directories by name ALL(i.e. Non Secure Samba Share) and Secure(i.e. Secures Samba share). Click on ALL to access content and any user may create or delete content in this non-secure share.

 So after clicking on this ALL dir you will be able to create your stuff and anyone may add up content.

6.2 Test secure Samba File Sharing

1. First Login to your windows host and try to access the samba server using its IP address

2. Now you will see directories by name ALL(i.e. Non Secure Samba Share) and Secure(i.e. Secures Samba share). Click on Secure to access content, only authorized user may create or delete content in this secure share.

Now here is the change, in secure samba share you will be prompted for username and password to login your samba server. So, click ok after entering credentials.

Once you are logged in, you will we able to see all see all the samba shared directories.

NOTE:- Though you see all samba shared directories you will be able to access only those directories to which you are authorized to see.

Read About Access SAMBA Share on Linux In Next Article

Kapendra
Love to write technical stuff with personal experience as I am working as a Sr. Linux Admin. and every day is a learning day and Trust me being tech geek is really cool.
http://kapendra.com

Leave a Reply