id_rsa.pub file SSH Error: invalid format

前端 未结 5 474
野的像风
野的像风 2021-02-05 03:31

My co worker and I have been trying to get my macbook to ssh into our AWS production server with no luck, this did work several months ago, but when we went to do it yesterday -

相关标签:
5条回答
  • 2021-02-05 03:49

    In my case, I was attempting to use the -i flag to point to the default key: ssh -i ~/.ssh/id_rsa.pub user@0.0.0.0

    Removing the -i key, and simply calling ssh user@0.0.0.0 resolved the error

    0 讨论(0)
  • 2021-02-05 03:50

    your error is in having used the -f option with the public key name... you have to generate a new key, as you have sent (and compromised) your private key, by storing it in -f .ssh/id_rsa.pub

    The private key is stored by default in .ssh/id_rsa and the public key is stored in .ssh/id_rsa.pub. By specifying .ssh/id_rsa.pub as the place of your private key, probably you'll have the public in .ssh/id_rsa.pub.pub (CHECK THIS) but anyway, you have sent your private key over the network, so it is compromised and you should have better generating a new key pair.

    Next time, you can trust the default settings proposed for the key filenames or use the proper (without the .pub extension) for the key file.

    0 讨论(0)
  • 2021-02-05 03:52

    Here's what worked for me.

    Trying to connect to AWS server, I was getting this error: Load key "yourKey.pem": invalid format and there was nothing wrong with the key file content.

    But generating fingerprint would produce : unable to load key <...> :Expecting: ANY PRIVATE KEY...

    What worked for me was to use terminal with nano and manually create a brand new file with the same name

    $ sudo nano yourKey.pem

    paste the text content from the original key file and save it.

    Then the new key's fingerprint matched and ssh access was restored.

    Hope this help.

    0 讨论(0)
  • 2021-02-05 03:53

    The following permissions should be set:

    Private keys should get rw for owner, none for group, none for others:

    chmod 600 id_rsa
    

    Public keys should get rw for owner, r for group, r for others:

    chmod 644 id_rsa.pub
    
    0 讨论(0)
  • 2021-02-05 04:02

    The IdentityFile configuration parameter should be pointed at the private key which the SSH client uses to prove its identity to the remote server. (The remote server, then, should have the contents of id_rsa.pub installed in its authorized_keys file, or an equivalent location).

    You should be putting the path to id_rsa, not id_rsa.pub, as an argument to IdentityFile in your ~/.ssh/config.

    0 讨论(0)
提交回复
热议问题