SSH error messages are terse. Most of them mean exactly one specific thing, but you have to know which thing. This is a reference list of the 20 errors you’ll actually hit running Ubuntu servers in production and at home, with diagnoses and fixes for each.
Tested on: Ubuntu Server 24.04.5 LTS (cloud image, OpenSSH 9.6p1) in a lab VM on 15 November 2026. Errors 1 to 5, 9 to 12, 14, 17 and 18 were reproduced there, and the screenshots are from that run. The rest are described from OpenSSH behaviour and not reproduced here (they need a second host, a fail2ban ban or a PuTTY client). 22.04 and 26.04 were not re-run. Most errors apply to other Linux distros and to OpenSSH on macOS and Windows.


1. Connection refused
ssh: connect to host 192.0.2.50 port 22: Connection refused
Cause: Server is reachable but nothing is listening on port 22.
Fix:
sudo systemctl status ssh(orssh.socketon 24.04+). Is it running?sudo ss -tnlp | grep :22. Is anything actually bound to port 22?- Did you change the port in
sshd_config? Usessh -p NEWPORT user@host. - On Ubuntu 24.04 and 26.04, a changed
Portdoes nothing until the socket is regenerated:sudo systemctl daemon-reloadthensudo systemctl restart ssh.socket. Restartingssh.servicealone leaves SSH on the old port, which is the usual cause of “refused after I changed the port”. - On a fresh install: did you actually
apt install openssh-server? It’s not installed by default on Ubuntu Desktop.

2. Connection timed out
ssh: connect to host 203.0.113.10 port 22: Connection timed out
Cause: Packets aren’t reaching the server. Firewall, routing, or the server is offline.
Fix:
- Can you ping the server?
ping host. If no, network/routing issue. - If ping works but SSH times out, firewall is blocking. Check
ufw statuson the server. - Cloud server: check the cloud provider’s security group / network ACL.
- Home network: check the router’s port forwarding rules.

3. Permission denied (publickey)
user@host: Permission denied (publickey).
Cause: The server only accepts SSH key auth and your key isn’t being offered or accepted.
Fix:
ssh -v user@host 2>&1 | grep -A2 'Offering public key'. Which keys are being offered?- On the server, check
~/.ssh/authorized_keysexists for the user, contains your key, and has correct permissions (600, owner = the user). - Server-side directory perms: use
700for~/.sshand600for~/.ssh/authorized_keys. With the defaultStrictModes yes, sshd ignores the key if these (or the home directory) are writable by group or others; the client just sees this error, and the reason is only in the server log. sudo sshd -T | grep pubkeyauthentication. Must beyes(it is by default; this catches anoinsshd_configor a drop-in under/etc/ssh/sshd_config.d/).

4. Permission denied (publickey,password)
user@host: Permission denied (publickey,password).
Cause: Both auth methods failed. You typed the wrong password, OR the username doesn’t exist on the server.
Fix:
- On the server, run
whoamito confirm the username you should use. - Try the password again, slowly. Check Caps Lock.
- If you’re certain the credentials are right, check
/etc/ssh/sshd_configforAllowUsers. If it’s set, only listed users can SSH in.

5. Host key verification failed
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Cause: The server’s host key has changed since the last time you connected.
Fix:
- Most innocent: server was reinstalled or rebuilt, so it has a new host key.
- Less innocent: someone is doing a man-in-the-middle attack.
- To clear the cached old key:
ssh-keygen -R 192.0.2.50 - Reconnect, accept the new fingerprint (verify it’s correct first if security is a concern).


6. Connection reset by peer
kex_exchange_identification: read: Connection reset by peer
(Older OpenSSH releases print ssh_exchange_identification instead of kex_exchange_identification.)
Cause: Server actively dropped the TCP connection during handshake.
Fix:
- A common cause:
fail2banor similar tool banned your IP (depending on its ban action, a ban can also show up as “Connection refused” or a timeout). Wait the configured ban time, or unban from another machine:sudo fail2ban-client unban 203.0.113.10. - Less common:
sshdhas a misconfiguration causing it to crash on connect. Checkjournalctl -u ssh.serviceon the server. MaxStartups: sshd starts dropping new unauthenticated connections when too many are open at once (default10:30:100). On an internet-facing server a burst of bot traffic can trigger this for legitimate users too.
7. Port 22: No route to host
ssh: connect to host 203.0.113.10 port 22: No route to host
Cause: Network layer can’t find the destination. Either the server is down, or routing/DNS resolves to an unreachable network.
Fix:
- Check the IP is correct.
dig hostif using a hostname. traceroute hostto see where the route dies.- Cloud server: confirm it’s running in the provider console.
8. kex_exchange_identification: Connection closed by remote host
Cause: Server accepted the TCP connection but closed it before the SSH handshake completed.
Fix:
- Same checklist as #6 (fail2ban, sshd misconfiguration).
- Check
/etc/hosts.denyon the server. If your IP is listed there, sshd refuses you instantly. - Server out of disk space (no, really: sshd can fail to fork new connections if
/is full).
9. Permissions are too open
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0644 for '/home/you/.ssh/id_ed25519' are too open.
Cause: SSH refuses to use a private key that’s readable by anyone other than you.
Fix:
chmod 600 ~/.ssh/id_ed25519
chmod 700 ~/.ssh

10. Could not open a connection to your authentication agent
Could not open a connection to your authentication agent.
Cause: ssh-add was run but ssh-agent isn’t started.
Fix:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519

11. WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED
Same as #5. See above.
12. ssh: Could not resolve hostname
ssh: Could not resolve hostname server: Name or service not known
ssh: Could not resolve hostname server: Temporary failure in name resolution
Both endings are real. Which one you get depends on the resolver: Name or service not known when it answers that the name does not exist, Temporary failure in name resolution when the lookup itself fails or gets no answer. On the 24.04 lab VM, a single-word name went to the lab’s forwarder and returned the second form.
Cause: DNS lookup failed.
Fix:
- Check the hostname is spelled right.
dig serverto see if DNS resolves.- For
.localmDNS hostnames: needs avahi-daemon running on the server and mDNS name resolution on the client. May not work over corporate VPNs or cellular. - Use the IP address directly to bypass DNS.

13. Read from socket failed: Connection reset by peer
Cause: Network connection dropped mid-session. Could be router restart, ISP outage, or server side.
Fix:
- Reconnect.
- For sessions you don’t want to lose: use
tmuxorscreenon the server.ssh user@hostthentmux. If the SSH session drops, reconnect andtmux attach. You’re back in your session with all your work.
14. error: kex_exchange_identification: client sent invalid protocol identifier
Cause: Something is connecting to port 22 that isn’t SSH. Often a misconfigured load balancer or health check probing the wrong protocol.
Fix:
- Check what’s hitting your SSH port in the server log:
sudo journalctl -u ssh -n 50 --no-pager | grep -iE 'banner exchange|kex_exchange'. On Ubuntu 24.04 (OpenSSH 9.6) a client that sends something other than SSH is logged asbanner exchange: Connection from <ip> port N: invalid format, with nokexin the line, so a search forkexalone finds nothing. Thekex_exchange_identificationwording is what other OpenSSH builds and clients print; it did not appear on this server. - If it’s a load balancer / monitoring tool, point it elsewhere.

15. Could not chdir to home directory
Could not chdir to home directory /home/username: No such file or directory
Cause: The user account exists in /etc/passwd but their home directory is missing or unreadable. You still get a shell, but it starts in /, and key login fails because ~/.ssh/authorized_keys is not there.
Fix:
ls -ld /home/usernameon the server. Does the home directory exist?- If missing, recreate it:
sudo mkhomedir_helper username(or restore from backup).
16. Disconnected: No supported authentication methods available
Cause: Server has disabled every auth method this client offers. Common after disabling password auth without first deploying keys. (This wording comes from PuTTY; the OpenSSH client shows Permission denied (publickey) for the same situation.)
Fix:
- This is the “you locked yourself out” message. You need physical/console access to fix
sshd_config. - Edit
/etc/ssh/sshd_configfrom the local console: re-enablePasswordAuthentication yestemporarily, restart sshd, deploy your key, then disable passwords again.
17. Bind to port 22 on 0.0.0.0 failed: Address already in use
Cause: sshd can’t start because something else is on port 22.
Fix:
sudo ss -tnlp | grep :22. Find what’s using the port.- On Ubuntu 24.04 and 26.04, expect to see
systemdin that list (as well assshdonce a connection has started it): that isssh.socketholding the port on sshd’s behalf, which is normal. The error usually means sshd was started by hand alongside it; manage SSH withsystemctlrather than runningsshddirectly. - If it is a different program, stop that program or move one of them to another port.
- Do not run
pkill sshdto clear it. On a remote server it can kill the sshd process carrying your own session. If a stray sshd really is holding the port, kill only that PID (the onessshows), ideally from the console.

18. Too many authentication failures
Received disconnect from 203.0.113.10 port 22:2: Too many authentication failures
Cause: Your SSH agent has many keys, SSH offers them all, server rejects after MaxAuthTries (default 6).
Fix:
- Specify exactly which key to use:
ssh -i ~/.ssh/id_ed25519 -o IdentitiesOnly=yes user@host - Or set up
~/.ssh/configwith explicit per-hostIdentityFileandIdentitiesOnly yes.

19. Welcome message printed but immediate disconnect
Cause: The user’s login shell is broken. SSH authenticates, then tries to start the shell, and the shell exits immediately.
Fix:
- Check the user’s shell in
/etc/passwd(last field). Is it a valid shell?/bin/bashis the safe default. - Check
~/.bashrcand~/.bash_profilefor a syntax error orexitstatement. - Try logging in with a different shell:
ssh user@host -t '/bin/sh'.
20. ssh.socket vs ssh.service confusion (Ubuntu 24.04 and 26.04)
Cause: Tutorial says systemctl status ssh shows Active: active (running). On 24.04 and 26.04, systemctl status ssh shows Active: inactive (dead) until the first connection after boot, because socket activation hasn’t fired yet. systemctl status ssh.socket is the one that shows Active: active (listening).
Fix:
- This is normal on 24.04+ with socket activation. SSH is working.
- See the Enable SSH on Ubuntu Server pillar for the full explanation. Short version: the socket waits for a connection, then starts the service, which then keeps running.
- The same split catches port changes: on 24.04 and 26.04, apply a new
Portwithsudo systemctl daemon-reloadandsudo systemctl restart ssh.socket, not by restartingssh.service.
Where you’ll meet this at work
The same errors turn up behind managed access, with a different place to fix them. In Azure, a “Connection timed out” to a Linux VM is very often a missing network security group rule for TCP 22 rather than anything wrong with sshd, and Microsoft’s own SSH troubleshooting guide starts there. Azure Bastion gives SSH through the portal so the VM needs no public port, and Microsoft Entra ID sign-in for Linux VMs replaces copied keys with OpenSSH certificates tied to a work identity.
What maps one to one: refused, timed out, host key changed and could not resolve mean the same thing at the protocol level, and the first checks are the same. What does not: with Entra sign-in, a “Permission denied” is often a missing role assignment (Virtual Machine Administrator Login or Virtual Machine User Login) rather than a bad authorized_keys. Having broken and fixed each of these on your own server is what lets you tell which layer is failing.
Companion guides: Enable SSH on Ubuntu Server, SSH Key Authentication on Ubuntu, SSH Hardening, Fail2ban for SSH. If you’ve hit an SSH error not on this list, drop it in the comments and I’ll add it.
The Complete SSH Series
Getting connected
- Enable SSH on Ubuntu Server
- Enable SSH on Raspberry Pi
- SSH Essentials: Remote Administration
- SSH from Windows to Ubuntu
Authentication and hardening
File transfer and tunnelling
Reference
- SSH Configuration Guide (overview)
- 20 Common SSH Errors (you are here)
Before you expose any of this: the seven steps that decide whether a home lab survives contact with the internet, in the order they matter, are in How to Secure a Homelab Network in 2026.
RTFM Apparel · printed in the UK

ReadTheManual is run, written and curated by Eric Lonsdale.
Eric has over 20 years of professional experience in IT infrastructure, cloud architecture, and cybersecurity, but started with PCs long before that.
He built his first machine from parts bought off tables at the local college campus, hoping they worked. He learned on BBC Micros and Atari units in the early 90s, and has built almost every PC he’s used between 1995 and now.
From helpdesk to infrastructure architect, Eric has worked across enterprise datacentres, Azure environments, and security operations. He’s managed teams, trained engineers, and spent two decades solving the problems this site teaches you to solve.
ReadTheManual exists because Eric believes the best way to learn IT is to build things, break things, and actually read the manual. Every guide on this site runs on infrastructure he owns and maintains.
Enjoyed this guide?
New articles on Linux, homelab, cloud, and automation every 2 days. No spam, unsubscribe anytime.





