Closed redrac closed 1 year ago
Hi @redrac, this is quite weird and I cannot reproduce it.
When you see only the ECDSA-CERT
in the agent, the agent has both the private key and the certificate. When you see ECDSA
too means that it also has the public key, the same one that is available in the certificate. This is the expected behavior:
user@host01 [16:40:32] ~ $ ssh-add -l
256 SHA256:zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz/OAvwmabJI/4 /home/user/.ssh/id_ecdsa (ECDSA-CERT)
I've tried with these version of ssh, but wasn't able to reproduce it:
In my tests, instead of Enter passphrase for key '/home/user/.ssh/id_ecdsa':
I see this:
$ ssh -v ssh.host
OpenSSH_8.2p1 Ubuntu-4ubuntu0.9, OpenSSL 1.1.1f 31 Mar 2020
...
debug1: Offering public key: mariano@smallstep.com ECDSA-CERT SHA256:zzz agent
debug1: Server accepts key: mariano@smallstep.com ECDSA-CERT SHA256:zzz agent
debug1: sign_and_send_pubkey: no separate private key for certificate "mariano@smallstep.com"
debug1: Authentication succeeded (publickey).
Authenticated to ssh.host ([x.x.x.x]:22).
...
By the way, I've just noticed that the fingerprints in the ssh-add -l
and ssh -v host02
are different:
SHA256:zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz/OAvwmabJI/4
SHA256:zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz/6WH2c+Gt8
Can this be related, or are just copypastes from different sessions?
@redrac I've been able to reproduce your behavior, but only if I store the files in /home/user/.ssh/id_ecdsa
, it works as expected in any other case.
By the way, you can also use step ssh login user@email.com
it will generate an ephemeral key that will be only in the agent.
After looking at the ssh
source code, if using a certificate and it is in the default location, it will first use the file instead of the agent. As the SSH server accepts that certificate, the client will ask you for the password of the file.
It was indeed copy paste from different sessions + obscuring my company. Thanks for tracking that down; I confirmed rm -f'ing the files does indeed allow SSH to work with just the cert in agent.
Steps to Reproduce
Run
step ssh certificate user@company.com /home/user/.ssh/id_ecdsa
and attempt to SSH to a host with the user CA installed; the SSH client will prompt you for a passphrase for the private key.Your Environment
step
CLI Version - Smallstep CLI/0.23.4 (linux/amd64) Release Date: 2023-03-10T00:07:02ZExpected Behavior
I would expect both the certificate and the key to be added to the agent. Both are required for SSHing to a host.
Actual Behavior
What actually happens is only the certificate is added and then you cannot SSH to a host with the CA configured in the SSH server configuration:
Additional Context
While I couldn't find it explicitly in the man pages I did find note that the private key is required to be in the agent here: https://en.wikibooks.org/wiki/OpenSSH/Cookbook/Certificate-based_Authentication.
And you can test and confirm that is indeed the case.
Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).