Two SSH Errors Worth Understanding
Host key negotiation failures and private key permissions — what the error messages actually say, and how the rules differ on Windows, macOS and Linux.
I have been building wTerm2, a terminal emulator for Windows written in Rust, together with Claude. It registers SSH and AWS SSM connections as profiles so you can attach with one click.
Which meant that for weeks, my job was mostly watching connections fail.
Two of those failures turned out not to be my program’s fault at all. Type ssh in any console and you get the same thing. So whether or not you are writing a terminal, if you use SSH you will eventually meet both:
no matching host key type found— dropped instantlyPermission denied (publickey)— even though you passed the right key
In both cases the error message already contains half the answer. The wording is just unfamiliar enough that most of us go dig in the wrong place. I certainly did.
Part 1: no matching host key type found
What you see
Connecting to an older server drops before any authentication prompt:
Unable to negotiate with x.x.x.x port 22: no matching host key type found.
Their offer: ssh-rsa,ssh-dssMy first reaction was:
It says key, but I’m not even using a key file — just a username and password.
That is exactly the trap. The word “key” makes you suspect your private key. The key in this message is the server’s ID card, not yours.
Read the whole sentence and half the problem is gone
There are three clues in that short message.
Unable to negotiate — this is the negotiation phase. Nobody has tried to log in yet.
host key type — not your key. The server's host key.
Their offer: — the list the server put on the table: "these are the algorithms I can do."
So the message reads:
The server says it can do A and B. My ssh accepts neither. There is nothing to talk about.
Your username and password never entered the picture. Which is why checking them gets you nowhere.
Why it broke without anything changing
The name ssh-rsa is misleading. It does not mean "an RSA key." It means the signature scheme that uses SHA-1.
SHA-1 fell in 2017, when a real collision was produced. OpenSSH 8.8 (September 2021) disabled ssh-rsa by default. ssh-dss (DSA) went long before that, and OpenSSH 10 dropped it from the build entirely.
So:
- The server is old and only offers
ssh-rsaandssh-dss - Your client is current and refuses both
- Negotiation fails
Notice what this means: the server did not change — your machine did. That is why it reads as “this worked yesterday.” A Windows update that bumped OpenSSH is a very common trigger.
Diagnosis: -Q and -G answer different questions
This tripped me up, so it is worth being explicit.
ssh -Q lists what your client is capable of:
ssh -Q HostKeyAlgorithmsssh -G shows what is actually enabled right now:
ssh -G example.com | grep -i hostkeyalgorithmsI measured both on my Mac (OpenSSH 10.2):
ssh-rsainssh -Qoutput: yesssh-rsainssh -Goutput: nossh-dssin either: no — removed in OpenSSH 10
Appearing in -Q does not mean it works. It means your client could, but it is switched off. An option can switch it back on.
The reverse matters more: if it is not in -Q, no option will bring it back. That is ssh-dss today. On OpenSSH 10, adding +ssh-dss accomplishes nothing — you need to fix the server or use an older client.
Start by knowing what you have:
ssh -VFix 1: try it once from the command line
ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa user@hostDo not lose the +. It is the most important character in this article.
HostKeyAlgorithms=ssh-rsa— replaces the default list. You just broke every modern server for this config.HostKeyAlgorithms=+ssh-rsa— appends to the default list. Modern servers keep working.HostKeyAlgorithms=-ssh-rsa— removes from the list.HostKeyAlgorithms=^ssh-rsa— moves it to the front (priority only).
A lot of the snippets you will find online drop the +. The damage shows up later, on other hosts, which makes it hard to connect cause and effect.
PubkeyAcceptedAlgorithmsis the name from OpenSSH 8.5 onward. On anything older usePubkeyAcceptedKeyTypes. Check withssh -V.
Fix 2: put it in the config file (do this)
Typing options every time is not a plan. Scope it per host:
- Linux, macOS:
~/.ssh/config - Windows:
C:\Users\<name>\.ssh\config, or$env:USERPROFILE\.ssh\config - WSL: the
~/.ssh/configinside WSL — a completely separate file from the Windows one
Host oldserver
HostName x.x.x.x
User myaccount
Port 22
HostKeyAlgorithms +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsaThen just:
ssh oldserverThe Host block is the point. Do not set this globally. Every other server keeps negotiating under modern rules.
On Windows, if the folder does not exist yet:
New-Item -ItemType Directory -Force "$env:USERPROFILE\.ssh"
notepad "$env:USERPROFILE\.ssh\config"When saving from Notepad, quote the filename —
"config". Otherwise you getconfig.txtand ssh never reads it. This catches people constantly.
Other things break in the same handshake
Old servers are usually old in several places at once. Match the option to the message:
no matching host key type→HostKeyAlgorithms=+...no matching key exchange method→KexAlgorithms=+diffie-hellman-group14-sha1no matching cipher→Ciphers=+aes128-cbcno matching MAC→MACs=+hmac-sha1- key auth rejected specifically →
PubkeyAcceptedAlgorithms=+ssh-rsa
Ask your own client what exists:
ssh -Q kex # key exchange
ssh -Q cipher # encryption
ssh -Q mac # integrity
ssh -Q key # key typesIn wTerm2 I do not hardcode these lists — I shell out to ssh -Q. A hardcoded table goes stale when OpenSSH moves, and worse, it can offer the user a value their machine does not support, so picking it still fails.
One step further: the app scrapes Their offer: ... out of the failed pane and marks those entries in the picker. The user just saw that line. Showing the same information where the choice is made beats adding another paragraph of help text.
The real fix is on the server
Options are a workaround. If you control the server, do this instead.
Option A — add an ed25519 host key. Simplest.
sudo ssh-keygen -A
sudo systemctl restart sshdssh-keygen -A only generates host key types that are missing. It does not overwrite existing keys, so nobody's known_hosts breaks.
If the line is commented out in /etc/ssh/sshd_config, uncomment it:
HostKey /etc/ssh/ssh_host_ed25519_keyOption B — upgrade OpenSSH. Correct, but think twice on a production box.
Keep one session open while you change sshd config. If you break it, new connections fail but existing sessions survive — and that session is how you undo it.
Know what you are giving up
This option permits SHA-1 signatures on the host key.
The host key is how you know the machine answering is the machine you meant. Weaken its signature and you weaken man-in-the-middle protection. More so if you log in as root.
So I put that in the app’s UI and its docs, next to the option itself:
Making the connection work without mentioning the security cost takes the decision away from the user.
In practice:
- Internal appliance being replaced next quarter — take the workaround.
- Production box on the public internet — fix the server.
- Not sure — use the workaround now, and put the server upgrade on a calendar.
Part 2: Permission denied with the right key
What you see
This is the actual error I hit:
$ ssh -p 22 -i C:\dev\oraclevm2.ppk ubuntu@x.x.x.x
Bad permissions. Try removing permissions for user: BUILTIN\Users on file C:/dev/oraclevm2.ppk
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
Load key "C:\dev\oraclevm2.ppk": bad permissions
ubuntu@x.x.x.x: Permission denied (publickey).Two problems are stacked here.
ssh.execannot read.ppk— that is PuTTY's own format- The file permissions are too open — Windows ACL inheritance
And the order matters. Fixing permissions first still fails, because of the format. I did exactly that and spent a while asking why it was still broken.
Layer 1: OpenSSH cannot read .ppk
PuTTY uses its own format. ssh reads OpenSSH format only. Keys handed out by Oracle Cloud, or sitting in older internal docs, are frequently .ppk.
Get talkit’s stories in your inbox
Join Medium for free to get updates from this writer.
Converting on Windows (PuTTYgen):
- Run PuTTYgen
Load→ pick the.ppk(switch the file filter to "All Files" or you will not see it)- Menu: Conversions → Export OpenSSH key
- Save as
.pem, or with no extension
Converting on macOS / Linux:
# Ubuntu/Debian: sudo apt install putty-tools
# macOS: brew install putty
puttygen key.ppk -O private-openssh -o key.pem
chmod 600 key.pemYou can tell which format you have by opening the file and reading line one:
PuTTY-User-Key-File-3:→ PuTTY. Convert it.-----BEGIN OPENSSH PRIVATE KEY-----→ OpenSSH, current format-----BEGIN RSA PRIVATE KEY-----→ PEM, which OpenSSH reads
Layer 2: the permission rules are not the same across OSes
The question I asked Claude was:
Is 601 fine? And what is the equivalent on Windows?
The two systems do not resemble each other at all.
Linux and macOS
OpenSSH’s check is one line:
(mode & 0o077) != 0 → refuseAny group or other bit at all. Read, write, execute — it does not matter which.
600— passes. Owner read/write.400— passes. Owner read.601— refused. One "other execute" bit.640— refused. Group read.644— refused. Group and other read.660— refused.
601 being refused is the part people get wrong. It is not "just the execute bit."
chmod 600 ~/.ssh/id_ed25519
chmod 700 ~/.sshCheck the directory too. A 755 ~/.ssh will bite you in some setups. Use 700.
One honest caveat. While writing this I measured it again on macOS with OpenSSH 10.2:
ssh -ihappily read a key at644, whilessh-addrefused it with the bigUNPROTECTED PRIVATE KEY FILE!banner. On Windows,ssh -irefused outright — that is the error above.So where the check fires varies by platform and version. This is the classic reason “it works on my Mac” fails on Windows or on a server. Just keep everything at
600and stop thinking about it.
Windows
Windows has no numeric mode at all. chmod 600 is meaningless there, and a chmod run from WSL does not properly apply to a file on the Windows side.
Windows OpenSSH checks the DACL instead:
Refuse if any principal other than the owner,
SYSTEM, orAdministratorsappears in the list.
The usual culprits:
BUILTIN\UsersEveryoneAuthenticated Users
Look at the current state:
icacls "C:\path\to\key.pem"Fixing it is two commands, and the order matters:
icacls "C:\path\to\key.pem" /inheritance:r
icacls "C:\path\to\key.pem" /grant:r "$env:USERNAME:(R)"/inheritance:r— cuts off entries inherited from parent folders/grant:r "user:(R)"— grants read to you only (:rreplaces existing entries)
Break inheritance first. Reverse the order and the inherited entries survive, and you are refused again. That is the order my app runs them in.
The real cause was where the file lived
My key was in C:\dev\. That directory inherits the loose ACL from the drive root. Put a key there and you will almost always get bitten.
Moving the key to %USERPROFILE%\.ssh\ connected immediately. That folder is owner-only from the start, so there is nothing to inherit.
New-Item -ItemType Directory -Force "$env:USERPROFILE\.ssh"
Move-Item "C:\dev\mykey.pem" "$env:USERPROFILE\.ssh\"A layout that cannot recur beats a button that fixes it. Telling people to click “tighten permissions” was worse advice than telling them where to put the file.
If you use WSL, one more
Windows files under /mnt/c/... appear as 777 to WSL by default. ssh refuses them unconditionally, and chmod does not stick.
# this will not help
chmod 600 /mnt/c/Users/me/key.pemCopy the key into WSL instead:
mkdir -p ~/.ssh && chmod 700 ~/.ssh
cp /mnt/c/Users/me/key.pem ~/.ssh/
chmod 600 ~/.ssh/key.pemThere is a metadata mount option in /etc/wsl.conf that also works, but copying is simpler and goes wrong less often.
And one for macOS: the keychain
macOS can hold a passphrase-protected key in the keychain:
ssh-add --apple-use-keychain ~/.ssh/id_ed25519Then in ~/.ssh/config, so it survives reboots:
Host *
UseKeychain yes
AddKeysToAgent yesOlder articles show
-K. The current spelling is--apple-use-keychain.
Narrowing down Permission denied (publickey)
That message has several causes. This ordering gets there fastest:
ssh -vvv -i key.pem user@hostWhat to look for in the log:
bad permissions/UNPROTECTED PRIVATE KEY→ permissionsLoad key ...: invalid format→ format (a.ppk, or a corrupted file)Offering public keyfollowed by rejection → the server'sauthorized_keysno mutual signature algorithm→ algorithms — that is Part 1 territory- the key is never offered at all → try
IdentitiesOnly=yes
That last one is more common than you would think. With several keys in ssh-agent, ssh offers the wrong ones first and the server cuts you off for too many attempts.
ssh -o IdentitiesOnly=yes -i key.pem user@hostQuick reference
no matching host key type→ confirm withssh -o HostKeyAlgorithms=+ssh-rsa, then move it into~/.ssh/configunder aHostblock- It is in
-Qbut still fails → supported yet disabled. An option turns it on. - It is not in
-Q→ no option can help. Fix the server. UNPROTECTED PRIVATE KEY(macOS/Linux) →chmod 600 key,chmod 700 ~/.sshBUILTIN\Users(Windows) →icacls /inheritance:r, then/grant:r "user:(R)"- A key under
/mnt/cin WSL → copy it into WSL, thenchmod 600 invalid format→ it is a.ppk. Convert with PuTTYgen.- It keeps coming back → move the key to
~/.sshor%USERPROFILE%\.ssh
What I took away
Read the error message to the end and half the problem is solved. host key type and Their offer were already telling me "before authentication" and "the server's list." I saw the word key and went to look at my private key.
When you hand someone a workaround, tell them what it costs. Making the connection work while staying quiet about the weakened MITM protection takes the decision away from them.
Ask the system instead of hardcoding a list. One ssh -Q beats a table you have to maintain, and it never goes stale. Also: -Q and -G answer different questions, and confusing them wastes an afternoon.
A layout that cannot recur beats a workaround. “Put the key in ~/.ssh" was a better answer than any button.
And one more, from the app-building side. The fix has to live where the problem is visible. I first put the “tighten permissions” button in the connection editor — but the error appears in the terminal pane. I even replied to the bug report saying “the button is in the editor.” It should have been next to the error from the start. Now it is:
The process exited with code 255 [Restart] [Close]
Private key permissions are too open [Tighten key permissions]Thanks for reading.
Commands and behavior here were verified against OpenSSH 10.2 in August 2026. The error messages are ones I actually hit; the server addresses are my own.
![[Performance Testing Basics] A Comprehensive Guide from Concept to JMeter Application](https://miro.medium.com/v2/resize:fit:1358/format:webp/1*86IQ4up1kZBdt2xO-oWZFg.png)





