Day 2: Build Your Own RHEL Practice Lab and Connect with SSH¶
Course: RHCSA Section: Lab Environment Topic: Creating a RHEL virtual machine, installing RHEL, and connecting to it with SSH Audience: Linux beginners through RHCSA exam candidates
1. Topic Introduction¶
A hosted course lab is limited in time. To practice whenever you like, you can build your own virtual machine (VM) on your computer and install Red Hat Enterprise Linux (RHEL) in it. A VM is a complete, isolated computer simulated by software, so you can experiment, break things, and start again without risking a real system.
This section covers the full path: choosing and installing a hypervisor, creating the VM, installing RHEL, and connecting to the VM from your computer's terminal with SSH. SSH (Secure Shell) is the standard way to administer Linux systems remotely, so the same skill applies to physical servers and cloud instances.
Where this is used in practice
- Building a private practice environment for RHCSA preparation.
- Testing configuration changes before applying them to real servers.
- Connecting to any remote Linux system for administration.
2. Learning Objectives¶
After completing this section, you will be able to:
- Explain what a hypervisor and a virtual machine are.
- Choose appropriate VM resources (CPU, memory, disk) for a RHEL practice VM.
- Create a VM from an ISO image in VMware Workstation.
- Install RHEL, choosing software selection, root, and user settings.
- Find the VM's IP address.
- Connect to the VM over SSH from PowerShell or PuTTY.
- Inspect and safely change the SSH server configuration, validate it, and restore it.
- Diagnose common SSH connection and authentication failures.
- Explain the security trade-offs of simple passwords and root password login.
3. Core Concepts¶
3.1 Hypervisor and virtual machine¶
| Term | Definition |
|---|---|
| Hypervisor | Software that creates and runs virtual machines on a host computer |
| Host | The physical computer (for example, your Windows laptop) |
| Guest | The operating system running inside the VM (RHEL in this section) |
| Virtual machine | A simulated computer with its own virtual CPU, memory, disk, and network adapter |
Host laptop
└─ Hypervisor (VMware Workstation or VirtualBox)
└─ Virtual machine
└─ Guest OS: RHEL
Why it matters: A VM is disposable. If a configuration breaks the system, you can reinstall or restore a snapshot. This makes it ideal for learning.
Common misunderstanding: A VM shares the host's physical resources. If you assign too much memory or too many processors, the host and the guest will both run slowly.
3.2 ISO image¶
An ISO file is a disk image of the installation media. The hypervisor attaches it to the VM as a virtual DVD, so you do not need a physical disc. RHEL installation images are downloaded from your Red Hat account.
3.3 Choosing VM resources¶
| Setting | Lab value used in this course | Notes |
|---|---|---|
| Processors | 2 | Enough for lab work |
| Memory | 2 GB minimum, 4 GB if the host allows | A graphical desktop benefits from more memory |
| Disk | 20 GB, as a single file | A disk that is too small can make the installer fail at the destination step |
Verify: These are practical lab values. Red Hat publishes official minimum and recommended requirements for each RHEL release. Check them for the version you install.
Verify (RHEL 10): RHEL 10 raised the minimum processor baseline for x86-64 systems. If the VM fails to start the installer or reports an unsupported CPU, confirm your processor and hypervisor meet the RHEL 10 hardware requirements in Red Hat's documentation.
3.4 Guest OS type in the hypervisor¶
The hypervisor uses the guest OS type to choose sensible defaults.
| RHEL version | Guest OS type | Version |
|---|---|---|
| RHEL 10 | Other | Other 64-bit |
| RHEL 9 | Linux | Red Hat Enterprise Linux 9 64-bit |
Note: Hypervisor lists may not include the newest RHEL release yet. If your version of VMware Workstation lists RHEL 10, choose that instead.
3.5 Installation choices¶
| Choice | Options | Guidance |
|---|---|---|
| Language | For example, English (India) | Any supported language works |
| Software selection | Server with GUI or Server | Server with GUI is easier while learning. Server (no GUI) is the common real-world choice. |
| Installation destination | The virtual disk | Select it and confirm. |
| Root account | Enable and set a password | Optional in many installs, but this lab uses it |
| User account | Create a regular user | Also create a password |
The installer warns when a password is weak and requires you to confirm by selecting Done twice. A simple password is acceptable only in a private lab.
3.6 SSH¶
Definition: SSH (Secure Shell) is a protocol that lets you open a command-line session on another machine over an encrypted network connection. The SSH server on RHEL is the sshd service, and it listens on TCP port 22 by default.
Why use SSH instead of the VM console: The console of a VM can feel slow, and it may not support copy and paste. An SSH session from PowerShell or PuTTY is fast and lets you paste commands easily.
Terminology
| Term | Meaning |
|---|---|
sshd |
The SSH server (daemon) running on the VM |
ssh |
The SSH client you run on your computer |
| Host key | The server's identity, shown on first connection |
known_hosts |
The client file that remembers server host keys |
3.7 Root login over SSH¶
By default, OpenSSH does not allow the root account to log in with a password over SSH. The behavior is controlled by PermitRootLogin in the SSH server configuration.
PermitRootLogin value |
Effect |
|---|---|
yes |
Root may log in with a password or key |
prohibit-password |
Root may log in with a key but not a password |
forced-commands-only |
Root may log in with a key only to run specific commands |
no |
Root cannot log in over SSH |
Allowing password login for root is a convenience for private practice VMs. It is not recommended for real servers, because the root account is the most targeted account. Production systems normally use a regular user with SSH keys and sudo.
Verify: Some RHEL installers offer an option on the root account screen to allow root SSH login with a password. The wording and availability depend on the release, so check your installer.
4. Commands and Syntax¶
Command: hostname -I¶
Purpose: Print the IP addresses assigned to the system.
Syntax:
hostname -I
Example:
hostname -I
Explanation: The output lists IP addresses separated by spaces. Use the address that belongs to the network your host can reach (typically the first one on a simple VM).
Important points: If nothing prints, the VM may have no network connection. Check the adapter in the hypervisor.
Command: ip addr¶
Purpose: Show network interfaces and their addresses.
Syntax:
ip addr [show [interface]]
Explanation: This gives more detail than hostname -I, including interface names and state. Look for the interface marked UP with an inet address.
Command: ssh¶
Purpose: Open a remote shell session on another machine.
Syntax:
ssh [options] user@host
Important options:
| Option | Meaning |
|---|---|
-p port |
Connect to a port other than 22 |
-v |
Verbose output for troubleshooting |
-i keyfile |
Use a specific private key |
Example:
ssh <user>@<IP-address>
<user> and <IP-address> are placeholders. Use your own user name and the address from hostname -I.
Explanation: The first time you connect, ssh shows the server's host key fingerprint and asks whether to continue. Answer yes only if you expect this server. The key is then saved in ~/.ssh/known_hosts on your computer.
Common errors
| Message (approximate) | Cause | Resolution |
|---|---|---|
| Connection timed out | Wrong IP, VM off, network or firewall issue | Check the IP and that the VM is running |
| Connection refused | No service is listening on the port | Check that sshd is running |
| Permission denied | Wrong password, or the method or account is not allowed | Check the password, user name, and sshd_config |
| Warning: remote host identification has changed | The host key differs from the saved one, for example after reinstalling the VM | Remove the old entry (see below) |
Removing an outdated host key (after verifying that the server really was reinstalled):
ssh-keygen -R <IP-address>
Command: systemctl (for sshd)¶
Purpose: Inspect and control the SSH service.
Privileges: Status checks work as a normal user. Starting, stopping, and restarting require sudo or root.
Syntax:
systemctl status sshd
sudo systemctl restart sshd
sudo systemctl enable --now sshd
Explanation:
statusshows whether the service is running and shows recent log lines.restartstops and starts the service so configuration changes take effect. Existing sessions usually remain open, but do not rely on that.enable --nowstarts the service immediately and also starts it at every boot.
Note: Both
sshdandsshd.serviceare accepted as the unit name.
Command: sshd -t and sshd -T¶
Purpose: Validate and display the SSH server configuration.
Privileges: Requires root or sudo.
Syntax:
sudo sshd -t # test the configuration for errors
sudo sshd -T # print the effective configuration
Example:
sudo sshd -T | grep -Ei 'permitrootlogin|passwordauthentication'
Explanation: sshd -t prints nothing if the configuration is valid and prints an error with a line number if it is not. sshd -T prints the settings the server will actually use after reading all configuration files, which is the reliable way to confirm a setting.
Command: cat /etc/os-release¶
Purpose: Confirm that you are connected to the intended system.
cat /etc/os-release
Check the name and version in the output.
Command: vim¶
Purpose: Edit configuration files in the terminal.
Basic use:
| Key or command | Action |
|---|---|
vim <file> |
Open a file |
i |
Enter insert mode |
Esc |
Return to command mode |
:wq |
Save and quit |
:q! |
Quit without saving |
/word |
Search for a word |
A later section covers Vim in detail. You may use another editor if you prefer.
5. Configuration Files and System Paths¶
| Path | Purpose |
|---|---|
/etc/ssh/sshd_config |
Main SSH server configuration |
/etc/ssh/sshd_config.d/ |
Additional configuration snippets |
~/.ssh/known_hosts |
(On your computer) Saved server host keys |
Important settings
| Setting | Meaning |
|---|---|
PermitRootLogin |
Whether root may log in over SSH, and how |
PasswordAuthentication |
Whether password logins are allowed |
Port |
TCP port the server listens on (default 22) |
How configuration is read: The main file may include the files in /etc/ssh/sshd_config.d/. For most settings the first value that sshd reads is the one used, so a snippet in that directory can override a line in the main file. Always confirm with sudo sshd -T instead of assuming.
Inspecting
sudo grep -Ei 'permitrootlogin|passwordauthentication' /etc/ssh/sshd_config
sudo grep -ri 'permitrootlogin\|passwordauthentication' /etc/ssh/sshd_config.d/
Backing up before changes
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
Validating a change
sudo sshd -t
Restoring
sudo cp /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
sudo sshd -t
sudo systemctl restart sshd
Warning: If you make a mistake in the SSH configuration,
sshdmay fail to start and you could lose remote access. Keep your VM console or an existing SSH session open until you have verified that a new connection works.
6. Step-by-Step Administration Procedures¶
Procedure 1: Prepare and download¶
Goal: Gather what you need before building the VM.
Prerequisites: A computer with enough free disk space (at least 20 GB for the VM plus room for the ISO) and enough memory to give the VM 2 to 4 GB while the host keeps running smoothly.
Steps
- Choose a hypervisor: VMware Workstation or Oracle VirtualBox.
- Download and install it. If an older version of VMware is already installed and the installer offers Change, Repair, or Remove, remove the old version first, then install the newer one.
- Download the RHEL ISO from your Red Hat account (this course used RHEL 10.1).
- Verify the ISO checksum (see section 3.2).
Verification: The hypervisor starts, and the ISO file is present and its checksum matches.
Procedure 2: Create the virtual machine (VMware Workstation)¶
Goal: Create a VM ready to boot the RHEL installer.
Steps
- Click Create a New Virtual Machine.
- Choose Installer disc image file (ISO) and browse to your RHEL ISO.
- Select the guest OS type (see section 3.4).
- Give the VM a name, for example
<yourname>-vm. - Choose a location. Create a dedicated folder (for example, a
VMwarefolder under Documents) so all VM files are kept together. - Set the disk size to 20 GB and choose Store virtual disk as a single file.
- Click Customize Hardware and set Memory to 2 GB (or 4 GB) and Processors to 2.
- Click Close, then Finish.
- Click Play virtual machine.
Verification: The VM starts and the RHEL boot menu appears.
Rollback: Delete the VM from the hypervisor to start again with different settings.
Procedure 3: Install RHEL¶
Goal: Install a working RHEL system in the VM.
Prerequisites: A VM booted from the RHEL ISO.
Steps
- At the boot menu, choose Install Red Hat Enterprise Linux (version 10.1 in this course) and press Enter.
- Choose a language, for example English (India), and select Continue.
- Choose Software Selection and select Server with GUI for now.
- Choose Installation Destination, select the virtual disk, and click Done. If prompted again, click Done once more.
- Choose Root Account, enable it, set a password, and click Done (twice if the installer warns about a weak password).
- Choose User Creation, create a regular user and password, and click Done (twice if warned). If the installer offers an option to make the user an administrator, enable it so the user can run
sudo. - Click Begin Installation. The installation takes about 30 to 45 minutes depending on your computer and network. Wait for it to finish.
- Click Reboot.
Lab note: Using the same simple password for the root and user accounts is acceptable only in a private lab. Never use it on any system that others can reach.
Verification: The system boots to a login screen. Log in, open a terminal, and run:
cat /etc/os-release
whoami
Procedure 4: First boot checks¶
Goal: Confirm the system is working.
Steps
- If a first-boot configuration screen appears, you can skip it.
- Open a terminal.
- Note any message that says the system is not registered. Registration with Red Hat is covered in a later section and is required to install packages from Red Hat repositories.
Verification: A terminal opens and cat /etc/os-release shows RHEL.
Procedure 5: Connect with SSH¶
Goal: Log in to the VM from your computer's terminal.
Prerequisites: The VM is running and has network connectivity. The SSH server is running.
Steps
- In the VM, find its IP address:
bash hostname -I - In the VM, confirm
sshdis running:bash systemctl status sshdIf it is not running, start it and enable it:bash sudo systemctl enable --now sshd - On your computer, open PowerShell (or PuTTY) and connect:
bash ssh <user>@<IP-address> - On the first connection, verify the host key prompt and answer
yes. - Enter the password.
- Confirm you are on the VM:
bash cat /etc/os-release
Verification: The prompt shows the VM's hostname, and cat /etc/os-release shows RHEL.
Procedure 6: Allow root password login (practice VM only)¶
Goal: Log in as root over SSH using a password, for lab convenience.
Prerequisites: Console or sudo access to the VM, and a backup of the configuration.
Warning: Do this only on a private practice VM. Do not enable it on any real or internet-facing system.
Steps
- Back up the configuration:
bash sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak - Open the configuration file:
bash sudo vim /etc/ssh/sshd_config - Find
PermitRootLogin. Remove any#at the start of the line and set:PermitRootLogin yes - Find
PasswordAuthenticationand make sure it reads:PasswordAuthentication yesSearch for the option names with/PermitRootLoginin Vim instead of relying on line numbers, because they differ between releases. - Save and exit (
:wq). - Check for syntax errors:
bash sudo sshd -t - Check what is actually in effect, including any overrides in
/etc/ssh/sshd_config.d/:bash sudo sshd -T | grep -Ei 'permitrootlogin|passwordauthentication' - Restart the service:
bash sudo systemctl restart sshd - From your computer, test the connection:
bash ssh root@<IP-address>
Verification: sshd -T shows permitrootlogin yes and passwordauthentication yes, and the root login succeeds.
Rollback:
sudo cp /etc/ssh/sshd_config.bak /etc/ssh/sshd_config
sudo sshd -t
sudo systemctl restart sshd
Procedure 7: Run everything from the SSH session¶
Goal: Practice in a comfortable terminal.
You can run any practice command in the SSH window. Copy and paste works with a right-click in PowerShell and PuTTY. You can power the VM off from the hypervisor or with sudo systemctl poweroff from inside the VM.
7. Practical Examples¶
Example 1: Creating a safe baseline¶
After a clean install and a working SSH connection, record the starting state so you can restore it later.
- Take a snapshot of the VM in the hypervisor (the menu is typically under VM, then Snapshot). Give it a clear name such as
clean-install. - Practice and experiment.
- If something breaks, restore the snapshot.
Why: Snapshots turn mistakes into a quick restart, which encourages experimentation. They are a hypervisor feature, not a RHEL feature.
Example 2: Confirming the effective SSH settings¶
You changed sshd_config, but the setting does not seem to apply.
sudo sshd -T | grep -i permitrootlogin
sudo grep -ri permitrootlogin /etc/ssh/sshd_config /etc/ssh/sshd_config.d/
Why: sshd -T tells you the final value, and the grep shows every place that sets it. If a file in sshd_config.d/ sets a different value, that is what is overriding your edit.
8. Verification and Troubleshooting¶
| Symptom | Likely cause | Diagnostic | Resolution |
|---|---|---|---|
| Installer fails at the destination step | Virtual disk too small | Check VM hardware settings | Recreate the VM with a 20 GB disk |
| VM will not start the installer | Unsupported CPU or settings | Hypervisor messages; Red Hat requirements | Check CPU and hypervisor support |
| VMware installer offers Change / Repair / Remove | Older version installed | n/a | Remove the old version, then install the new one |
hostname -I prints nothing |
No network | ip addr; VM network adapter settings |
Enable the adapter and reconnect it in the hypervisor |
ssh times out |
Wrong IP, VM off, or network or firewall block | Ping the IP; confirm the VM is running | Fix the address or the network mode |
ssh connection refused |
sshd not running |
systemctl status sshd |
sudo systemctl enable --now sshd |
| Authentication failure for root | Root password login not allowed | sudo sshd -T |
See Procedure 6 |
| Authentication failure after fixing config | Mistyped password | Retype carefully | Use the correct password |
| Host identification changed warning | VM reinstalled with the same IP | n/a | ssh-keygen -R <IP-address> after confirming the change is expected |
Changes to sshd_config have no effect |
Service not restarted or an override exists | sudo sshd -T |
sudo systemctl restart sshd and check sshd_config.d/ |
Logs
sudo journalctl -u sshd --since "10 minutes ago"
This shows recent messages from the SSH service, including authentication failures. Read them to see why a login was rejected.
Firewall: RHEL's firewall normally allows SSH by default. You can check allowed services with:
sudo firewall-cmd --list-services
If ssh is missing, add it permanently:
sudo firewall-cmd --permanent --add-service=ssh
sudo firewall-cmd --reload
Do not disable the firewall to make SSH work. Add the specific service instead.
Persistent versus temporary: Edits to sshd_config take effect only after a restart or reload, and they persist across reboots. A restored snapshot reverts all changes made after it was taken.
9. Best Practices and Important Notes¶
- Verify the ISO checksum before installing.
- Keep VM files in one dedicated folder and back up important VMs.
- Take a snapshot after a clean install and before risky experiments.
- Use a simple password only in a private lab. Use strong passwords or keys on real systems.
- Prefer a regular user with
sudoover logging in as root. - Never expose a practice VM with weak credentials to the internet.
- Always run
sudo sshd -tbefore restartingsshd, and keep a session open while testing a change. - Do not disable SELinux or the firewall as a shortcut. Fix the specific cause.
Common mistakes
- Choosing a disk that is too small.
- Editing
sshd_configbut forgetting to restartsshd. - Forgetting that a drop-in file can override the main file.
- Typing the wrong password and assuming the configuration is wrong.
10. RHCSA Exam Preparation¶
General administration skills practiced here
- Working at the command line, including editing configuration files.
- Starting, enabling, and checking a service with
systemctl. - Validating changes and confirming they persist.
- Reading logs with
journalctl.
Preparation habits
- Practice in an environment you can reset quickly.
- Spend regular time each day on hands-on work. About two hours a day over a few weeks is a common study pattern for this exam.
- Learn the typical errors in a task and how to fix them.
Verify: Building a VM, installing a hypervisor, and enabling root password login over SSH are lab-preparation activities, not stated exam objectives. Confirm what the current RHCSA (EX200) objectives require on Red Hat's official exam page.
11. Section Summary¶
- A hypervisor runs a virtual machine on your computer, and the VM runs RHEL.
- Use 2 processors, 2 to 4 GB of memory, and a 20 GB disk as lab values, and check the official RHEL requirements.
- Install Server with GUI while learning, and create both a root and a regular user.
- Find the VM's IP address with
hostname -I, then connect withssh user@IP. - The SSH server is
sshd, configured in/etc/ssh/sshd_configand/etc/ssh/sshd_config.d/. - Validate with
sudo sshd -t, inspect withsudo sshd -T, and restart the service to apply changes. - Root password login and simple passwords are for private practice VMs only.
12. Quick Revision¶
| Command or item | Purpose | Notes |
|---|---|---|
hostname -I |
Show IP addresses | Run in the VM |
ip addr |
Show interfaces and addresses | More detail |
ssh user@ip |
Remote login | Placeholders for user and address |
ssh-keygen -R ip |
Remove a saved host key | After a VM reinstall |
systemctl status sshd |
Check the SSH service | No privileges needed |
sudo systemctl enable --now sshd |
Start and enable at boot | |
sudo systemctl restart sshd |
Apply config changes | |
sudo sshd -t |
Validate the configuration | Silent when valid |
sudo sshd -T |
Show effective settings | Use with grep |
/etc/ssh/sshd_config |
Main SSH config | Back up before editing |
/etc/ssh/sshd_config.d/ |
Drop-in configs | Can override the main file |
sudo journalctl -u sshd |
SSH logs | Use --since to narrow |
sudo firewall-cmd --list-services |
Check allowed services | Add ssh if missing |
| 20 GB / 2 CPU / 2 to 4 GB | Lab VM resources | Verify against official requirements |
13. Knowledge Check¶
- What is a hypervisor, and how does it differ from a virtual machine?
- Why is a personal VM useful when you already have a hosted lab?
- Which guest OS type is used for RHEL 10 in the VMware steps in this section?
- What disk size is recommended for the lab VM, and what can happen if the disk is much smaller?
- Which command shows the VM's IP address?
- What is the name of the SSH server service on RHEL?
- Which two settings in
sshd_configrelate to password login for root? - What does
sudo sshd -tdo? - Why might a change to
sshd_configappear to have no effect even after a restart? - Why should you avoid root password login on a real server, and what is the usual alternative?
Answer Key¶
- A hypervisor is the software that creates and runs virtual machines. A virtual machine is the simulated computer that runs inside it.
- It has no time limit, can be reset or restored, and can be used for extra experiments.
- Other, with version Other 64-bit.
- 20 GB is recommended. A much smaller disk can make the installer fail at the installation destination step.
hostname -I.sshd.PermitRootLoginandPasswordAuthentication.- It checks the SSH server configuration for errors and prints nothing if it is valid.
- A file under
/etc/ssh/sshd_config.d/may override the setting, or the service may not have been restarted.sudo sshd -Tshows the effective value. - Root is the most targeted account, and passwords can be guessed. The usual alternative is a regular user with SSH keys and
sudo.