Skip to content

feat(auth): add certificate-based authentication via SSH agent - #632

Merged
Eugeny merged 4 commits into
Eugeny:mainfrom
wi-adam:certificate-auth
Mar 22, 2026
Merged

feat(auth): add certificate-based authentication via SSH agent#632
Eugeny merged 4 commits into
Eugeny:mainfrom
wi-adam:certificate-auth

Conversation

@wi-adam

@wi-adam wi-adam commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Add support for authenticating with SSH certificates held by an SSH agent, complementing the existing key-based authentication flow.

  • Add FutureCertificate method variant for certificate auth
  • Add AgentIdentity enum to represent both keys and certificates
  • Implement sign_request_cert for certificate-based signing
  • Add authenticate_certificate_with for FutureCertificate auth flow
  • Add hash_alg support for RSA certificate signing
  • Comprehensive test coverage for new functionality

Closes #438

Add support for authenticating with SSH certificates held by an SSH agent,
complementing the existing key-based authentication flow.

- Add FutureCertificate method variant for certificate auth
- Add AgentIdentity enum to represent both keys and certificates
- Implement sign_request_cert for certificate-based signing
- Add authenticate_certificate_with for FutureCertificate auth flow
- Add hash_alg support for RSA certificate signing
- Comprehensive test coverage for new functionality

Closes Eugeny#438
@wi-adam

wi-adam commented Feb 5, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Eugeny this should be ready for review. I validated it in our setup (an SSH bastion for our AI Agent sandbox where we want to control what's being passed through except we use cert based SSH auth).

@wi-adam

wi-adam commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

Hi @Eugeny - just wanted to poke in this PR

@chipsenkbeil

chipsenkbeil commented Mar 13, 2026

Copy link
Copy Markdown

This is also a blocker for https://github.com/chipsenkbeil/distant and https://github.com/chipsenkbeil/distant.nvim

I switched over to russh from wezerm's ssh library powered by two separate C client libraries. Was trying it out to connect to a corporate VPN and hit this exact limitation.

Would love to see this get reviewed when the author has time. In the meantime, I'm going to grab your branch @wi-adam and try to compile distant against it to see if that works for my corporate setup.

[EDIT]

Can confirm that @wi-adam branch works for me on my corporate setup, which is great. :)

chipsenkbeil added a commit to chipsenkbeil/distant that referenced this pull request Mar 13, 2026
Servers requiring certificate-based auth (e.g. @cert-authority in
known_hosts) reject bare public keys from the agent. OpenSSH handles
this by loading the certificate from IdentityFile, matching it to the
agent's key, and presenting the cert to the server while the agent
signs the challenge. distant now does the same.

Patch russh 0.57.1 with upstream PR #632 (Eugeny/russh#632) to add
authenticate_certificate_with, sign_request_cert, and AgentIdentity.
In distant-ssh, discover certificate files (-cert.pub) from identity
files, parse IdentityAgent from ssh -G, and try cert+agent auth before
plain agent auth — matching OpenSSH's order. Platform-specific agent
connection mirrors the existing try_agent_auth pattern.
Comment thread russh/src/keys/mod.rs Dismissed
@Eugeny
Eugeny merged commit efb9a13 into Eugeny:main Mar 22, 2026
10 of 11 checks passed
@Eugeny

Eugeny commented Mar 22, 2026

Copy link
Copy Markdown
Owner

Thank you! I've adjusted the API a bit

@all-contributors add @wi-adam for code

@allcontributors

Copy link
Copy Markdown
Contributor

@Eugeny

I've put up a pull request to add @wi-adam! 🎉

Eugeny pushed a commit that referenced this pull request Mar 22, 2026
Adds @wi-adam as a contributor for code.

This was requested by Eugeny [in this
comment](#632 (comment))

[skip ci]

---------

Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Comment on lines +257 to +258
/// Ask the agent for a list of identities, including certificates.
pub async fn request_identities(&mut self) -> Result<Vec<AgentIdentity>, Error> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR changed the return type of request_identities() (a public API), but it was released as a patch version 0.58.1, which breaks the semver - maybe it's worth yanking 0.58.1 and republishing it as v0.59?

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.

Support retrieving OpenSSH certificates from the agent

5 participants