4

Is there a command to extract information about the algorithm that is used (RSA, ECDSA, 3DES ...) for SSH keys, regardless of the format (pem, der etc)? I looked into openssl, but I could not find anything about this.

3
  • 2
    Can you add some more context please? I think that you want to have a command that takes a file containing a key (public? private? both? either?) as input and returns the encryption algorithm used. Is that right? If so, please edit your question and add some more details. I don't know much about this, but in my (limited) experience, which is exclusively with RSA keys, both public and private keys mention "RSA" in the file.
    – terdon
    Commented Sep 26, 2021 at 16:45
  • @terdon, same for DSA, EC keys Commented Sep 26, 2021 at 17:02
  • 1
    Seconding @terdon - please clarify your question. It's difficult to help if we don't know what exactly you want to do. Commented Sep 26, 2021 at 17:45

1 Answer 1

9

You can use next command to get the type of the key (RSA, DSA, etc):

# ssh-keygen -l -f .ssh/id_rsa
2048 SHA256:4+Na0ttfBkspSFSYnRjwbwja8/b708lRxzqjPBzLJMw ........ (RSA)
# ssh-keygen -l -f .ssh/id_dsa
1024 SHA256:F6h53Zu0A9M094CbszkwxfQ5L2EZ0kUEpLkH0dp1alU ........ (DSA)
# ssh-keygen -l -f .ssh/id_ed25519
256 SHA256:b4mTk5rvo0SgazbzQxame6gX7r1MPtXeGNJY2q4Y3dg ........ (ED25519)

In the command you can specify file the private or the public key

1
  • 1
    Yeah, that's exactly what I was looking for. Thanks !
    – Kyu96
    Commented Sep 26, 2021 at 22:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .