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

前端 未结 9 1239
抹茶落季
抹茶落季 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:03

    puttygen supports exporting your private key to an OpenSSH compatible format. You can then use OpenSSH tools to recreate the public key.

    1. Open PuttyGen
    2. Click Load
    3. Load your private key
    4. Go to Conversions->Export OpenSSH and export your private key
    5. Copy your private key to ~/.ssh/id_dsa (or id_rsa).
    6. Create the RFC 4716 version of the public key using ssh-keygen

      ssh-keygen -e -f ~/.ssh/id_dsa > ~/.ssh/id_dsa_com.pub
      
    7. Convert the RFC 4716 version of the public key to the OpenSSH format:

      ssh-keygen -i -f ~/.ssh/id_dsa_com.pub > ~/.ssh/id_dsa.pub
      

    See this and this for more information.

    0 讨论(0)
  • 2020-11-22 15:03

    I recently had this problem as I was moving from Putty for Linux to Remmina for Linux. So I have a lot of PPK files for Putty in my .putty directory as I've been using it's for 8 years. For this I used a simple for command for bash shell to do all files:

    cd ~/.putty
    for X in *.ppk; do puttygen $X -L > ~/.ssh/$(echo $X | sed 's,./,,' | sed 's/.ppk//g').pub; puttygen $X -O private-openssh -o ~/.ssh/$(echo $X | sed 's,./,,' | sed 's/.ppk//g').pvk; done;
    

    Very quick and to the point, got the job done for all files that putty had. If it finds a key with a password it will stop and ask for the password for that key first and then continue.

    0 讨论(0)
  • 2020-11-22 15:10

    PPK → OpenSSH RSA with PuttyGen & Docker.

    Private key:

    docker run --rm -v $(pwd):/app zinuzoid/puttygen private.ppk -O private-openssh -o my-openssh-key
    

    Public key:

    docker run --rm -v $(pwd):/app zinuzoid/puttygen private.ppk -L -o my-openssh-key.pub
    

    See also https://hub.docker.com/r/zinuzoid/puttygen

    0 讨论(0)
  • 2020-11-22 15:13

    Newer versions of PuTTYgen (mine is 0.64) are able to show the OpenSSH public key to be pasted in the linux system in the .ssh/authorized_keys file, as shown in the following image:

    enter image description here

    0 讨论(0)
  • 2020-11-22 15:16

    Alternatively if you want to grab the private and public keys from a PuTTY formated key file you can use puttygen on *nix systems. For most apt-based systems puttygen is part of the putty-tools package.

    Outputting a private key from a PuTTY formated keyfile:

    $ puttygen keyfile.pem -O private-openssh -o avdev.pvk

    For the public key:

    $ puttygen keyfile.pem -L

    0 讨论(0)
  • 2020-11-22 15:17

    It's probably easier to create your keys under linux and use PuTTYgen to convert the keys to PuTTY format.

    PuTTY Faq: A.2.2

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