public-openssh and private keys from Unix puttygen seem to mismatch - SSH

This is a discussion on public-openssh and private keys from Unix puttygen seem to mismatch - SSH ; Hi, everyone. I'm trying to create a private key in PuTTY format and it's corresponding private key in OpenSSH format, to be able to log into a Linux/OpenSSH server from a Windows box with PuTTY. I'm trying to generate the ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: public-openssh and private keys from Unix puttygen seem to mismatch

  1. public-openssh and private keys from Unix puttygen seem to mismatch

    Hi, everyone.

    I'm trying to create a private key in PuTTY format and it's
    corresponding private key in OpenSSH format, to be able to log into a
    Linux/OpenSSH server from a Windows box with PuTTY.

    I'm trying to generate the keys on the Linux box from within a bash
    script with:

    puttygen -t rsa -b 1024 -O private -o $file_name.ppk -q $file_name.pub
    -n -q
    puttygen $file_name.ppk -t rsa -b 1024 -O public-openssh -o
    $file_name.pub -q

    Then I put the contents of $file_name.pub in $user/.ssh/authorized_keys
    And get the .ppk file to the Windows box. But I get a "Server refused
    our key" message.

    I tried this: I used Windows version of puttygen to open the ppk file
    and compared the "Public key for pasting into OpenSSH authorized_keys
    file" with the .pub file. They don't match!!!
    I pasted the one created by Windows puttygen into authorized_keys, and
    it worked.

    Using Windows puttygen is not an option. I need to generate the keys on
    the server. What should I do? Where's the mistake?

    Thanks:

    Wences


  2. Re: public-openssh and private keys from Unix puttygen seem to mismatch

    Hi, it's me again!

    I figured it out! So in case anyone else stumbles on the same rock,
    this is the problem:

    puttygen -t rsa -b 1024 -O private -o $file_name.ppk -q $file_name.pub
    -q
    puttygen $file_name.ppk -t rsa -b 1024 -O public-openssh -o
    $file_name.pub -q

    The second call to puttygen opens $file_name.ppk, but as there's also
    "-t" and "-b" options, puttygen understands it should generate the key
    anew. So you get non-matching keys.

    The fixed lines:

    puttygen -t rsa -b 1024 -O private -o $file_name.ppk -q $file_name.pub
    -q
    puttygen $file_name.ppk -O public-openssh -o $file_name.pub -q

    Works like a charm!

    Cheers:

    Wences


  3. Re: public-openssh and private keys from Unix puttygen seem to mismatch

    Wences writes:
    >I'm trying to create a private key in PuTTY format and it's
    >corresponding private key in OpenSSH format, to be able to log into a
    >Linux/OpenSSH server from a Windows box with PuTTY.
    >
    >I'm trying to generate the keys on the Linux box from within a bash
    >script with:
    >
    >puttygen -t rsa -b 1024 -O private -o $file_name.ppk -q $file_name.pub
    >-n -q
    >puttygen $file_name.ppk -t rsa -b 1024 -O public-openssh -o
    >$file_name.pub -q


    You don't need to specify "-t rsa -b 1024" in the second command -- the
    key type and size will come from the .ppk file.
    In fact, the "-t rsa" option is causing a new key to be generated, which
    is why your files don't match.
    There should have been a diagnostic about this, but it never fired, due
    to a bug. It should also be complaining about your trying to generate a
    key but not save the private part.

+ Reply to Thread