Red Hat System Administration I
Note
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.
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
rootuser.Disable password-based SSH logins.
Install packages and package modules by using the
dnfcommand.
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
serverbas thestudentuser.Generate SSH keys for the
studentuser. Do not protect the private key with a passphrase. Save the private and public keys as the/home/student/.ssh/review3_keyand/home/student/.ssh/review3_key.pubfiles respectively.Configure the
studentuser onserverato accept logins that are authenticated by thereview3_keySSH key pair. Thestudentuser onserverbshould be able to log in toserveraby using SSH without entering a password.On
serverb, configure thesshdservice to prevent therootuser from logging in.On
serverb, configure thesshdservice 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
zshpackage on theserverbmachine.
Log in to
serverbas thestudentuser.[student@workstation ~]$
ssh student@serverb...output omitted... [student@serverb ~]$Generate SSH keys for the
studentuser. Do not protect the private key with a passphrase. Name the private and public key files/home/student/.ssh/review3_keyand/home/student/.ssh/review3_key.pubrespectively.[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
studentuser onserverato accept logins that are authenticated by thereview3_keySSH key pair. Thestudentuser onserverbshould be able to log in toserveraby using SSH without entering a password.Export the
review3_keypublic key toserverafromserverb.[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
serverafromserverbas thestudentuser by using thereview3_keyprivate 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 ~]$
exitlogout Connection to servera closed. [student@serverb ~]$
On
serverb, configure thesshdservice to prevent therootuser from logging in.Set the
PermitRootLoginparameter tonoin the/etc/ssh/sshd_configfile. Use thesudo vim /etc/ssh/sshd_configcommand to edit the configuration file.Reload the
sshdservice.[student@serverb ~]$
sudo systemctl reload sshd.service
On
serverb, configure thesshdservice to prevent users from using their passwords to log in. Users should still be able to authenticate logins by using SSH keys.Set the
PasswordAuthenticationparameter tonoin the/etc/ssh/sshd_configfile. Use thesudo vim /etc/ssh/sshd_configcommand to edit the configuration file.Reload the
sshdservice.[student@serverb ~]$
sudo systemctl reload sshd.service
Install the
zshpackage.[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!Return to the
workstationsystem as thestudentuser.[student@serverb ~]$
exitlogout Connection to serverb closed. [student@workstation ~]$