Skip to content

Restrict SSH host key algorithms to the configured host key types (#892) - #893

Merged
m90 merged 2 commits into
offen:mainfrom
OleksandrMorskyi:fix/ssh-host-key-algorithms
Oct 30, 2026
Merged

m90 merged 2 commits into
offen:mainfrom
OleksandrMorskyi:fix/ssh-host-key-algorithms

Conversation

@OleksandrMorskyi

Copy link
Copy Markdown
Contributor

Fixes #892

When SSH_HOST_PUBLIC_KEY or SSH_KNOWN_HOSTS_FILE is used, HostKeyAlgorithms is now set to the type(s) of the configured host key(s). Previously the client negotiated its default preference (ECDSA first), so a pinned ED25519 key never matched when the server also offered ECDSA.

  • Pinned key: algorithm derived from the key type (RSA also allows rsa-sha2-256/512)
  • known_hosts: algorithms of all keys known for the host; unknown hosts keep the default behavior
  • Tests: in-memory SFTP server with ED25519 + ECDSA host keys, covering pin and known_hosts for both types plus mismatch cases. Without the fix, the two ED25519 cases fail.
  • Docs: note that any host key type can be used

@m90

m90 commented Oct 30, 2026

Copy link
Copy Markdown
Member

This looks good, thank you. I wonder if we can also test this behavior in the integration test, e.g. by providing a non-ecdsa key instead?

@OleksandrMorskyi

Copy link
Copy Markdown
Contributor Author

Good idea, thanks! I added a fourth step to the SSH integration test: the backup container is restarted with the server’s ED25519 host key pinned (the test server offers both ECDSA and ED25519), and the test checks that the backup is uploaded. Without the fix it fails with ssh: host key mismatch.

@m90
m90 merged commit f309bfe into offen:main Oct 30, 2026
3 checks passed
@m90

m90 commented Oct 30, 2026

Copy link
Copy Markdown
Member

This is now released in v2.50.1, thanks a lot 🎩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SSH backend: pinned ED25519 host key always fails with “host key mismatch” when server also offers ECDSA

2 participants