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_rsafile 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 -lcan't read a privatekey file, although otherssh-keygen(andssh*) operations do. But whenssh-keygengenerates a key it writes both the privatekey file e.g.id_rsaand a corresponding publickey file with.pubadded e.g.id_rsa.pub. Olderssh-keygen -lwill try adding.pubto the filename you specify and reading that publickey file.