Objective. Students configure OpenSSH with key-based authentication and harden the SSH daemon against common attacks to protect remote administrative access.
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.
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+.
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.
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.
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.
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.
`/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.
Answer each question, then check it. Nothing is recorded; this is your own practice.
A free tech program — complimentary, as our commitment to get America working. Help us build VoTechWorks. Tell us what works, what doesn’t, and what you want to learn.