2

I've generated two keys on PuTTY: public and private. Using this software on windows I can connect to the server as usual.

Then I tried to copy those files in my ubuntu machine (21.04), and logged in loading the private key (open putty, write the user@hostname and then load the private key at SSH>Auth), but there is unable to connect being rejected by the server as this error says:

Unable to load key file '~/private_key.ppk' (PuTTY key format too new). 

And an emerging windows appears saying:

No supported authentication methods available (server sent: publickey)

So, as the first error suggest, after convert the private key to openssh PEM format through PuTTYgen and then load that file to SSH/Auth, the 'No supported' message remains before:

Unable to use key file '~/private_key_openssh' (OpenSSH SSH-2 private key (old PEM format) ).

Is there any way to use these keys on Ubuntu? Maybe through openssh?

Some info that will be useful:

  • New installed version of Ubuntu
  • PuTTY 0.74

The output while trying with ssh -i ~/.ssh/private_key.ppk user@hostname

Load key "~/.ssh/private_key.ppk": invalid format user@hostname: Permission denied (publickey).

1
  • On Windows, export your PPK within puttygen to OpenSSH format privkey, and copy the pubkey info from the window. The Ubuntu version of PuTTY and PuTTYgen may be 'too old' if you're using the latest PuTTY from upstream, and as such you need to do the exports on Windows, then copy your keys over to Ubuntu.
    – Thomas Ward
    Sep 25, 2021 at 1:24

2 Answers 2

2

The answers/comments by Adonis and Thomas are basically correct, but lack some detail that I needed to get this working in practice. Since I don't have enough reputation to comment, I'll add the detail via this answer.

Export the Putty PPK to OpenSSH format.

To do this, open PuttyGen, Load the private key, and then go to the "Conversions" menu and choose "Export OpenSSH Key"

Using the OpenSSH key on Ubuntu (or derivatives)

If you are using it for SSH directly, you can use it as Adonis mentioned. But what if you need it indirectly, e.g. for use with source control systems?

Copy it to your ~/.ssh folder on Linux. You may need to create this folder if you haven't used SSH on your Linux box before. When you create the .ssh directory, you need to chmod 0700 ~/.ssh so that the ssh tool believes that the directory is really private to you.

If you copied the key file from Windows, now open a terminal to the ~/.ssh folder, and run chmod 400 [private key file name]. This is necessary because the default permissions (when copied from Windows) will be 770; the SSH utility will tell you that is too permissive and that it will ignore the key. Unfortunately it doesn't directly tell you how to fix the problems, but 400 permissions, which mean "readable to me, not available to anyone else", will correct the problem.

Now, at a terminal, run eval $(ssh-agent). This opens your local SSH agent, and allows you to add keys that can be picked up by other programs, such as source control.

Finally, run ssh-add ~/.ssh/[private file key name]. As long as you remembered to set permissions, it should work, and you should be able to use git/hg/etc. with your SSH key.

0

Connection achieved!

As suggested by Thomas Ward, loading the private_key file to PuTTYgen on Windows and copying the public key to the authorized-keys file worked as a first step.

Moreover, exporting the private_key file as openssh format, the first option, to private_OpenSSH file and then move it to the ~/.ssh directory to change permissions with:

chmod 400 private_OpenSSH

Allowed me to finally connect with:

ssh -i ~/private_OpenSSH user@hostname

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.