0

I want to recover my ssh public key from my private key. I am aware of this answer but it doesn't seem to work for me. When I run the command suggested ssh-keygen -f ~/.ssh/my_key -y > ~/.ssh/my_key.pub I only get the algorithm ssh-ed25519 and an ssh fingerprint not the full public key. What am I missing?

I tried making a new key and testing the command, it worked as expected. Is there something about the algorithm?

It is worth noting that the original key pair was generated by AWS.

5
  • What is the content of first line of your private key? Commented Jan 30, 2023 at 13:53
  • -----BEGIN OPENSSH PRIVATE KEY----- did you mean the first line of the actual cipher? Commented Jan 30, 2023 at 14:23
  • This is odd, from where you get this key? Commented Jan 30, 2023 at 14:26
  • 3
    Are you sure you don't get your public key? Curve algorithms (like ed25519) generate very short keys (a public key can be less than 70 bytes). Have you actually tried to use the resulting string as an SSH public key entry? Commented Jan 30, 2023 at 14:27
  • @Lacek that was it. please add it as an answer so I can upvote it. meybe it will help someone else in the future. At least my hunch about the algorithm was right Commented Jan 30, 2023 at 14:49

1 Answer 1

0

Try it with openssl:

openssl pkey -in ~/.ssh/my_key -pubout 

See also https://superuser.com/a/1700545/351496

1
  • Won't work for OpenSSH 'new' format, which is (1) stated in a comment on the Q over a year ago (2) ALWAYS used in OpenSSH for Ed25519, and also for other keytypes by default since 7.8 (6 years ago), and since 6.5 (10 years ago) if you generated or converted with -o which many people and sites recommended (for good reason. Your link is only for keys generated by OpenSSL (or things like Java that are at least semi-compatible) not OpenSSH. Commented Jul 25, 2024 at 9:28

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.