Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I for the life of me can't seem to get openSSH to work on Ubuntu Server 10.10 with keys I generated in PuttyGen on my Windows machine. After hours of trial and error and web searches I can't get my ssh service to accept my private key!

Here is my sshd_config.

I generated my public and private keys using Putty in Windows then used a ssh connection to paste my key from putty directly into my authorized_keys2 file located in */etc/ssh/publickeys/authorized_keys2*

The authorized_keys2 file looks something like: ssh-rsa AAAAB3NzaC1yc2EAAAA... with no email or anything at the end of it. I just pasted it straight from PuttyGen without using a key comment.

I feel like it's not working because of some nuance I am not understanding or some unusual setting or incompatibility. I've restarted the ssh service (and the machine) to no avail.

What are some common pitfalls I might have gotten myself into? Is there a simpler way to generate ssh keys that putty can use in windows?

share|improve this question

I solved it. My problem was that I needed to convert the public key to OpenSSH's format. This required the use of the following command: ssh-keygen -i -f puttygen_key > openssh_key which converted my putty generated key into an openssh key which I then simply renamed to authorized_keys and boom it works.

share|improve this answer
Thanks. Should have known that option in ssh-keygen before! – gertvdijk Sep 16 '12 at 11:25

The above is not working for me, i copied the pub..key into my .ssh/authorized_keys Then went to putty and still not allowed excess. Been banging my head for near 3 days now. lol

I think my problem is understanding what user sudo is doing what. I have a key pair made and working from my home pc [linux] which was so easy using sudo jamjam$ Do i need to mkdir .ssh for sudo user for the laptop? and then chown -R etc etc etc..

At the minute i sitting with the 2 keys made from putty, uploaded private key into Pageant and once again playing with my nuts where to stick the second one. hahaha. Anyone help please, ? The second public key is stored on USB and as been copied to .ssh/authorized_keys and thats me for tonight. Any help would be great people.

share|improve this answer
Make sure you copy and put the OpenSSH public key displayed on the PuTTYgen dialog box and NOT the saved public key into .ssh/authorized_keys file. The saved public key contains "---- BEGIN SSH2 PUBLIC KEY ----" and "---- END SSH2 PUBLIC KEY ----" pre- and postfixes not used by OpenSSH. – Shy Robbiani Jan 11 at 10:55

You must write the content of your into your ~/.ssh/known_hosts file and that's it the workaround is similar to:

  1. Install openSSH (done as you point)
  2. Generate an rsa in the client machine to share.
  3. Copy the content of the into the ~/.ssh/known_hosts in the server.
  4. Enjoy fully authorized communication with the server from the client machine.

More on creating sshkeys with PuTTYgen here and there (note that you just need to change the step when you copy the text to the server, now the server is linux!)

You also can use google's Secure Shell, here you can find how to share a key-pair using it.

share|improve this answer
Does the known_hosts file need to be one line? Puttygen creates a multi-line file for the .pub key. Also, is this file required to be in ~/.ssh/known_hosts because my authorized_keys file is in /etc/ssh/publickeys – warpstack Sep 16 '12 at 5:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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