Practices for Lesson 7: Overview
Practice 7-2: Accessing Samba Shares from a Client Host
Overview
In this practice, you do the following:
• Access the Samba shares that you set up on host03 in the previous practice, from
host01, which acts as an Oracle Linux Samba client.
• Mount and unmount a Samba share on host01.
Assumptions
All steps are performed from the host01 VM except where indicated.
Tasks
1. Install the samba-client package on host01.
a. If necessary, open a new terminal window on dom0.
b. Use the su - command to become the root user on dom0. • The root password is oracle.
[dom0]$ su – Password: oracle
c. As the root user on dom0, use the ssh command to log in to host01. • The root password is oracle.
[dom0]# ssh host01
root@host01's password: oracle Last login: ...
d. From host01, use the yum command to install the samba-client package.
• Answer y to “Is this ok.”
[host01]# yum install samba-client ...
Is this ok [y/N]: y ...
Complete!
2. From host01, access the Samba shares on host03 as user user01.
a. Use the smbclient command to access the /tmp directory on host03. • The Samba password for user01 is MyOracle1.
[host01]# smbclient //host03/tmp -U user01 Enter user01's password: MyOracle1
Domain=[GROUPA] OS=[Unix] Server=[Samba 4.1.12] smb: \>
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
b. If the smbclient command returns “session setup failed:
NT_STATUS_LOGON_FAILURE,” use the systemctl command on host03 to restart the smb service.
• After restarting the smb service, run the smbclient command in step 2a again. [host03]# systemctl restart smb
c. At the smb: prompt on host01, use the ls command to list the files in the /tmp directory on host03. smb: \> ls . D 0 ... .. DR 0 ... ... smb: \>
d. Use the exit command to exit the smb session on host01. smb: \> exit
e. Use the smbclient command to access the home directory for user user01 on
host03.
• The Samba password for user01 is MyOracle1.
[host01]# smbclient //host03/user01 -U user01 Enter user01's password: MyOracle1
Domain=[GROUPA] OS=[Unix] Server=[Samba 4.1.12] smb: \>
f. Use the ls command to list the files in the home directory for user user01. • The command fails because SELinux is in “Enforcing” mode.
• SELinux is covered in a subsequent lesson in this course. smb: \> ls
NT_STATUS_ACCESS_DENIED listing \* smb: \>
g. Use the exit command to exit the smb session. smb: \> exit
h. To allow Samba users access to their home directories, set SELinux to “Permissive” mode on host03.
• You could configure SELinux to allow Samba users to access their home
directories; however, for the purposes of this practice, set SELinux to “Permissive” mode. [host03]# getenforce Enforcing [host03]# setenforce 0 [host03]# getenforce Permissive
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Practices for Lesson 7: Samba Services
i. On host01, re-issue the smbclient command to access the home directory for user
user01 on host03.
• The Samba password for user01 is MyOracle1.
[host01]# smbclient //host03/user01 -U user01 Enter user01's password: MyOracle1
Domain=[GROUPA] OS=[Unix] Server=[Samba 4.1.12] smb: \>
j. Use the ls command to list the files in the home directory for user user01.
• Because of the change in the SELinux mode, you can now list and access the files in user01’s home directory.
smb: \> ls . D ... .. D ... .mozilla DH ... .bash_logout H ... .bash_profile H ... .bashrc H ... ... smb: \>
k. Use the exit command to exit the smb session. smb: \> exit
3. On host01, mount and unmount a Samba share from your Oracle Linux client.
a. On host01, create a mount point for user01’s home directory.
[host01]# mkdir /homedir
b. Use the yum command to install the cifs-utils package. • Answer y to “Is this ok.”
[host01]# yum install cifs-utils ...
Is this ok [y/N]: y ...
Complete!
c. Use the mount.cifs command to mount user01’s home directory on the newly created mount point.
• Specify read-only in the mount options.
• The Samba password for user01 is MyOracle1.
[host01]# mount.cifs -o username=user01,ro //host03/user01
/homedir
Password for user01@//host03/user01: MyOracle1
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
d. Use the df -hT command to verify that the mount operation was successful. • Notice that the file system type for //host03/user01 is cifs.
[host01]# df -hT
Filesystem Type Size Used Avail Use% Mounted on ...
//host03/user01 cifs 11G 3.2G 7.1G 32% /homedir e. Verify that the /homedir directory is read-only by using the mount command.
[host01]# mount | grep homedir
//host03/user01 on /homedir type cifs (ro,relatime,vers=1.0...) f. List the contents of /homedir.
[host01]# ls /homedir
• Notice that the directory is empty.
g. On host03, use the touch command to create the /home/user01/testfile file.
[host03]# touch /home/user01/testfile h. On host01, list the contents of /homedir.
• Notice that the testfile can now be seen from host01. [host01]# ls /homedir
testfile
i. On host01, use the umount command to unmount the Samba share.
• Using the cd command ensures you are not in the /homedir directory. [host01]# cd
[host01]# umount /homedir
j. Use the exit command to log off host01. [host01]# exit
logout
Connection to host01 closed. k. Set SELinux to “Enforcing” mode on host03.
[host03]# getenforce Permissive
[host03]# setenforce 1 [host03]# getenforce Enforcing
l. Use the systemctl poweroff command to shut down host03. • You are instructed to shut down host03 in preparation for Practice 8.
[host03]# systemctl poweroff ...
juan corso arias (juanฺcorso@unimilitarฺeduฺco) has a
non-transferable license to use this Student Guideฺ
Copyright © 2015, Oracle and/or its affiliates. All rights reserved. Practices for Lesson 7: Samba Services