I generated slot 9a following the PIV Walkthrough:
yubico-piv-tool -s 9a -a generate -o public.pem
But I lost the public.pem
file , how can I get it back?
yubikey-piv-tool
does not have any action to extract the public key from slot 9a directly see issue #501, but you can get the certificate from slot 9a and extract the public key from it like this:
yubico-piv-tool -a read-certificate -s 9a | openssl x509 -noout -pubkey
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuXiyBsdCdho3e0eAWNYo
....
....
....
0wIDAQAB
-----END PUBLIC KEY-----
Alternatively, you can use Yubikey Manager to extract the public key for slot 9a with:
ykman piv keys export 9a public.pem