Bookmark this page

Lab: Configure and Manage a Server

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.

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.

  1. Log in to serverb as the student user.

    [student@workstation ~]$ ssh student@serverb
    ...output omitted...
    [student@serverb ~]$
  2. 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-keygen
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/student/.ssh/id_rsa): /home/student/.ssh/review3_key
    Enter passphrase (empty for no passphrase): Enter
    Enter same passphrase again: Enter
    Your 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]-----+
  3. 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.

    1. 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: student
      
      Number 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.
    2. 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 ~]$
    3. Exit from servera.

      [student@servera ~]$ exit
      logout
      Connection to servera closed.
      [student@serverb ~]$
  4. On serverb, configure the sshd service to prevent the root user from logging in.

    1. 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.

    2. Reload the sshd service.

      [student@serverb ~]$ sudo systemctl reload sshd.service
  5. 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 SSH keys.

    1. 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.

    2. Reload the sshd service.

      [student@serverb ~]$ sudo systemctl reload sshd.service
  6. Install 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!
  7. Set the time zone of serverb to Asia/Kolkata.

    1. Set the time zone of serverb to Asia/Kolkata.

      [student@serverb ~]$ sudo timedatectl set-timezone Asia/Kolkata
    2. Return to the workstation system as the student user.

      [student@serverb ~]$ exit
      logout
      Connection to serverb closed.
      [student@workstation ~]$

Evaluation

As the student user on the workstation machine, use the lab command to grade your work. Correct any reported failures and rerun the command until successful.

[student@workstation ~]$ lab grade rhcsa-rh124-review3

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish rhcsa-rh124-review3

This concludes the section.

Revision: rh124-9.0-398f302