Connecting to RHEL
This section covers core RHEL connectivity concepts, virtual consoles, pseudo-terminals, remote administrative access via OpenSSH, X11 graphical forwarding, and key-based authentication for RHCSA preparation.
Theory Questions
1. What are the key distinctions between a terminal, console, shell, and interface?
These terms describe distinct operational components within the Linux system architecture.
- Definitions:
- Terminal: An input/output abstraction device (physical hardware terminal or virtual software terminal) that sends keystrokes and displays text output.
- Console: The primary physical or virtual terminal directly attached to the system hardware (typically
/dev/tty1), providing local emergency access without network involvement. - Shell: The command-line interpreter (such as
bashorzsh) running inside a terminal to process user input commands into system calls. - Interface: The overall interaction model exposed to the user, either a Command Line Interface (CLI) or Graphical User Interface (GUI).
- Command(s):
tty - Why: Distinguishing these layers helps isolate connection issues (e.g., shell environment vs. SSH daemon vs. TTY allocation).
- Gotchas: Terminal emulators (e.g., GNOME Terminal) are software applications running inside a graphical environment, not hardware consoles.
- Verify:
tty
2. Which device file is associated with the virtual console accessed via Alt + F6?
The device file is /dev/tty6.
- Command(s):
tty - Why: Linux maps virtual text consoles to static TTY device files located in
/dev/tty1through/dev/tty6. - Gotchas: In graphical desktop environments, switching to a text console usually requires pressing
Ctrl + Alt + F6rather than plainAlt + F6. - Verify:
tty(executed on the 6th virtual console outputs/dev/tty6).
3. Which methods open a pseudo-terminal device?
Pseudo-terminals (PTS) are instantiated by SSH remote connections, GUI terminal emulators, terminal multiplexers (tmux, screen), and container execution tools.
- Command(s):
ls /dev/pts/ - Why: Pseudo-terminals provide virtualized terminal sessions managed dynamically by software services rather than direct kernel TTY bindings.
- Gotchas: Virtual consoles (
/dev/ttyN) are statically allocated by the kernel, while pseudo-terminals (/dev/pts/N) are generated dynamically upon request. - Verify:
tty(returns/dev/pts/0or a similar slave index).
4. Which administration tasks typically require a full server reboot?
Kernel upgrades, core system library updates (such as glibc), hypervisor driver replacements, and hardware maintenance require system reboots.
- Command(s):
needs-restarting -r - Why: Running kernel image code and foundational system libraries loaded in system RAM cannot be hot-swapped completely without re-initializing the OS environment.
- Gotchas: Most non-kernel software updates only require restarting their corresponding systemd services (
systemctl restart <service>) rather than a full system reboot. - Verify:
needs-restarting -r(returns exit code 1 if a system reboot is required).
5. How do you access Linux servers remotely from a Windows environment?
Use the native Windows PowerShell or Command Prompt via the built-in OpenSSH client, or use graphical utilities like PuTTY or MobaXterm.
- Command(s):
ssh user@rhel_server_ip - Why: Windows 10/11 includes a native OpenSSH executable in its standard command path, allowing direct CLI access to remote Linux hosts.
- Gotchas: Ensure target RHEL host firewalls allow incoming traffic on TCP port 22 (
firewall-cmd --add-service=ssh). - Verify:
echo $SSH_CLIENT(executed on the target RHEL server after connecting).
6. Which file stores SSH public key fingerprints for previously connected host systems?
Host key fingerprints are stored in ~/.ssh/known_hosts.
- Command(s):
cat ~/.ssh/known_hosts - Why: Stores public key fingerprints of verified servers upon initial connection to protect against Man-in-the-Middle (MITM) impersonation attacks.
- Gotchas: Re-installing a remote server changes its host key, triggering a security warning on re-connection until the old entry is cleared using
ssh-keygen -R <host>. - Verify:
ssh-keygen -F rhel_server_ip
7. How do you configure SSH to enable graphical application forwarding automatically without passing -X?
Set the persistent directive ForwardX11 yes within the client SSH configuration file (~/.ssh/config).
- Command(s):
echo "ForwardX11 yes" >> ~/.ssh/config - Why: Automatically requests X11 protocol forwarding for all outgoing client SSH connection requests.
- Gotchas: The destination server must have the
xorg-x11-xauthpackage installed andX11Forwarding yesenabled in/etc/ssh/sshd_config. - Verify:
grep ForwardX11 ~/.ssh/config
8. How do you set up secure, key-based SSH authentication?
Generate an asymmetric cryptographic key pair using ssh-keygen and transfer the public key using ssh-copy-id.
- Command(s):
ssh-keygen -t ed25519 ssh-copy-id user@remote_host
* **Why:** Key-based authentication uses public-key cryptography to authenticate users without transferring plaintext passwords over the network.
* **Gotchas:** The remote `~/.ssh` directory requires strict `700` permissions and `authorized_keys` requires `600` permissions; `ssh-copy-id` sets these permissions automatically.
* **Verify:** `ssh user@remote_host` (authenticates successfully without requesting a password).
---
### 9. What defines the system console?
The console is the primary physical or virtual terminal directly attached to the system hardware interface (typically `/dev/tty1`).
* **Command(s):** `consoletype`
* **Why:** Provides low-level local access to the operating system independently of network stack functionality.
* **Gotchas:** Do not confuse the system console (`/dev/tty1`) with network-dependent pseudo-terminal sessions (`/dev/pts/*`).
* **Verify:** `consoletype` (returns `vt` for a virtual terminal console).
---
### 10. How do you switch from a text-based login prompt back to the graphical desktop?
Use the key shortcut `Ctrl + Alt + F2` or isolate the graphical systemd target.
* **Command(s):** Press `Ctrl + Alt + F2` (or run `systemctl isolate graphical.target`)
* **Why:** Modern RHEL distributions host the Display Manager (GDM) on `tty2` by default.
* **Gotchas:** If the default system target is set to `multi-user.target`, the graphical environment is not initialized; you must change targets to enable the GUI.
* **Verify:** `systemctl status display-manager`
---
### 11. How do you display all users currently logged into active terminal sessions?
Run the `w` or `who` command.
* **Command(s):** `w`
* **Why:** Reads current session accounting files and displays active user accounts, assigned TTY/PTS devices, remote host IP addresses, and running processes.
* **Gotchas:** `whoami` outputs only your current user identity, whereas `w` lists all connected system users.
* **Verify:** `w`
---
### 12. What device path is assigned to the first SSH connection on a server without a GUI?
The initial SSH connection is assigned the pseudo-terminal path `/dev/pts/0`.
* **Command(s):** `ls /dev/pts/`
* **Why:** Pseudo-terminal slave devices are indexed sequentially starting at `0`.
* **Gotchas:** Physical and virtual text consoles map to `/dev/ttyN`, whereas remote SSH sessions map to `/dev/pts/N`.
* **Verify:** `tty` (executed inside the first active SSH session).
---
### 13. How do you retrieve verbose debugging information during SSH authentication?
Pass verbose flags (`-v`, `-vv`, or `-vvv`) to the `ssh` client binary.
* **Command(s):** `ssh -vvv user@host`
* **Why:** Verbose logging exposes SSH protocol handshakes, client/server configuration parsing, cipher negotiation, and key authentication steps.
* **Gotchas:** Extremely verbose logs (`-vvv`) generate substantial output; start with a single `-v` when troubleshooting initial connections.
* **Verify:** `ssh -vvv user@host`
---
### 14. How do you launch an SSH session with X11 graphical application support?
Pass the `-X` (untrusted) or `-Y` (trusted) flag to `ssh`.
* **Command(s):** `ssh -X user@host`
* **Why:** `-X` tunnels X11 graphical protocol data securely through the encrypted SSH connection back to your local display server.
* **Gotchas:** If the remote host lacks `xorg-x11-xauth`, X11 forwarding initialization will fail.
* **Verify:** `ssh -X user@host "echo $DISPLAY"` (returns a display allocation string such as `localhost:10.0`).
---
### 15. Where are the SSH client configuration options defined?
Client settings are defined per-user in `~/.ssh/config` and globally across the system in `/etc/ssh/ssh_config`.
* **Command(s):** `cat ~/.ssh/config`
* **Why:** Controls outgoing SSH connections, including host aliases, target usernames, custom ports, and preferred identity key locations.
* **Gotchas:** Do not confuse the SSH client configuration file (`ssh_config`) with the SSH daemon server configuration file (`sshd_config`).
* **Verify:** `ls -l ~/.ssh/config /etc/ssh/ssh_config`
---
### 16. How do you copy a local file to a remote server under a specific username using SCP?
Execute `scp` specifying the local file path and the remote target location formatted as `user@host:path`.
* **Command(s):** `scp /path/to/local/file.txt username@remote_host:/tmp/`
* **Why:** Copies files securely over encrypted SSH transport tunnels using standard remote authentication credentials.
* **Gotchas:** Writing to restricted destination paths fails unless the user account specified has adequate write permissions on the remote file system.
* **Verify:** `ssh username@remote_host "ls -l /tmp/file.txt"`
---
### 17. Which file stores authorized public keys for key-based SSH authentication?
Authorized public keys reside in `~/.ssh/authorized_keys`.
* **Command(s):** `cat ~/.ssh/authorized_keys`
* **Why:** The SSH daemon checks this file to validate incoming signature challenges against trusted public keys for passwordless authentication.
* **Gotchas:** If permissions on `~/.ssh/authorized_keys` permit group or world writing, the SSH daemon rejects key authentication attempts.
* **Verify:** `ls -l ~/.ssh/authorized_keys`
---
### 18. How do you generate an SSH cryptographic key pair?
Run `ssh-keygen` to generate a public/private key pair using modern algorithm choices.
* **Command(s):** `ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""`
* **Why:** `-t ed25519` selects the secure Ed25519 signature algorithm, `-f` sets the key path, and `-N ""` specifies an unpassphrased key for automated execution.
* **Gotchas:** Overwriting an existing default key pair invalidates prior public key deployments across connected remote hosts.
* **Verify:** `ls -l ~/.ssh/id_ed25519*`
---
## Lab Tasks
### Local Console Management Practice
Configure systemd default boot targets, navigate virtual console TTY instances, and verify environment switching.
#### Configuration Steps
```bash
# 1. Configure default boot state to multi-user (text-only) target
systemctl set-default multi-user.target
# 2. Switch the active runtime state to multi-user text mode immediately
systemctl isolate multi-user.target
# 3. From text console, switch to virtual console TTY6
# Press Alt+F6 (or run: chvt 6)
# 4. Configure system default back to graphical target
systemctl set-default graphical.target
# 5. Restore the graphical interface immediately
systemctl isolate graphical.target
-
Why:
-
systemctl set-defaultupdates persistent symlinks in/etc/systemd/system/default.target. -
systemctl isolatechanges active system execution states immediately without requiring a system reboot. -
chvt 6changes virtual consoles from the command line interface. -
Gotchas:
-
Keyboard shortcut
Alt + F6requires holdingCtrl + Alt + F6when issuing the sequence from within a running graphical desktop session.
Verification Procedures
Confirm default system targets and active console assignments.
# Verify system default boot target configuration
systemctl get-default
# Verify active virtual terminal device
tty
SSH Remote Management Practice
Establish encrypted SSH client connections, enable X11 graphical application forwarding, and deploy passwordless key authentication.
Configuration Steps
# 1. Generate an Ed25519 asymmetric SSH key pair on server2 without a passphrase
ssh-keygen -t ed25519 -N "" -f ~/.ssh/id_ed25519
# 2. Copy the public key to student account on server1
ssh-copy-id student@server1
# 3. Initiate passwordless SSH connection to server1
ssh student@server1
# 4. Connect with X11 graphical application forwarding enabled
ssh -X student@server1
-
Why:
-
ssh-keygengenerates cryptographic private and public key files (id_ed25519andid_ed25519.pub). -
ssh-copy-idappends public key entries into~/.ssh/authorized_keyson the remote host and sets correct target permissions (700for~/.sshand600forauthorized_keys). -
-Xinitiates X11 forwarding capabilities over the secure SSH session tunnel. -
Gotchas:
-
If the remote target user directory structure has invalid permissions (e.g., world-writable home directory), OpenSSH
StrictModeswill decline key-based authentication.
Verification Procedures
Confirm passwordless authentication and remote graphical forwarding functionality.
# Verify passwordless login execution (returns remote hostname without password prompt)
ssh student@server1 "hostname"
# Verify X11 graphical display variable allocation over SSH
ssh -X student@server1 "echo \$DISPLAY"