Do This Lab With Your Fast Private Cloud Remote VMS.: Lesson 5 Exercises
Do This Lab With Your Fast Private Cloud Remote VMS.: Lesson 5 Exercises
Do This Lab With Your Fast Private Cloud Remote VMS.: Lesson 5 Exercises
Lesson 5 Exercises
Part 5.1 – Networking (Assigning static and dynamic IP Addresses) (documentation:
https://ubuntu.com/server/docs/network-configuration & https://ubuntu.com/server/docs/network-dhcp)
IMPORTANT: most likely Linux will name your network interface card using the “ens##” naming
convention (where ## is a number). You can verify the names by running the ‘ip’ command. (An older
naming convention used “eth#” for NICs). This example shows two interfaces named ‘ens33’ and
‘ens37’ with their IP addresses.
Start the Desktop and Server01 VMs. These VMs are already on the same subnet. Do all your work at the
Command Line. View the ‘man’ page for the ‘ping’ command. At the Desktop, ping Server01 (this command
runs non-stop – press ‘Ctrl-C’ to stop it). Then ping Desktop from Server01.
YES
b) Put here the screenshot of the ping from Desktop.
c) View the ‘man’ page for the ‘ip’ command. Check the IP information on both VMs. A short form of the
above “ip address show” command is “ip a”. Put a screenshot of your result at the Desktop:
d) Identify the interface used by Desktop:
ens160
2) With the ‘ip’ command. This method is temporary – the address is not retained in a reboot, but
reverts back to the address specified by netplan.
Note: Due to settings in the FAST private cloud, if we change the Desktop’s IP address, we can no longer
access it with an SSH Client or the ‘nomachine’ client. So the ‘vcenter’ site with a browser must be used.
5.1.6 After the VM reboots, use ‘ip’ to verify it has the new address.
Put a screenshot here showing its output:
5.1.7 Verify Desktop can ping Server01 and vice-versa.
5.1.8 At Desktop, first we delete the …100 address: sudo ip a del 192.168.10.100/24 dev ens160
(if your interface has a name other than ens160, insert your interface name)
5.1.9 Add a different address (use 101): sudo ip a add 192.168.10.101/24 dev ens160
5.1.10 Verify you have the new address, then verify Desktop can ping Server01 and vice-versa. Show the ping
from Server01:
It may help for you to review your Networking course notes on how DHCP works, before you do this section.
5.1.11 First we must install DHCP Server on the Server01 VM (Server02 VM could also be used – for these
steps, we’ll stick with Server01). Start Server01 and run: sudo apt-get install isc-dhcp-server -y - to do
the install.
5.1.12.5 Find and change the lease times to 8 minutes (480s) – (this is just for testing – more common
times are 2 hrs, 1 day or 1 week)
default-lease-time 480;
max-lease-time 480;
5.1.12.7 Specify the network address and subnet-mask: Go to the end of the file and add these lines:
(use these addresses and masks)
5.1.14 The Desktop VM still has a statically set IP address. We must switch it to use DHCP. Start the VM from
a browser at ‘vcenter…’ (if you use SSH Client or ‘nomachine’ client now to connect, you will lose the
connection once DHCP switches the IP address away from the 192.168.10.13 address).
5.1.15 Edit the 99-netcfg-vmware.yaml file so that you have: dhcp4: yes (you can leave the
dhcp6: no line). Delete all the following lines.
5.1.17 Verify its IP address is now in the range chosen: 192.168.10.105 – 115 - Put a screenshot showing
this new address:
5.1.18 Run: netplan ip leases ens160 (substitute your interface name). Put a screenshot of its output:
5.1.20 From Server01, ping the Desktop. Put a screenshot of the ping:
5.1.21 Also from Server01, run: dhcp-lease-list - put a screenshot of its output:
5.1.22 View the dhcpd.leases file in /var/lib/dhcp - after 20 minutes, how many leases are in this file? Put
a screenshot of one of the leases here:
We are done reviewing DHCP. Now we must statically set Desktop’s IP address back to the original and
disable the DHCP Server.
5.1.26 You previously created the backup file 99-netcfg-vmware.yaml.bak, now rename it back to the original
name so netplan will use it: sudo mv 99-netcfg-vmware.yaml.bak 99-netcfg-vmware.yaml
This part is like the Samba tool in that it involves an NFS Server (server01) making NFS shares available to
NFS Clients (our test will use only ‘Desktop’).
STEPS
5.2.1 On your SERVER01 (the NFS server): Login with your default user (for ex: vmadmin), create the ‘nfs-
test’ and
‘nfs-test/data’ directories below your home directory and add a file myfile.txt (with text) to the data directory.
(replace USERNAME and ClientIP with your values – for ClientIP, use the IP address of your client
[DESKTOP] – note the SPACE(s) before ClientIP).
Note the ‘rw’. We are giving clients read/write access to these folders. Put a screenshot of the lines of this file:
5.2.5 On your NFS Client machine (DESKTOP), install nfs-client: sudo apt-get install nfs-common
5.2.7 Load the nfs module (at the client): sudo modprobe nfs
5.2.8 At the NFS Server, restart nfs server: sudo systemctl restart nfs-kernel-server …or
sudo /etc/init.d/nfs-kernel-server restart
5.2.9 At the client, create the directory /media/nfs-share for mounting the nfs share (you may choose any
name or location – ‘/media’ is often used), then issue the following command to mount SERVER01’s nfs share
– run this from DESKTOP: sudo mount -t nfs ServerIP:/data /media/nfs-share (replace ServerIP
with your SERVER01’s IP address – ‘data’ is the directory you entered in ‘exports’ file)
5.2.10 Run df -h and mount commands to verify DESKTOP has accessed the share. Put a screenshot of
these commands:
.
5.2.11 Go to /media/nfs-share directory at the client and verify that you can see the file that you created in
/home/USERNAME/nfs-test/data folder. Verify you can create a file in SERVER01 and it is readable in
DESKTOP, then, you can create a file in DESKTOP and it is readable in SERVER01. Put screenshots
showing:
- the files in both VMs (‘nfs-share’ and ‘data’)
- you created a file in nfs-share and it is readable in data
- you created a file in data and it is readable in nfs-share
5.2.12 When done, from DESKTOP, leave the directory and unmount this filesystem:
sudo umount /media/nfs-share
5.2.13 Stop the NFS service on the server: sudo systemctl stop nfs-kernel-server …or
sudo /etc/init.d/nfs-kernel-server stop
Insert here the history of your Linux session on both VMs for this Part 5.2 (NFS Share) ONLY (not your entire
history file!).
cl
e
Lesson 7 Exercises
The Secure Shell (SSH) protocol is the Application Layer protocol that enables clients to remotely login to an SSH Server
to access services. An example is employees logging into a company server to do work from home.
In many Linux servers, the SSH daemon will be installed and started at bootup. If you are able to login to
Server01 using ‘Putty’ or another SSH Client, that means the SSH Server is running on Server01.
7.1.1 Launch your SERVER01 (it will be the SSH Server), log in to your regular user account and verify SSH
Server daemon is running: sudo systemctl status sshd
If it is not, check if you have the SSH package: dpkg -l | grep ssh
ii libssh-4:amd64 0.9.3-2ubuntu2 amd64
tiny C SSH library (OpenSSL flavor)
ii openssh-client 1:8.2p1-4 amd64
secure shell (SSH) client, for secure access to remote machines
ii openssh-server 1:8.2p1-4 amd64
secure shell (SSH) server, for secure access from remote machines
ii openssh-sftp-server 1:8.2p1-4 amd64
secure shell (SSH) sftp server module, for SFTP access from remote machines
ii ssh-import-id 5.10-0ubuntu1 all
securely retrieve an SSH public key and install it locally
If you don’t see these packages, install them: sudo apt-get install openssh-server openssh-client
7.1.2 At your Desktop VM (the SSH Client), attempt to connect to the SSH Server:
ssh [email protected] (‘your-userid’ is a user account on the server, substitute Server01’s
IP address)
Note that the first time you log in, you may see a message like this:
vmadmin@Desktop:~$ ssh [email protected]
The authenticity of host '192.168.10.11 (192.168.10.11)' can't be established.
ECDSA key fingerprint is SHA256:fa87xR4a4y2uhOAN+/6QSpx0Z68uhuaODjlqdAc63kQ.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
7.1.3 Try the ‘who’ and ‘hostname’ commands to get an idea of your connection details. Then enter ‘exit’ to
log-out of your ssh session (leave Server01).
7.1.4 At the server, view the contents of the SSH configuration file: /etc/ssh/sshd_config
There is a section for permitting login as root (PermitRootLogin). Why do you think it would be important to not
allow root to be permitted remote login? ANSWER: because root can do a lot more damage on the
machine than a standard user so root is prohibited.
Part 7.2: Using SSH Utilities (ssh, scp, sftp)
We will use ssh to remotely run commands and transfer files between your Desktop VM and your Atlas
account. Atlas is a Sheridan College-wide Linux server.
Where do you think the file was saved? ANSWER: In bhanvada directory
What command can you issue to confirm that this command worked?
COMMAND: ssh [email protected] ls
7.2.5 Add two more small files to ‘transfer’ directory. Write the scp command using the option –r to copy that
transfer directory to your atlas account (make certain to include the colon (:) at the end of the atlas domain
name).
COMMAND:
Try issuing the command above. Did the command work? ANSWER: Yes
What command can you issue to confirm that this command worked?
COMMAND: ssh [email protected] ls
7.2.6 Another way we can transfer files is using the sftp command (Secure File Transfer Protocol). You
probably noticed scp requires to enter the password each time when you issue the command.This sftp
method opens a shell where the user issues commands to perform various file transfer operations without
requiring the password every time.
On your Desktop VM, put your professor’s name in sample.txt, and move the file to ~/transfer. Run the sftp
command shell: sftp [email protected]
Local Machine (eg. Desktop VM) Remote Server (eg. Atlas Server)
!ls (or lls) – list files on local machine ls – list files on remote server
!pwd (or lpwd) – display current location (local machine) pwd – display current location (remote server)
Within sftp shell, go to ~/transfer, remove test.txt file from local directory, transfer your sample.txt file to
your atlas account, then copy/restore the test.txt file back to transfer directory on Desktop VM.
Put screenshots of all steps:
As sample.txt file is transfer to remote server it is visible in atlas remote server. And test.txt is visible
in local machine.
You are done, hi-light your answers in YELLOW and submit this to SLATE.