How to convert SSH keypairs generated using PuTTYgen (Windows) into key-pairs used by ssh-agent and Keychain (Linux)

前端 未结 9 1373
抹茶落季
抹茶落季 2020-11-22 14:25

I\'ve generated key pairs using PuTTYgen and been logging in using Pageant, so that I have to enter my pass-phrase only once when my system boots.

How do I achieve

9条回答
  •  梦谈多话
    2020-11-22 15:25

    If all you have is a public key from a user in PuTTY-style format, you can convert it to standard openssh format like so:

    ssh-keygen -i -f keyfile.pub > newkeyfile.pub
    

    References

    • Source: http://www.treslervania.com/node/408
    • Mirror: https://web.archive.org/web/20120414040727/http://www.treslervania.com/node/408.

    Copy of article

    I keep forgetting this so I'm gonna write it here. Non-geeks, just keep walking.

    The most common way to make a key on Windows is using Putty/Puttygen. Puttygen provides a neat utility to convert a linux private key to Putty format. However, what isn't addressed is that when you save the public key using puttygen it won't work on a linux server. Windows puts some data in different areas and adds line breaks.

    The Solution: When you get to the public key screen in creating your key pair in puttygen, copy the public key and paste it into a text file with the extension .pub. You will save you sysadmin hours of frustration reading posts like this.

    HOWEVER, sysadmins, you invariably get the wonky key file that throws no error message in the auth log except, no key found, trying password; even though everyone else's keys are working fine, and you've sent this key back to the user 15 times.

    ssh-keygen -i -f keyfile.pub > newkeyfile.pub
    

    Should convert an existing puttygen public key to OpenSSH format.

提交回复
热议问题