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.
-
2Can 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– Romeo NinovCommented Sep 26, 2021 at 17:02
-
1Seconding @terdon - please clarify your question. It's difficult to help if we don't know what exactly you want to do.– Peregrino69Commented Sep 26, 2021 at 17:45
Add a comment
|
1 Answer
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