Sitemap
talkit

talkit

Application architect. I find out why large systems are slow — load testing, bottleneck analysis, APM and log platforms, and the reports that lead to fixes.

Two SSH Errors Worth Understanding

10 min readAug 11, 2026

--

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 instantly
  • Permission 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-dss

My 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-rsa and ssh-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 HostKeyAlgorithms

ssh -G shows what is actually enabled right now:

ssh -G example.com | grep -i hostkeyalgorithms

I measured both on my Mac (OpenSSH 10.2):

  • ssh-rsa in ssh -Q output: yes
  • ssh-rsa in ssh -G output: no
  • ssh-dss in 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 -V

Fix 1: try it once from the command line

ssh -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa user@host

Do 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.

PubkeyAcceptedAlgorithms is the name from OpenSSH 8.5 onward. On anything older use PubkeyAcceptedKeyTypes. Check with ssh -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/config inside 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-rsa

Then just:

ssh oldserver

The 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 get config.txt and 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-sha1
  • no matching cipher → Ciphers=+aes128-cbc
  • no 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 types

In 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 sshd

ssh-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_key

Option 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.

  1. ssh.exe cannot read .ppk — that is PuTTY's own format
  2. 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):

  1. Run PuTTYgen
  2. Load → pick the .ppk (switch the file filter to "All Files" or you will not see it)
  3. Menu: Conversions → Export OpenSSH key
  4. 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.pem

You 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  →  refuse

Any 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 ~/.ssh

Check 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 -i happily read a key at 644, while ssh-add refused it with the big UNPROTECTED PRIVATE KEY FILE! banner. On Windows, ssh -i refused 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 600 and 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, or Administrators appears in the list.

The usual culprits:

  • BUILTIN\Users
  • Everyone
  • Authenticated 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 (:r replaces 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.pem

Copy the key into WSL instead:

mkdir -p ~/.ssh && chmod 700 ~/.ssh
cp /mnt/c/Users/me/key.pem ~/.ssh/
chmod 600 ~/.ssh/key.pem

There 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_ed25519

Then in ~/.ssh/config, so it survives reboots:

Host *
UseKeychain yes
AddKeysToAgent yes

Older 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@host

What to look for in the log:

  • bad permissions / UNPROTECTED PRIVATE KEY → permissions
  • Load key ...: invalid format → format (a .ppk, or a corrupted file)
  • Offering public key followed by rejection → the server's authorized_keys
  • no 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@host

Quick reference

  • no matching host key type → confirm with ssh -o HostKeyAlgorithms=+ssh-rsa, then move it into ~/.ssh/config under a Host block
  • It is in -Q but 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 ~/.ssh
  • BUILTIN\Users (Windows) → icacls /inheritance:r, then /grant:r "user:(R)"
  • A key under /mnt/c in WSL → copy it into WSL, then chmod 600
  • invalid format → it is a .ppk. Convert with PuTTYgen.
  • It keeps coming back → move the key to ~/.ssh or %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.

--

--

talkit
talkit

Application architect. I find out why large systems are slow — load testing, bottleneck analysis, APM and log platforms, and the reports that lead to fixes.