-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Using YubiKey with SSH results in "error retrieving public key" #2101
Comments
Hi @danthonywalker, This is a known issue, right now we only** support keys generated on the YubiKey, generating the keys should be simple, using step kms create 'yubikey:slot-id=83?pin-value=123456'
step certificate create --profile intermediate-ca \
--kms yubikey:?pin-value=123456 --key yubikey:slot-id=83 \
--ca root_ca.crt --ca-key root_ca_key \
"My Intermediate CA" intermediate_ca.crt If the root is also in the yubikey, then you can use: step certificate create --profile intermediate-ca \
--kms yubikey:?pin-value=123456 --key yubikey:slot-id=83 \
--ca-kms yubikey:?pin-value=123456 --ca root_ca.crt --ca-key yubikey:slot-id=82 \
"My Intermediate CA" intermediate_ca.crt ** This is not 100% true, if you import a key and a certificate for the same key in the same slot we support it. It would be possible to support imported keys without the certificate workaround, I'll add an issue in https://github.com/smallstep/crypto so we can triage. |
Here's is the issue in crypto smallstep/crypto#655 |
@maraino for an SSH CA, If they were to import an arbitrary X.509 certificate that's bound to the key, are you saying that would be a usable workaround? |
As far as I understand it, SSH doesn't use X.509 certificates and the key/pub it does generate aren't tied to the root/intermediate (they are essentially keys you could generate with I should've added context from the Discord discussion, but I can't generate the keys on the YubiKey because I'm running a HA setup, so I need to be able to import the key into multiple YubiKeys. |
Yes, my fix in
|
For example with a YubiKey 5.2.7:
To work around this problem:
Once my PR is merged and the dependencies are updated, this won't be required if you use a a newer YubiKey. I haven't figured out when 5.3.0 was released. |
Ok. So, @danthonywalker, to be clear, the X.509 certificate isn't used for anything. It just has to be imported along with the pubkey for the software to work. |
The reason for this is because to use a signer from the yubikey we need to know the public key, and the slot, obviously. The go-piv package provides 3 ways to get this public key:
We will try all those in that order, and we will use the first one that works. |
This commit upgrade go.step.sm/crypto, the new version adds support for retrieving imported keys without a certificate on YubiKeys >= 5.3.0 Fixes #2101
Steps to Reproduce
Initialize a certificate authority with --ssh so it generates keys and .pub files. Import the keys into a YubiKey (you cannot import the public keys since they are not certificates). Change
ca.json
to pull from YubiKey.Your Environment
step-ca
Version - 0.28.1Expected Behavior
CA starts and can get a public key for SSH from the YubiKey
Actual Behavior
Running the CA immediately results in
error retrieving public key: command failed: smart card error 6a82: data object or application not found
Additional Context
Beginning of the Discord discussion where Carl T. told me to create an issue:
https://discord.com/channels/837031272227930163/841249977699401759/1316182538162802720
My
ca.json
:Removing the
ssh
property makes the CA run properly.Here is some YubiKey outputs with ykman showing the keys exist and you can get a public key from them:
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).
The text was updated successfully, but these errors were encountered: