Use it when you cannot log in over SSH.
SSH Failure
SSH failures are problems connecting or authenticating with SSH: no connection, host key warnings, rejected keys or passwords, or immediate disconnects.
1. ssh -vvv user@host — connect, key exchange, or auth step?
2. Connection refused/timeout → ss -ltnp | grep :22 and firewall.
3. Server log: journalctl -u ssh -u sshd -e.
4. Keys: ~/.ssh 700, authorized_keys 600, home not group-writable.
5. sshd -T — AllowUsers/PermitRootLogin/PasswordAuthentication.
TCP 22 reachable → key exchange → host key accepted → user authenticated → session
For Linux Troubleshooting → SSH Failure, continue with the first unproven Topic check: Capture exact host/user/port/source and verbose client trace for one attempt. If that boundary is healthy, advance to the adjacent check: Correlate same-attempt sshd journal/auth logs and effective sshd configuration including Match rules. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.
Continue only after interpreting the current observation.Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
journalctl -u sshd --since "-30 min" --no-pagerPrimary Commands
Configuration and operational commands for this Topic.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
Healthy evidence: client and server evidence align through transport, trust, negotiation, authentication and requested session/subsystem, and the original SSH-dependent workload succeeds.
Step 2 Command read-back and what it shows Verify boundary
Read back Linux Troubleshooting → SSH Failure with journalctl -u sshd --since "-30 min" --no-pager. Known-good is the intended client attempt reaches sshd, authenticates through the expected method, opens the requested session/subsystem and the original SSH operation completes; broken/suspicious remains when the same stage-specific rejection recurs or the client still cannot complete the requested session despite an apparently healthy daemon. Classify success only when the expected discriminator is present, then repeat the original acceptance/workload test and one adjacent regression check. The recent sshd journal shows only events emitted by the daemon/unit on that host and window, but it does not show packets reached the host when no log exists or that every distribution logs SSH under the same unit name.
Step 3 Commands Verify boundary
ssh -vvv user@host
journalctl -u sshd -n 50
sshd -T | grep -iE 'permitroot|passwordauth'
Step 4 Verification and output interpretation Verify boundary
Existing fast checks for this Topic. - Capture exact host/user/port/source and verbose client trace for one attempt.
- Correlate same-attempt sshd journal/auth logs and effective sshd configuration including Match rules.
- Verify host key, algorithms, authorized_keys permissions/ownership, PAM/account and session/subsystem restrictions.
- Apply minimal correction and repeat the original SSH/SCP/SFTP/tunnel operation, not just login.
Step 5 Failure modes and next checks Narrow the fault
Step 6 Observation-driven branch and next-check logic Narrow the fault
Start from the exact failing target and timestamp. Capture journalctl -u sshd --since "-30 min" --no-pager before mutation. Branch on evidence: if no sshd event exists for the attempt, check listener/network/firewall path; if negotiation or host-key error appears, isolate crypto/client policy; if authentication/PAM/key rejection appears, inspect identity and key permissions; if authentication succeeds but session fails, inspect shell/subsystem/home permissions. Treat an error, failed result, unexpected state or missing object as a branch trigger and move only one boundary at a time.
Step 7 Common mistakes Narrow the fault
- Wrong permissions on
~/.ssh(700) orauthorized_keys(600).
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
ssh -v on the client shows where it stops; the server's journal (journalctl -u ssh/sshd) shows why it refused. Common causes: firewall, sshd not running, wrong key or permissions on ~/.ssh, AllowUsers/PermitRootLogin, account locked.
journalctl -b -p err— errors this bootsystemctl --failed— failed unitsdf -h; df -i— space and inodesss -tulpn— listening socketsdmesg -T | tail— recent kernel messages
ReferenceWhat it is1 section · depth on demand
Core model
Use verbose client evidence and server-side logs for the same attempt. Separate transport, host identity, crypto negotiation, user authentication, authorization/policy, PAM/account restrictions and session/subsystem execution.
ReferenceHow it works1 section · depth on demand
How it works
Linux Troubleshooting → SSH Failure owns client TCP reachability, sshd listener/process state, protocol/crypto negotiation, host-key trust, authentication/PAM policy, account authorization and session/subsystem startup. An SSH session progresses through transport establishment, SSH key exchange/host identity, user authentication and then session creation; each stage can fail while later stages remain untouched. Keep adjacent boundaries separate: DNS, firewall/NAT, time, directory/identity systems, authorized_keys permissions and shell/home filesystem state are independent adjacent boundaries. Diagnostic distinction: an authentication failure shows the daemon and transport were reached, while a connection timeout/refusal occurs before credentials are evaluated.
ReferenceImportant terms & boundaries4 sections · depth on demand
What this shows and what it does not
In depth
Troubleshooting SSH connections
SSH failures can be placed precisely by how far the connection gets. The ssh(1) manual page gives the main tool: -v, repeatable up to three times, prints each step. It also documents the exit status: 255 means ssh itself failed, and any other value comes from the remote command. The client tries authentication methods in a fixed order (GSSAPI, host-based, public key, keyboard-interactive, password), and the verbose output shows each attempt.
Where it stops, and why
| Message | Stage | Usual cause |
|---|---|---|
Connection timed out | TCP | Firewall, routing, wrong address, server down |
Connection refused | TCP | sshd not running, or not on that port |
No route to host | IP | Routing or a firewall reject |
Host key verification failed / REMOTE HOST IDENTIFICATION HAS CHANGED | Host key | Server reinstalled, IP reused, or an attack |
no matching host key type / no matching key exchange method | Negotiation | Old server or client; algorithm policy |
Permission denied (publickey) | Authentication | Key not offered, not authorised, or file permissions on the server |
Too many authentication failures | Authentication | The agent offers too many keys; use IdentitiesOnly yes |
| Logs in, then disconnects at once | Session | Shell set to nologin, ForceCommand, /etc/nologin |
Client and server views together
| Side | Command |
|---|---|
| Client | ssh -vvv user@host 2>&1 | grep -E "Connecting|Offering|Authentications|denied|debug1: Server" |
| Server log | journalctl -u ssh -u sshd --since -10min |
| Server effective configuration | sshd -T -C user=<u>,host=<h>,addr=<ip> |
| Server in debug mode on another port | sshd -d -p 2222 |
| Reachability | nc -zv host 22 |
admin$ ssh -v srv3 2>&1 | grep -E "Connecting|Offering|Authentications that can continue|denied"
debug1: Connecting to srv3 [10.30.0.13] port 22.
debug1: Offering public key: /home/admin/.ssh/id_ed25519_work ED25519 SHA256:Qb...
debug1: Authentications that can continue: publickey
admin@srv3: Permission denied (publickey).
srv3$ sudo journalctl -u sshd --since -5min | grep -E "admin|refused|Authentication"
sshd[4410]: Authentication refused: bad ownership or modes for file /home/admin/.ssh/authorized_keys
srv3$ ls -l /home/admin/.ssh/authorized_keys
-rw-rw-r-- 1 admin admin 412 Nov 28 15:58 /home/admin/.ssh/authorized_keys
srv3$ sudo chmod 600 /home/admin/.ssh/authorized_keys
Reading the example
The client offers the right key, and the server refuses it without saying why on the client side. The server's log has the reason: authorized_keys is group-writable, so sshd ignores it. That's why SSH authentication problems almost always need the server log, as well as ssh -v.
Documented example, not captured output.
How it works at runtime
SSH Failure is part of Linux Troubleshooting → SSH Failure. SSH Failure isolates an SSH connection from name resolution and TCP reachability through host-key trust, algorithm negotiation, authentication, sshd effective policy, session setup and requested subsystem/command.
Topic-specific state model. SSH Failure isolates an SSH connection from name resolution and TCP reachability through host-key trust, algorithm negotiation, authentication, sshd effective policy, session setup and requested subsystem/command.
Interpretation rule. - TCP/22 open ≠ SSH negotiation or authentication will succeed.
- Public key offered ≠ server accepted the key for that user/policy.
- Authentication succeeds ≠ shell/SFTP/forwarding is authorized or functional.
- Restarting sshd ≠ configuration is valid or failure root cause is fixed.
Method
SSH failure diagnosis:
ssh -vvv user@host # client side: which key, which auth methods
journalctl -u sshd -f # server side (ssh on Debian/Ubuntu)
sshd -t; sshd -T | grep -Ei 'allowusers|allowgroups|passwordauth|pubkey'
nc -zv host 22
| Message | Cause |
|---|---|
| Connection refused | sshd not running/listening, firewall REJECT |
| Connection timed out | Network/firewall DROP |
| Permission denied (publickey) | Key not in authorized_keys, wrong permissions (~/.ssh 700, file 600), wrong user |
| Host key verification failed | Changed host key — verify before removing from known_hosts |
| Too many authentication failures | Agent offers many keys — -o IdentitiesOnly=yes -i key |
sshd refuses keys if home or .ssh directories are group/world-writable (StrictModes).
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Linux Troubleshooting → SSH Failure. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.kernel.org/ · confidence 94%What changed and what may be affected
Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
SSH Failure operational reference
Topic-specific lookup boundaries, proof limits and next-step Evidence for SSH Failure.
| Lookup boundary | Topic-specific reference | Operational use |
|---|---|---|
| Scope / effective state | SSH Failure isolates an SSH connection from name resolution and TCP reachability through host-key trust, algorithm negotiation, authentication, sshd effective policy, session setup and requested subsystem/command. | Establish exactly what this Topic owns before crossing into another subsystem. |
| Fast verification | Pin symptom + exact time + host/boot/user → define scope + expected baseline → preserve original failing test → collect targeted kernel/process/service/storage/network/security/log evidence → identify first divergent boundary → make one minimal reversible change → repeat original test → verify adjacent regressions and retain before/after evidence. | Use the shortest evidence path first; a fast check is a boundary test, not blanket proof. |
| Verification chain | symptom + exact time → scope + baseline → reproduce original failure → collect first-party evidence → identify first failed boundary → minimal controlled change → repeat original test → regression/posture check | Trace requested/configured state through effective state to the observed workload result. |
| Failure boundary | SSH Failure troubleshooting is complete only when evidence localizes the first failed Linux boundary and the original failing workload passes after the smallest justified change; intermediate command success is not final proof. | Stop broad troubleshooting at the first boundary that is not supported by evidence. |
| Positive evidence | Correlated Linux troubleshooting evidence can establish this proof path: symptom + exact time → scope + baseline → reproduce original failure → collect first-party evidence → identify first failed boundary → minimal controlled change → repeat original test → regression/posture check | Use this observation only for the specific claim it actually supports. |
| Evidence limit | It does not independently prove behavior outside the captured host, boot, process/user, dependency, time or workload scope. SSH Failure troubleshooting is complete only when evidence localizes the first failed Linux boundary and the original failing workload passes after the smallest justified change; intermediate command success is not final proof. | Do not promote a local success signal into end-to-end or adjacent-dependency proof. |
| Next troubleshooting check | Continue from the first unproven boundary: reproduce the exact original failure, collect the owning subsystem evidence at the same time, change only the proven cause or prerequisite, then repeat the original workload and regression checks. | Continue to the next unresolved boundary while preserving the original test condition. |
SSH Failure · operational reference
Compact Linux state, persistence, verification and boundary reference for fast lookup.
| Reference boundary | SSH Failure |
|---|---|
| Topic path | Linux Troubleshooting → SSH Failure |
| Runtime state | SSH Failure isolates an SSH connection from name resolution and TCP reachability through host-key trust, algorithm negotiation, authentication, sshd effective policy, session setup and requested subsystem/command. |
| Fast checks | - Capture exact host/user/port/source and verbose client trace for one attempt. - Correlate same-attempt sshd journal/auth logs and effective sshd configuration including Match rules. - Verify host key, algorithms, authorized_keys permissions/ownership, PAM/account and session/subsystem restrictions. - Apply minimal correction and repeat the original SSH/SCP/SFTP/tunnel operation, not just login. |
| Verification chain | symptom + exact time → scope + baseline → reproduce original failure → collect first-party evidence → identify first failed boundary → minimal controlled change → repeat original test → regression/posture check Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary. |
| Failure boundary | SSH Failure troubleshooting is complete only when evidence localizes the first failed Linux boundary and the original failing workload passes after the smallest justified change; intermediate command success is not final proof. Boundary chain: process/context → userspace configuration → kernel subsystem/resource → device/network/filesystem dependency → effective state → original workload. |
| Persistence rule | Prove which configuration source owns the state, then prove that the running consumer loaded or generated the intended state. |