key_load_public: invalid format

前端 未结 10 2561
滥情空心
滥情空心 2020-12-22 15:23

I used PuTTY Key Generator to generate a 4096 bit RSA-2 key with a passphrase.

I save the .ppk and an openSSL format public key. The putty format public key doesn\'t

相关标签:
10条回答
  • 2020-12-22 15:45

    So, after update I had the same issue. I was using PEM key_file without extension and simply adding .pem fixed my issue. Now the file is key_file.pem.

    0 讨论(0)
  • 2020-12-22 15:48

    If you're using Windows 10 with the built-in SSH, as of August 2020 it only supports ed25519 keys. You'll get the key_load_public: invalid format error if you use e.g. an RSA key.

    As per this GitHub issue it should be fixed via Windows Update some time in 2020. So one solution is to just wait for the update to ship.

    If you can't wait, a workaround is to generate a new ed25519 key, which is good advice anyway.

    > ssh-keygen -o -a 100 -t ed25519
    

    You can use it with e.g. github, but some older systems might not support this newer format.

    After generating your key, if you're using either of the below features, don't forget to update them!

    1. ~\.ssh\config might still point to the old key.
    2. Add the new key to ssh-agent via the ssh-add command
    0 讨论(0)
  • 2020-12-22 15:51

    In the case you copy your public key with clipboard and paste it, it may happen the public key string can be broken which contains new-line.

    Make sure your public key string formed as one line.

    0 讨论(0)
  • 2020-12-22 15:53

    The error is misleading - it says "pubkey" while pointing to a private key file ~/.ssh/id_rsa.

    In my case, it was simply a missing public key (as I haven't restored it from a vault).


    DETAILS

    I used to skip deploying ~/.ssh/id_rsa.pub by automated scripts.

    All ssh usages worked, but the error made me think of a possible mess.

    Not at all - strace helped to notice that the trigger was actually the *.pub file:

    strace ssh example.com
    ...
    openat(AT_FDCWD, "/home/uvsmtid/.ssh/id_rsa.pub", O_RDONLY) = -1 ENOENT (No such file or directory)
    ...
    write(2, "load pubkey \"/home/uvsmtid/.ssh/"..., 57) = 57
    load pubkey "/home/uvsmtid/.ssh/id_rsa": invalid format
    
    0 讨论(0)
  • 2020-12-22 15:54

    Instead of directly saving the private key Go to Conversions and Export SSh Key. Had the same issue and this worked for me

    0 讨论(0)
  • 2020-12-22 15:55

    It seems that ssh cannot read your public key. But that doesn't matter.

    You upload your public key to github, but you authenticate using your private key. See e.g. the FILES section in ssh(1).

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