In this review, you will configure, secure, and use SSH service to access remote machine, configure rsyslog service, archive local files, transfer local files to remote machine, and manage packages using yum.
Outcomes
You should be able to:
Create a new SSH key pair.
Disable SSH logins as root user.
Disable SSH logins using password.
Update the time zone of a server.
Install packages and package modules using yum.
Archive local files for backup.
Transfer local files to remote machine.
Log in to workstation as student using student as the password.
On workstation, run lab rhcsa-rh124-review3 start to start the comprehensive review.
This script creates the necessary files to set up the environment correctly.
[student@workstation ~]$lab rhcsa-rh124-review3 start
Instructions
Accomplish the following tasks on serverb to complete the exercise.
Generate SSH keys for the user student on serverb.
Do not protect the private key with a passphrase.
The private and public key files should be named /home/student/.ssh/review3_key and /home/student/.ssh/review3_key.pub respectively.
On servera, configure the user student to accept logins authenticated by the SSH key pair you created for the user student on serverb.
The user student on serverb should be able to log in to servera using SSH without entering a password.
On serverb, configure the sshd service to prevent users from logging in as root via SSH.
On serverb, configure the sshd service to prevent users from using their passwords to log in.
Users should still be able to authenticate logins using an SSH key pair.
Create a tar archive named /tmp/log.tar containing the contents of /var/log on serverb.
Remotely transfer the tar archive to /tmp directory on servera, authenticating as student using the student user’s private key of the SSH key pair.
Configure the rsyslog service on serverb to log all messages it receives that have the priority level of debug or higher to the file /var/log/grading-debug.
This configuration should be set in an /etc/rsyslog.d/grading-debug.conf file, which you need to create.
Install the zsh package, available in the BaseOS repository, on serverb.
Enable the default module stream for the module python36 and install all provided packages from that stream on serverb.
Set the time zone of serverb to Asia/Kolkata.
Generate SSH keys for the user student on serverb.
Do not protect the private key with a passphrase.
The private and public key files should be named /home/student/.ssh/review3_key and /home/student/.ssh/review3_key.pub respectively.
From workstation, open an SSH session to serverb as student.
[student@workstation ~]$ssh student@serverb...output omitted...[student@serverb ~]$
Use the ssh-keygen command to generate the SSH keys for the user student.
[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 2048]----+ | | | . | | . . . . | | . o . = | | . S . * ..| | . ...B +..| |.o . o . =o+ O.o | |+ = . + ..X o *.o| | Eoo .o.+.+o=.+=| +----[SHA256]-----+
On servera, configure the user student to accept logins authenticated by the SSH key pair you created for the user student on serverb.
The user student on serverb should be able to log in to servera using SSH without entering a password.
Use the ssh-copy-id command to export the public key /home/student/.ssh/review3_key.pub from servera to 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 keysstudent@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.
Use the ssh command to confirm that you can log in to servera from serverb as student using the SSH private key /home/student/.ssh/review3_key without being prompted for the password.
[student@serverb ~]$ssh -i .ssh/review3_key student@servera...output omitted...[student@servera ~]$
Log out of servera.
[student@servera ~]$exitlogout Connection to servera closed.[student@serverb ~]$
On serverb, configure the sshd service to prevent users from logging in as root with SSH.
On serverb, configure the sshd service to prevent users from using their passwords to log in.
Users should still be able to authenticate logins using their private key of the SSH key pair.
Create a tar archive named /tmp/log.tar containing the contents of /var/log on serverb.
Remotely transfer the tar archive to the directory /tmp on servera, authenticating as student using /home/student/.ssh/review3_key as the student user’s private key of the SSH key pair for authentication.
Use the sudo tar command to create an archive named /tmp/log.tar as the superuser containing the contents of /var/log.
[student@serverb ~]$sudo tar -cvf /tmp/log.tar /var/log[sudo] password for student:student...output omitted...
Use the scp command to remotely transfer the archive file /tmp/log.tar to the directory /tmp on servera.
Specify /home/student/.ssh/review3_key as the private key of the SSH key pair.
[student@serverb ~]$scp -i .ssh/review3_key /tmp/log.tar student@servera:/tmplog.tar 100% 14MB 57.4MB/s 00:00
Configure the rsyslog service on serverb to log all messages it receives that have the priority level of debug or higher to the file /var/log/grading-debug.
This configuration should be set in an /etc/rsyslog.d/grading-debug.conf file which you should create.
Create the file /etc/rsyslog.d/grading-debug.conf with the following content.
You may use the sudo vim /etc/rsyslog.d/grading-debug.conf to create the file.
*.debug /var/log/grading-debug
Use the sudo systemctl command to restart the rsyslog service.
[student@serverb ~]$sudo systemctl restart rsyslog.service
Use the logger command to generate the log message Debug Testing having priority debug.
[student@serverb ~]$logger -p debug Debug Testing
Confirm that the log message Debug Testing is saved in the /var/log/grading-debug file.
[student@serverb ~]$sudo tail /var/log/grading-debug...output omitted... Mar 12 09:55:23 serverb student[32383]: Debug Testing
Use the sudo yum command to install the zsh package, available in the BaseOS repository, on serverb.
Use the yum command to enable the default module stream for the module python36 and install all the provided packages from that stream, on serverb.
Set the timezone of serverb to Asia/Kolkata.