SSH Banner, Logging, and Monitoring
You'll learn how to set warning banners, configure detailed SSH logging, and monitor authentication attempts to detect and deter threats.
Why SSH Visibility Matters
SSH is often a primary target for attackers. Just as a "No Trespassing" sign warns visitors and a security camera deters criminals, SSH banners warn users while logging and monitoring capture evidence of suspicious activity. Without proper visibility, you're flying blind—unable to detect brute-force attacks, unauthorized access attempts, or policy violations.
Setting Warning Banners
SSH supports two types of banners:
Pre-authentication banner (Banner /etc/ssh/banner.txt): Displayed before login. Should contain legal warnings about authorized use only. This establishes no expectation of privacy and can be legally important.
Post-authentication MOTD (Message of the Day): Shown after successful login via /etc/motd.
Banners serve both legal and deterrent purposes—they inform users that activity is monitored and unauthorized access is prohibited.
Verbose Logging Configuration
The LogLevel directive in /etc/ssh/sshd_config controls logging verbosity:
INFO(default): Basic connection informationVERBOSE: Includes key fingerprints and authentication detailsDEBUG,DEBUG1,DEBUG2,DEBUG3: Increasingly detailed for troubleshooting
Use LogLevel VERBOSE for production security monitoring. This captures authentication method, source IP, username, and key fingerprints—critical for forensics.
Monitoring Authentication Attempts
SSH logs typically go to /var/log/auth.log (Debian/Ubuntu) or /var/log/secure (Red Hat/CentOS). Monitor for:
- Repeated failed login attempts (brute force)
- Root login attempts (when disabled)
- Successful logins from unexpected locations
- Invalid user attempts (username enumeration)
Use tools like fail2ban to automatically ban IPs with excessive failed attempts, or centralize logs to a SIEM for broader correlation.
Key Takeaway: Warning banners provide legal protection and deterrence, verbose logging captures critical authentication details, and active monitoring of SSH logs enables rapid detection of attacks and unauthorized access attempts.