🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Cybersecurity › Linux for Cybersecurity › Lesson 6
TEC-CYBE44-04 · Lesson 6 · 14.5 clock hours · lab

SSH, Remote Access, and Encryption in Transit

Objective. Students configure OpenSSH with key-based authentication and harden the SSH daemon against common attacks to protect remote administrative access.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Why SSH Security Matters

Secure Shell (SSH) is the primary protocol administrators use to manage Linux servers remotely. Because it exposes an authenticated, encrypted channel directly into a system, a poorly configured SSH daemon is one of the most targeted services on the internet. Automated bots continuously scan for open SSH ports and attempt credential attacks. Hardening SSH is therefore one of the first actions you should take on any production Linux system — and a core skill tested on CompTIA Security+ and CySA+.

How SSH Encryption Works

SSH uses asymmetric cryptography during the initial handshake to authenticate both server and client, then switches to a symmetric session key for bulk data transfer. When you connect to a server, your client verifies the server's host key against a known-hosts file, protecting you from man-in-the-middle attacks. The client can then prove its identity either by password or by a cryptographic key pair.

A key pair consists of a private key (kept secret on your local machine) and a public key (placed on the server in `~/.ssh/authorized_keys`). Authentication works by a challenge-response: the server encrypts a random value with your public key; only your private key can decrypt and answer it correctly. No password ever crosses the network.

Ed25519 is the recommended key algorithm today. It is based on elliptic-curve cryptography, produces short keys, resists certain side-channel attacks, and is faster than older RSA keys while providing strong security. CompTIA Security+ covers elliptic-curve concepts in its Cryptography and PKI domain.

Generating and Deploying a Key Pair

On your host machine, run:

```

ssh-keygen -t ed25519 -C "your_label"

```

Accept the default file path or choose a custom one. Add a strong passphrase — this encrypts the private key on disk, so theft of the file alone is not sufficient for access. Use `ssh-copy-id user@server_ip` to install the public key on the remote VM automatically. After that, `ssh user@server_ip` should succeed without a password prompt.

Hardening /etc/ssh/sshd_config

The SSH daemon reads its configuration from `/etc/ssh/sshd_config`. Always keep a second terminal session open and authenticated before restarting `sshd` — a misconfiguration could lock you out, so the open session is your safety net to fix errors without losing access.

Key directives to set:

After editing, validate syntax with `sshd -t` before restarting. Restart with `sudo systemctl restart sshd`. The CIS Benchmark for SSH provides a detailed, evidence-based checklist aligned with these controls.

Blocking Brute-Force Attacks with fail2ban

Even with password authentication disabled, attackers may probe for configuration weaknesses. fail2ban monitors log files (such as `/var/log/auth.log`) and uses configurable rules to ban IP addresses that exceed a failure threshold within a time window.

Install with `sudo apt install fail2ban`. The default jail configuration lives in `/etc/fail2ban/jail.conf`; create a local override at `/etc/fail2ban/jail.local` to survive package updates. A basic SSH jail entry sets `maxretry` (maximum failures before ban), `findtime` (the observation window), and `bantime` (how long the IP is blocked). After enabling the jail and restarting fail2ban, inspect status with:

```

sudo fail2ban-client status sshd

```

This command shows currently jailed IPs, total bans, and failed attempts — useful evidence for an incident report.

Logging and Verification

`/var/log/auth.log` (Debian/Ubuntu) records every authentication attempt, success or failure. Review it with `grep sshd /var/log/auth.log | tail -50` to see recent activity. CySA+ emphasizes log analysis as a core analyst skill; being able to correlate authentication failures with ban events demonstrates that your controls are functioning.

Safety and Professional Practice

Key terms8

Ed25519An elliptic-curve digital signature algorithm used for SSH key pairs; preferred over RSA for its strong security, small key size, and resistance to certain side-channel attacks.
Public Key AuthenticationAn SSH login method in which the server encrypts a challenge with the user's public key; only the holder of the matching private key can respond correctly, so no password travels over the network.
sshd_configThe main configuration file for the OpenSSH daemon, located at /etc/ssh/sshd_config, which controls all server-side SSH behavior including allowed users, authentication methods, and port settings.
PermitRootLoginAn sshd_config directive that, when set to 'no', prevents anyone from authenticating directly as the root user over SSH, forcing privilege escalation through a regular account.
fail2banA log-monitoring daemon that parses authentication logs and temporarily bans IP addresses that exceed a configured number of failed login attempts within a defined time window.
Asymmetric CryptographyA cryptographic system using mathematically linked key pairs — a public key and a private key — so that data encrypted with one key can only be decrypted with the other.
Idle Session TimeoutAn SSH configuration setting (ClientAliveInterval and ClientAliveCountMax) that automatically disconnects sessions that have been inactive for a specified period, reducing the risk of session hijacking.
CIS BenchmarkA set of consensus-based, prescriptive configuration guidelines published by the Center for Internet Security; the SSH Benchmark provides specific, auditable hardening recommendations for SSH daemons.
In class: Generate an Ed25519 SSH key pair on the host machine, copy the public key to the VM using ssh-copy-id, verify passwordless login, then demonstrate that password-based login is still possible — setting up the need for the next activity. · Edit /etc/ssh/sshd_config to disable root login, disable password authentication, restrict allowed users, change the default port, and set idle session timeouts; restart sshd and verify changes take effect without locking yourself out using a second terminal session. · Use fail2ban (install and configure) to block repeated failed SSH attempts; simulate brute-force attempts from a second VM using a looped ssh command, then inspect /var/log/auth.log and fail2ban-client status sshd to confirm the source IP is jailed.
Materials: Two Linux VMs on the same virtual network, OpenSSH server, fail2ban, text editor (nano/vim), CIS SSH Benchmark, CompTIA Security+ objective list (Cryptography and PKI domain)
Check: Instructor attempts password login and root login after hardening; both must fail; fail2ban jail must block the attack IP within the configured threshold; pass = all three hardening controls verified functional and /etc/ssh/sshd_config changes documented.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

CompTIA Security+ — Cryptography and PKI
1. A student generates an Ed25519 key pair and copies the public key to a server. Which file on the server stores the public key so SSH authentication can use it?
CompTIA Security+ — Implementation
2. After hardening sshd_config with 'PasswordAuthentication no', an administrator forgets to copy her public key first. What is the most likely result?
CompTIA Security+ — Implementation
3. Which sshd_config directive limits SSH access so that only specific named user accounts can connect, even if other accounts have valid credentials?
CompTIA CySA+ — Security Operations
4. A security analyst runs 'sudo fail2ban-client status sshd' and sees an attacker's IP in the 'Banned IP list'. What does this confirm?
CompTIA Security+ — Cryptography and PKI
5. Why is adding a passphrase to an SSH private key considered a defense-in-depth measure?
CompTIA Security+ — Implementation
6. An SSH server is configured with 'ClientAliveInterval 300' and 'ClientAliveCountMax 2'. Approximately how long will the server wait before disconnecting an unresponsive idle client?
CompTIA Security+ — Cryptography and PKI
7. Which of the following BEST describes why Ed25519 is preferred over older RSA 1024-bit keys for SSH authentication?
CompTIA CySA+ — Security Operations
8. A junior analyst notices hundreds of failed SSH login attempts in /var/log/auth.log from a single IP address over two minutes. Which CySA+ skill domain does analyzing this log entry PRIMARILY represent?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.