Implement SAMBA (CIFS) Fileshares for Servers and Clients

1 hour
  • 7 Learning Objectives

About this Hands-on Lab

Implementing fileshares for Windows and Linux servers, plus clients is a key skill for any experienced system administrator. In this activity, we will be working to set up a Linux Samba fileshare that can then be used by a remote client to store files on. Once this activity is completed, we will see how Samba can be used to provision a fileshare for use via a Linux client.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install Samba Packages on the Samba Server

We will need several packages installed on our server to complete this activity. Install the packages needed via:

sudo yum install -y samba samba-client cifs-utils
Install Samba Packages on the Samba Client Server

Similar to the server install, we will need to install some packages on the client in order to use the share we are making available from the server. We can execute the package installation with:

sudo yum install -y samba samba-client cifs-utils   
Create the Server Fileshare and Set Universal Read/Write Permissions

On the server, we are tasked with creating the fileshare location for our development team’s documentation. Easily accomplished with:

sudo mkdir /devdocs

We can meet the accessibility requirement with the following command:

sudo chmod 777 /devdocs
Allow Network and Users to Access the Share

Our private network is on 10.0.1.0/24 and you have a test user that we will be configuring access to this fileshare via the Samba server configuration file located at /etc/samba/smb.conf — we will need to edit the following values in the [global] section of that file so they appear as follows:

security = user
hosts allow = 127. 10.0.1.
interfaces = lo eth0
passdb backend = smbpasswd:/etc/samba/sambapasswd.txt

Additionally, we will need to add a new section at the end of the configuration file for our share. We can accomplish this by adding the following values:

[devdocs]
        comment = Development documentation
        read only = no
        available = yes
        path = /devdocs
        public = yes
        valid users = devdocsuser
        write list = devdocsuser
        writable = yes
        browseable = yes

Optionally, once saved, we can perform a quick test with:

sudo testparm
Start the Samba Service

Enable and start smb:

sudo systemctl enable smb
sudo systemctl start smb
Make the Local Mount Directory on the Samba Client and Set Universal Permissions

Run the following to establish the mount directory:

sudo mkdir /mnt/devdocs

Set up permissions with:

sudo chmod 777 /mnt/devdocs/
Test the Server Mount on the Client System via the Command Line

We will need to provide a string of options to the mount command to test our access:

sudo mount -t cifs -o user=devdocsuser,password=devdocs //10.0.1.100/devdocs /mnt/devdocs/

Once mounted, we can check via df -h to see it in the list of mounted filesystems and we should be able to write a file and read it on either client or server system

Additional Resources

You will be presented with two CentOS 7 Servers in this Learning Activity:

  1. CentOS 7 Samba SERVER
  2. CentOS 7 Samba Client

Once provisioned the username, password and IP address, start by connecting to the SERVER instance and then launch your Activity Guide below for instructions on completing the activity.

While working within your company's engineering department, you are part of a team supporting the development and implementation of a new set of APIs. As your team builds the development environment, the development team is looking for a place to share the documentation they will be creating during the development process. They have requested a file server that they can use to do so.

You have been given the credentials for two systems; the first is intended to be the file server. It is a CentOS 7 system and you will find that once you are logged into the public IP, the private IP has been set statically to 10.0.1.100. The second system, intended to be used to test the file share as a client, is also a CentOS 7 system. Once you are connected to that server on the public IP, you will find a private IP set statically there at 10.0.1.101.

The development team has asked that a fileshare be set up that is world readable/writable on the server, call that share directory /devdocs (at the root of the filesystem). Change the permissions on that directory as appropriate to meet their universal access requirements. You will then need to install the necessary Samba server packages to make that filesystem available to clients. The development team would like anyone with the name in the list below to be able to connect using the password devdocs.

Accounts for Fileshare Access

  • devdocuser

Note: When adding the username and password, be sure you are using the standard password file /etc/samba/smbpasswd.txt in your configuration and to manage the account credentials. Once you have completed the configuration of the server, be sure to test the configuration and, assuming it passes, enable and start the service on the file server.

Once you have completed the necessary server setup, log into the test client system and create a mount for that directory called /mnt/devdocs. Mount that remote filesystem at the command line, using the appropriate connection options and filesystem type. Make sure once logged in as one of the users; you can read and write files to that location. Once you have verified the filesystem is available and has the appropriate permissions, you can turn the system over for their use.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Get Started
Who’s going to be learning?

How many seats do you need?

  • $499 USD per seat per year
  • Billed Annually
  • Renews in 12 months

Ready to accelerate learning?

For over 25 licenses, a member of our sales team will walk you through a custom tailored solution for your business.


$2,495.00

Checkout
Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!