If you plan to take the RHCSA exam, then use the following approach to maximize the benefit of this Comprehensive Review: attempt each lab without viewing the solution buttons or referring to the course content. Use the grading scripts to gauge your progress as you complete each lab.
In this review, you configure, secure, and use the SSH service to access a remote machine, and manage packages with the dnf utility.
Outcomes
Create a new SSH key pair.
Disable SSH logins as the root user.
Disable password-based SSH logins.
Update the time zone of a server.
Install packages and package modules by using the dnf command.
If you did not reset your workstation and server machines at the end of the last chapter, then save any work that you want to keep from earlier exercises on those machines, and reset them now.
As the student user on the workstation machine, use the lab command to prepare your system for this exercise.
This command prepares your environment and ensures that all required resources are available.
[student@workstation ~]$ lab start rhcsa-rh124-review3
Specifications
Log in to serverb as the student user.
Generate SSH keys for the student user.
Do not protect the private key with a passphrase.
Save the private and public keys as the /home/student/.ssh/review3_key and /home/student/.ssh/review3_key.pub files respectively.
Configure the student user on servera to accept logins that are authenticated by the review3_key SSH key pair.
The student user on serverb should be able to log in to servera by using SSH without entering a password.
On serverb, configure the sshd service to prevent the root user from logging in.
On serverb, configure the sshd service to prevent users from using their passwords to log in.
Users should still be able to authenticate logins by using an SSH key pair.
Install the zsh package on the serverb machine.
Set the time zone of serverb to Asia/Kolkata.
Log in to serverb as the student user.
[student@workstation ~]$ ssh student@serverb
...output omitted...
[student@serverb ~]$Generate SSH keys for the student user.
Do not protect the private key with a passphrase.
Name the private and public key files /home/student/.ssh/review3_key and /home/student/.ssh/review3_key.pub respectively.
[student@serverb ~]$ssh-keygenGenerating public/private rsa key pair. Enter file in which to save the key (/home/student/.ssh/id_rsa):/home/student/.ssh/review3_keyEnter passphrase (empty for no passphrase):EnterEnter same passphrase again:EnterYour identification has been saved in /home/student/.ssh/review3_key. Your public key has been saved in /home/student/.ssh/review3_key.pub. The key fingerprint is: SHA256:Uqefehw+vRfm94fQZDoz/6IfNYSLK/OpiQ4n6lrKIbY student@serverb.lab.example.com The key's randomart image is: +---[RSA 3072]----+ | .+=oBo+ | | ...O * = | |.. + % = | |. +.B =. | |...*..o S | |E.=. o + . | | .= oo o . | | *... . | | .oo. | +----[SHA256]-----+
Configure the student user on servera to accept logins that are authenticated by the review3_key SSH key pair.
The student user on serverb should be able to log in to servera by using SSH without entering a password.
Export the review3_key public key to servera from serverb.
[student@serverb ~]$ssh-copy-id -i .ssh/review3_key.pub student@servera/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: ".ssh/review3.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys student@servera's password:studentNumber of key(s) added: 1 Now try logging into the machine, with: "ssh 'student@servera'" and check to make sure that only the key(s) you wanted were added.
Verify that you can log in to servera from serverb as the student user by using the review3_key private key without being prompted for the password.
[student@serverb ~]$ ssh -i .ssh/review3_key student@servera
...output omitted...
[student@servera ~]$Exit from servera.
[student@servera ~]$ exit
logout
Connection to servera closed.
[student@serverb ~]$On serverb, configure the sshd service to prevent the root user from logging in.
Set the PermitRootLogin parameter to no in the /etc/ssh/sshd_config file.
Use the sudo vim /etc/ssh/sshd_config command to edit the configuration file.
Reload the sshd service.
[student@serverb ~]$ sudo systemctl reload sshd.serviceOn serverb, configure the sshd service to prevent users from using their passwords to log in.
Users should still be able to authenticate logins by using SSH keys.
Set the PasswordAuthentication parameter to no in the /etc/ssh/sshd_config file.
Use the sudo vim /etc/ssh/sshd_config command to edit the configuration file.
Reload the sshd service.
[student@serverb ~]$ sudo systemctl reload sshd.serviceInstall the zsh package.
[student@serverb ~]$sudo dnf install zsh...output omitted... Is this ok [y/N]:y...output omitted... Installed: zsh-5.8-9.el9.x86_64 Complete!
Set the time zone of serverb to Asia/Kolkata.
Set the time zone of serverb to Asia/Kolkata.
[student@serverb ~]$ sudo timedatectl set-timezone Asia/KolkataReturn to the workstation system as the student user.
[student@serverb ~]$ exit
logout
Connection to serverb closed.
[student@workstation ~]$This concludes the section.