In this lab, you will install packages to support automounting CIFS shares and create three automounts.
| Resources: | |
|---|---|
| Files: |
samba.txt in each share directory, for testing. |
| Machines: | desktopX and serverX |
Outcomes:
Installation of at least two packages to support automounting Samba shares.
Automount /shares/work with authenticated, RW
access to your home directory on serverX.
Automount /shares/docs with RO guest access to
the public share.
Automount /shares/cases with authenticated, RW
access to restricted team share bakerst.
Available persistently after a reboot.
If you haven't already done so at start of the previous exercise:
Reset your serverX system.
Log into and set up your server system.
[student@serverX ~]$lab samba setup
Always perform this step:
Reset your desktopX system.
Log into desktopX and open a terminal.
Your company runs a Samba service on serverX to provide document sharing for both Red Hat Enterprise Linux and Microsoft Windows clients. The server contains a directory for each user to store their personal documents, a publicly available read-only directory for common documents, and a number of team directories to host collaborative documents.
You may need to perform some basic user and group administration on desktopX to ensure
student can access files on all of the shares.
Here are the key details from serverX that you will need:
Username: student
Password: student
Group membership: bakerst, GID=10221
Domain: MYGROUP
Home shares are enabled and writeable.
desktopX mount point: /shares/work
There is a share called public that only requires guest privileges to
access.
desktopX mount point: /shares/docs
Your team has a private, writeable share called bakerst that is only
accessible to members of the bakerst group.
desktopX mount point: /shares/cases
When you are done, reboot your desktopX machine, then run the
command lab samba grade from your desktopX machine to
verify your work.
Install the two packages needed to automount a CIFS file system.
Add an auto.master.d configuration file that identifies the base
directory and associated map file (use any name you like for the configuration file, but
it must end with .autofs), and create the associated map file (use any
name you like for the map file), ensuring proper authentication on each mount. As
needed, you can create other configuration files to support the automount mapping
configuration.
Use vim to create and edit the
/etc/auto.master.d/shares.autofs file.
[student@desktopX ~]$sudo vim /etc/auto.master.d/shares.autofs
Add the following line:
/shares /etc/auto.shares
This solution is using shares.autofs as the master map file
and auto.shares as the map file, but the file names are not
important.
Use vim to create the auto.shares map
file.
[student@desktopX ~]$sudo vim /etc/auto.shares
Add the following lines:
work -fstype=cifs,credentials=/etc/me.cred ://serverX/student docs -fstype=cifs,guest ://serverX/public cases -fstype=cifs,credentials=/etc/me.cred ://serverX/bakerst
An alternative to the credentials file (and the steps shown here to create and
edit it) would be to substitute the credentials=/etc/me.cred entry in
the auto.shares file with two entries,
username=student,password=student, but that would be less
secure.
Use vim to create the credentials file.
[student@desktopX ~]$sudo vim /etc/me.cred
Add the following lines:
username=student password=student domain=MYGROUP
Use chmod to secure the credentials file.
[student@desktopX ~]$sudo chmod 600 /etc/me.cred
This step is not essential for this lab, but shown for completeness.
Ensure that username student has the correct UID and GIDs to access each
of the shares (Hint: bakerst). If necessary, add any new
groups that are needed, modify student's group membership, or both.
Note: If you add a new group to student's
supplementary groups, then you will either need to exit the shell and start a new shell,
or use newgrp groupname to switch to the
newly added group. This is necessary because the environment Bash starts with does not get
updated with student's new details.
Use the groups command to check the current group
memberships for the student user.
[student@desktopX ~]$groupsstudent
The student account does not belong to the
bakerst group (GID 10221) and
will need to be added.
Check if the bakerst group exists on
desktopX. Use grep to check the
/etc/group file.
[student@desktopX ~]$grep -e bakerst -e 10221 /etc/group
The bakerst group does not exist either; it will need to be added
first.
Use groupadd to add the bakerst group with GID
10221.
[student@desktopX ~]$sudo groupadd -g 10221 bakerst
Use usermod to add the bakerst group to
student as a supplementary group.
[student@desktopX ~]$sudo usermod -aG bakerst student
This approach is not typically the best solution to align UID and GID values, as there are mount options that can handle this. However, it is a suitable solution for this lab, and you get to practice some user and group administration skills.
Use newgrp to switch to bakerst.
[student@desktopX ~]$newgrp bakerst
Enable and start the automount service.
Check that you can access each share and write to those shares you have write
privileges on, work and cases.
There is a file called samba.txt that contains the message
"Success" in each of the share locations. Use
cat samba.txt.
Use echo testing > my.txt to test if you can write to
a directory.
Check you can read and write in work:
[student@desktopX ~]$cd /shares/work[student@desktopX work]$cat samba.txtSuccess[student@desktopX work]$echo testing > my.txt
Check you can read, but not write, in docs:
[student@desktopX work]$cd ../docs[student@desktopX docs]$cat samba.txtSuccess[student@desktopX docs]$echo testing > my.txtbash: my.txt: Permission denied
Check you can read and write in cases:
[student@desktopX docs]$cd ../cases[student@desktopX cases]$cat samba.txtSuccess[student@desktopX cases]$echo testing > my.txt
When you are done, reboot your desktopX machine, then run the
command lab samba grade from your desktopX machine to
verify your work.