I have a new private key that I'm bringing to a docker container as part of a bash script. After copying the private key to /root/.ssh/id_rsa
I wanted to regenerate the public with:
ssh-keygen -yf /root/.ssh/id_rsa > /root/.ssh/id_rsa.pub
Unfortunately this results in the following error:
load failed
I assume this is because the private key has a passphrase which wasn't provided to ssh-keygen
command but sadly I don't know how do this. I had read that setting the SSH_AUTH_SOCK environment variable would suffice but it didn't work for me ... still asks for the passphrase.
Then I ran into a small variation on the keygen command which uses the -x
parameter:
ssh-keygen -yf /root/.ssh/id_rsa > /root/.ssh/id_rsa.pub -x
And to my great surprise it produces results. The right results? Not sure. In fact the results are distinctly different from the non "-x" variant (when provided the passphrase). I looked at the man file and it doesn't mention -x
at all.
I'm confused. Any help would be appreciated. Looking for either:
- a better understanding of what
-x
does and how to use it effectively - a way to pass in my private key's passphrase to
ssh-keygen
(and also sogit
will use it too)
ssh-add
it still asks for password and since this is a CLI I need to pass this in as a parameter.