0:00–0:10
Recap
0:10–1:45
Lab 1D Parts 3–4
1:45–1:55
Bonus
1:55–2:00
Wrap
0:00 – 0:10 Recap · 10 min

Key auth confirmed, sshd_config walkthrough

0:10 – 1:45 Lab 1D Parts 3–4 · 95 min

Apply production-grade SSH hardening: disable password auth, change port, banners, timeout, access controls

Part 3a — Disable password authentication (15 min)

Lock-out prevention: Always keep an existing SSH session open when changing sshd_config. If the service fails to restart or you accidentally lock yourself out, the existing session keeps you in. The Hyper-V console is the last resort — connect directly to the VM and fix the config from there.

Part 3b — Change the SSH port (10 min)

Part 3c — Authentication security settings (15 min)

Part 4a — Configure the idle timeout (15 min)

Part 4b — Configure login banners (20 min)

Lab 1D complete when: Password authentication rejected on all three servers. SSH available on new port. LoginGraceTime, MaxAuthTries, MaxSessions, PermitRootLogin, and AllowUsers all set. Idle timeout active. SSH banner appears before login. MOTD penguin appears after login.
1:45 – 1:55 Bonus · 10 min

Reading auth.log — a preview of fail2ban

1:55 – 2:00 Wrap · 5 min

Learning outcomes — by end of Day 4, students can…

Disable password authenticationSet PasswordAuthentication no in sshd_config and verify rejection with a forced password attempt
Apply security directivesConfigure LoginGraceTime, MaxAuthTries, MaxSessions, PermitRootLogin, and AllowUsers with appropriate values
Configure idle timeoutSet TMOUT in /etc/profile as readonly/exported and verify it terminates idle sessions
Deploy login bannersCreate and configure both the SSH pre-auth banner and the post-auth MOTD
Read auth.logIdentify failed login attempts, source IPs, and failure reasons in /var/log/auth.log

Common issues and fixes

IssueLikely causeFix
Password auth still works after setting PasswordAuthentication noSecond PasswordAuthentication directive in a Match block at file bottom, or PAM overrideSearch for all occurrences: grep -n PasswordAuthentication /etc/ssh/sshd_config. Also check /etc/ssh/sshd_config.d/ — Ubuntu 22+ may include a drop-in file that overrides the main config
Locked out after changing SSH portWindows Terminal profile not updated, or firewall blocking new portConnect via Hyper-V console. Update the port in sshd_config back to 22 temporarily, restart, then update Windows Terminal and change the port again
AllowUsers blocks the student accountUsername typo or case sensitivity (Linux usernames are case-sensitive)Verify exact username: whoami on the server. Correct the AllowUsers line and restart SSH
SSH banner not appearingBanner directive not pointing to the correct file path, or sshd not restartedVerify the file exists: ls -l /etc/ssh_banner. Check the directive in sshd_config matches the path exactly. Restart SSH
TMOUT not working in existing sessionsTMOUT only applies to new sessionsLog out completely and open a new SSH session. The TMOUT setting is read at shell startup
← Day 3 Lab 1D Handout Day 5 →