1,234
edits
Changes
→Using Nautilus to browse Samba shares
This lab will first install, setup, and enable a Samba server. Then users will access files on the Linux Samba server from Linux and Windows client machines (both graphically and command line).
==OVERVIEWINVESTIGATION 1: INSTALLING & CONFIGURING A SAMBA SERVER==
In this labinvestigation, we will look at several separate technologies that are used with the Apache web set up a '''Samba server to ''' on our '''VM2''' machine. We will first install, configure and run web applicationsenable the samba server on our virtual machine, and then we will quickly test to see if the Samba server works.
'''Perform the following steps:'''
#Make certain you are in that both your '''VM4VM1''' machine.#Install the Apache package (the name of the package is: and '''httpdVM2''').#Start the httpd service, and enable this service to start automatically upon system startupmachines are running.#Make certain Switch to configure your firewall to allow access to the httpd service (i.e. the Apache serves HTTP traffic which goes over TCP port '''80VM2''').#Open a web-browser in your machine as the '''hostroot''' machine and enter user.#Issue the following URLLinux command to install Samba server utlity: <br>'''vm4.youruserid.orgyum install samba samba-client'''.<br>If you setup your Apache webserver correctly, you should be able to view the Apache Test page.#Delete Copy the file '''/etc/httpdsamba/smb.conf''' to another filename by issuing the following command:<br>'''cp /etc/samba/smb.dconf /etc/samba/welcomesmb.conf.original''' to remove the default webpage.#Although we will not be exploring webservers in depth, we will have you create a simple webpage for testing purposes, then later setup a web resource for webmailClear the contents of the configuration file by running '''cat /dev/null > /etc/samba/smb.conf'''#The termEdit '''DocumentRoot/etc/samba/smb.conf''' specifies where so that the file that contains the Apache webserver will search for documents following lines: [global] workgroup = WORKGROUP server string = "put your real name here without the quotes" encrypt passwords = yes security = user passdb backend = tdbsam [home] comment = "put your real name here without the quotes" path = /home/<yourSenecaID> public = no writable = yes printable = no create mask = 0765 [homes] comment = automatic home share public = no writable = yes printable = no create mask = 0765 browseable = no<ol><li value="3">Append (add) the following parameter to serve. Create the file bottom of the '''index.html[global] section''' that will limit access to the share so that only machines in your virtual network will be able to access it:</li></ol> hosts allow = 192.168.x. 127.0.0.1<ol><li value="4">Append (add) the following parameter to the '''DocumentRoot[home] section''' directory with the following contents (replace the date with the current one)so that only your user account can access that share:</li></ol> valid users = <yourSenecaID><preol><li value="5">Hello, this is Create a web page on vm4.yourid.org Samba account and password for yourSenecaID by issuing the current time is Mar 28 22following command:16:27 EDT 2016!<br>'''smbpasswd -a <yourSenecaID>'''</li></preol>
<ol><li value="6">Confirm the user you created has been added using the following command:<br>'''pdbedit -L -v'''</li><li>Test and review your configuration with the command:<br>'''testparm'''</li><li>Use the '''systemctl''' command to start the smb.service and enable the service to run on boot-up</li><li>If you have SELinux set to enforcing, you'll will need to tell it to allow samba access to home directories by running: <br> '''setsebool -P samba_enable_home_dirs 1'''</li><li>Use the '''ss -nautp''' command to see with port Samba is running on.</li><li>Use the information in the previous step to modify the firewall on VM2 machine to allow samba traffic.</li><li>Test to see that you can connect to your Samba server (locally) by issuing the following command:<br>'''smbclient -U <yourSenecaID> -L 127.0.0.1'''</li><li>When prompted, enter your Samba account password.</li><li>The output from that issued command show appear similar to example displayed below:</li></ol>
Sharename Type Comment
--------- ---- -------
home Disk Your Name
IPC$ IPC IPC Service ("Your Name")
Domain=[WORKGROUP] OS=[Windows 6.1] Server=[Samba 4.2.3]
Server Comment
------ -------
WorkGroup Master
--------- ------
<ol><li value="13">To access the Samba client shell on your local Samba share, issue the following command:<br>'''smbclient '\\127.0.0.1\home' -U <yourSenecaID>'''</li><li>Enter your Samba account password.</li><li>Issue the help command to note common commands (''dir'', ''cd'', ''ls'', ''put'', ''get''). Note how similar they are to ''sftp'' commands.</li><li>Enter '''exit''' to terminal your local Samba session.</li></ol>
'''Record steps, commands, and your observations in INVESTIGATION 1 in your OPS335 lab log-book'''
'''Perform the following steps:on your VM1'''
#Replace our Install the '''samba-client''index.html' and ''' file with an cifs-utils'''indexpackages.php#Use the "smbclient" command in a terminal window.<source> smbclient '\\vm2\home'' with -U <yourSenecaID></source>#After entering your password you should get a prompt similar to:<source> smb: \></source>#Enter the ls command to see a list of the following contentsfiles in your home directory:<source> smb: \> ls</source>#Once you have access to the directory use the get and put commands (similar to ftp) to move files.#When you are finished close the connection.# Try again using '''[homes]''' share instead<source> smbclient '\\vm2\homes' -U <yourSenecaID></source>
# Make certain that your '''VM2''' machine is running, is still allowing samba traffic through the firewall, and is still running the samba service.# Use the Windows machine you are already running Vmware on. If you have a Linux host - good for you, you can either use a Windows VM or skip this part.# Add the prerouting and forwarding rules to your host's iptables necessary to redirect samba traffic from outside your network to your VM2, making sure to replace the X with your own network address.::* Be careful about copy<code>iptables -I FORWARD -p tcp --dport 139 -d 192.168.X.3 -j ACCEPT</code>::<code>iptables -I FORWARD -p tcp --dport 445 -d 192.168.X.3 -j ACCEPT</code>::<code>iptables -pasting the MySQL setup part, don't try nat -A PREROUTING -p tcp --dport 139 -j DNAT --to rush it-destination 192.168.X.3</code>::* You'll need <code>iptables -t nat -A PREROUTING -p tcp --dport 445 -j DNAT --to install a couple more Apache modules-destination 192.168.X.3</code>OR with specifing the interface (whichever works)::: php<code>iptables -t nat -A PREROUTING -i *externalinterface* -p tcp --dport 139 -j DNAT -xml, php-pdo, and phpto-mysqldestination 192.168.X.3</code>::<code>iptables -t nat -A PREROUTING -i *externalinterface* -p tcp --dport 445 -j DNAT --to-destination 192.168.X.3</code>where * Donexternalinterface* is an interface name (e.g. ens33)<br>'''NOTE:''' when you restart libvirtd, it will move your FORWARD rules to the end of the chain, invalidating them.# Modify the '''hosts allow''' setting on your '''vm2'''t forget to set also accept connections from the password in windows machine you are using.# Open the roundcube configurationWindows File Explorer application.# At the top of the application, enter the following:<br>'''\\EXTERNAL_IPADDR_OF_HOST\home'''
|- valign="top"|[[Image::* $config[samba-login.png|thumb|right|300px|You will be prompted (once only) for the Samba user-name and password for your '''VM2''smtp_server'machine). ]]|[[Image::* $config[samba3-map-drive.png|thumb|right|300px|You can create a ''default_host']mapped network drive (z::* $config[)''default_port'for your Linux Samba server network share). ]]|}
<ol><li value="5"> You will be prompted to enter your samba username and password (one time only). Refer to screenshot on right.<br><br>'''NOTE:::(''' It may take approximately 30 seconds to display the file contents.<br><br></li><li>Were you successful? You should have received an error stating the last two your credentials are incorrect. You will notice that it adds SENEDS to the beginning of your IMAP serveruser name, as the Seneca machine is pre-configured to be part of that workgroup.</li><li>Change the workgroup parameter in smb.conf on VM2 to match the seneca domain SENEDS, and try to connect again.</li><li>Were you successful? If not, try to troubleshoot the problem first, then ask your lab assistant or instructor for assistance.</li><li>Close the Windows File Explorer application window.</li><li>Click on the '''START''' menu, and click on '''This PC'''.</li><li>Click on the Map Network Drive button, and create a '''mapped network drive''' (called it drive '''Z:''')which is a Samba share of your VM2 machine for the home directory.</li><li>When finished, click on '''Network''' in Windows file manager to confirm that the network share is present.</li><li>Try to create a file on Windows on your Linux Samba machine. Were you able to create a save a file?</li><li>Switch to your VM2 machine and check to see if that file was created in your home directory.</li></ol>
{{Admon/important |Backup your VMs!|You MUST perform a '''full backup''' of ALL of your VMs whenever you complete your '''OPS335 labs''' or when working on your '''OPS335 assignments'''. You should be using the dump or rsync command VMs.}}
== COMPLETING THE LAB ==In completing this lab you have gained experience using a service that allows remote access to files stored on a Linux server. You have also learned how to use several different tools to access those files, both from a Linux and Windows client..
::<span style="color:green;font-size:1.5em;">✓</span> Proof of network share of VM2 machine from Windows VM via Windows Explorer application
::<span style="color:green;font-size:1.5em;">✓</span> Firewall settings on your Windows VM to allow Linux Samba network share
::<span style="color:green;font-size:1.5em;">✓</span> Display contents of '''/etc/samba/smb.conf''' file on VM2 machine
::<span style="color:green;font-size:1.5em;">✓</span> Firewall exceptions (both machines) to allow Samba traffic
::<span style="color:green;font-size:1.5em;">✓</span>Download and run '''https://ict.senecacollege.ca/~andrew.smith/ops335/labcheck5.bash'''
::<span style="color:green;font-size:1.5em;">✓</span>Completed Lab5 log-book notes.
-->
==EXPLORATION QUESTIONS==
#What does SMB stand for?#What does CIFS stand for?#What is the purpose of the '''testparm''' command?#What does the text inside square brackets in the '''smb.conf''' file mean? (e.g., "[home]").#Explain the meaning of the line "create mask = 0765" in the smb.conf file?#What does the '''smbpasswd''' command do?