Lab 4
Lab 4
4. Look for either of these two lines, depending on whether the server is an Ubuntu or
a CentOS 7/AlmaLinux VM:
Uncomment the line and change it to the following:
5. Reload the SSH daemon so that it will read in the new changes.
7. Attempt to log in to the server VM from the client that you used in the previous lab.
In this step, you’ll set up two-factor authentication for logging in at the local terminal
and for using sudo . Open the /etc/pam.d/common-auth file in your favorite text editor
At the local terminal of the Ubuntu VM, log out and then log back in. When
prompted, enter the verification code from your smart phone app.
7. Open the /etc/pam.d/sshd file in your text editor, and add that line just under the
@include common-auth line at the top of the file. The top portion of the file should
now look like this:
You should now be able to log in to the local terminal and perform sudo actions
without having to enter a verification code. Instead, you should only have to enter a
verification code when logging in remotely.
6.4 – Using Google Authenticator with key exchange on Ubuntu
2. On the Ubuntu VM, open the /etc/ssh/sshd_config file in your text editor. This
time, instead of changing the #PasswordAuthentication yes line, add this line below
the KbdInteractiveAuthentication yes line :
6.6 – Disabling weak SSH encryption algorithms – Ubuntu 22.04
1. If you haven’t done so already, scan the Ubuntu 22.04 VM and save the output to
a file:
2. Count the number of lines in the file by doing:
3. On the target Ubuntu 22.04 VM, open the /etc/ssh/sshd_config file in your
preferred text editor. Toward the top of the file, find these two lines:
# Ciphers and keying
#RekeyLimit default none
4. Beneath those two lines, insert these three lines:
6 Save the file and restart the SSH daemon. Verify that it started correctly:
9. On the scanner VM, use diff to compare the two files. You should see fewer
algorithms than you saw previously:
6.9 – Configuring more verbose SSH logging
1. Open the main log file and scroll down to where you see the entry that was made due
to your login and observe what it says. For Ubuntu, do:
sudo less /var/log/auth.log
6.10 – Configuring whitelists within sshd_config
1. On the VM that you wish to configure, create user accounts for Frank, Charlie, and
Maggie. ( password : 123456 )
4. From either your host machine or from another VM, have the three users log in.
Then, log them back out
5. Open the /etc/ssh/sshd_config file in your favorite text editor. At the bottom of the
file, add an AllowUsers line with your own username, like so:
6. Then, restart or reload the SSH service and verify that it has started correctly:
7. Open another cmd and ssh by user frank, this time, the user shouldn’t be able to log in.
Add an AllowGroups line to the bottom of the file for the webadmins group, like so:
7.1 – Searching for SUID and SGID files
1. Search through the entire filesystem for all the files that have either SUID or SGID
set before saving the output to a text file:
2. Log into any other user account that you have on the system and create a dummy shell
script file.
3. Run the find command again, saving the output to a different text file:
4. View the difference between the two files:
1. Using your preferred text editor, create the perm_demo.txt file with a line of text.