I have a PEM file which I add to a running ssh-agent:
$ file query.pem
query.pem: PEM RSA private key
$ ssh-add ./query.pem
Identity added: ./query.pem (./query.pem)
$ ssh-add -l | grep query
2048 ef:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX ./query.pem (RSA)
How can I get the key's fingerprint (which I see in ssh-agent) directly from the file? I know ssh-keygen -l -f some_key
works for "normal" ssh keys, but not for PEM files.
If I try ssh-keygen on the .pem file, I get:
$ ssh-keygen -l -f ./query.pem
key_read: uudecode PRIVATE KEY----- failed
key_read: uudecode PRIVATE KEY----- failed
./query.pem is not a public key file.
This key starts with:
-----BEGIN RSA PRIVATE KEY-----
MIIEp.... etc.
as opposed to a "regular" private key, which looks like:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,E15F2.... etc.
.ssh/id_rsa
file generated by OpenSSH using all the defaults IS a PEM file. The private keys are PEM encoded by default. In fact you can use RSA keys you generate with OpenSSL directly with OpenSSH.ssh-keygen -l
can't read a privatekey file, although otherssh-keygen
(andssh*
) operations do. But whenssh-keygen
generates a key it writes both the privatekey file e.g.id_rsa
and a corresponding publickey file with.pub
added e.g.id_rsa.pub
. Olderssh-keygen -l
will try adding.pub
to the filename you specify and reading that publickey file.