sshd-logging-debug: OpenSSH authentication debugging and resolution
Lead paragraph: When OpenSSH authentication goes silent without obvious cause, enabling detailed logging is the fastest path to diagnosis. Understanding what happens at the sshd level lets you resolve the issue in minutes, not hours. This note shows how to enable LogLevel DEBUG3, locate records in the system, and decode typical access-rejection errors without wasting time on Google searches.
Enabling LogLevel DEBUG3 in sshd_config
By default LogLevel is set to INFO, which records only basic connection and disconnection events. DEBUG3 exposes the full event stream: from handshake initiation through key checks and PAM modules. Enabling it requires editing the config and restarting the daemon.
After debugging, revert the level to INFO or VERBOSE, as DEBUG3 generates significant data and can impact performance under high load.
If a daemon restart is unavailable, sending USR1 to the sshd process can activate debugging, but full effect comes only with restart using the new config.
Log entries appear in journald (when SyslogFacility is AUTHPRIV) and in /var/log/auth.log on classic distributions.
Searching and Reading Logs in journald and auth.log
Real-time log viewing:
Session‑specific records from the last few minutes:
On systems without systemd or in containers, logs may reside in /var/log/auth.log:
With DEBUG3, focus on lines starting with Authentication, pam, Accepted, Failed. They contain the rejection reason and the username.
Decoding Common Errors: invalid user, pam, authorized_keys
Typical log lines and their meaning:
| Log line | Meaning | Typical cause |
|---|---|---|
Failed password for invalid user root from 10.0.0.1 port 54322 ssh2 | auth | User does not exist in /etc/passwd or is locked out |
pam_unix(sshd:auth): authentication failure | pam | Wrong password, account lockout expired, PAM configuration |
Authorization failed for user deploy | authz | authorized_keys lacks a matching key, incorrect permissions |
Did not receive identification string | transport | Client did not send banner, old protocol, banner issue |
Key type RSA1 not allowed | kex | Client attempts obsolete key; KexAlgorithms may block |
Note the suffixes ,1 or ,2 after the reason — they indicate the specific check step (password check, key check, etc.).
Scenario: Locked-Out User
Account lockout via passwd -u or expired lockout time appears in the log as Permission denied (account locked). Status check:
LK in the output field means the account is locked. In /etc/shadow this shows as ! before the password hash.
Unlocking:
Or remove the lock flag directly in the shadow file (requires root):
After changes, restart sshd or send SIGHUP if the config permits.
Scenario: Wrong Password
Failed password for admin from 10.0.0.1 port 49152 ssh2 without invalid user means the user exists but password authentication failed. Causes:
- Typo or CapsLock
- Password change not yet propagated to
sshd(rare, usually instant) - PAM
authsettings requiring additional conditions (e.g.,pam_tally2blocks after N failures)
Reset the pam_tally2 counter (if installed):
Check password policy:
Scenario: Expired Key Life
OpenSSH does not expire user keys by default, but CA‑signed keys have valid-after/valid-before validity. If access is rejected due to a key, check:
CA key validity:
~/.ssh/authorized_keys rights and ownership:
The authorized_keys line must start with the key type (ssh-rsa, ecdsa-sha2-nistp256, etc.), followed by base64 data and a comment. Extra spaces or line breaks break parsing.
Diagnose via ssh:
Output shows which key was proposed and whether it was accepted. If the key is rejected, verify PubkeyAuthentication yes, IdentitiesOnly yes (when multiple keys exist in ssh-agent), and no symlinks in the ~/.ssh/ chain.
When working with DEBUG3, avoid storing verbose logs in production for extended periods. Shorten retention or filter by IP/user immediately after data collection.