Okay, so I'm trying to setup a login for logging in with ssh, using a public key.

First, I am using puttygen to generate a rsa-ssh2 public key using a passphrase. I followed the directions and generated the key. I saved the private key in its own file for putty and puttygen also generated the public key.

In putty I set it up to use the private key file and use rsa-ssh2 etc...

So I c/p'd my houtput ssh2 public key stuff from puttygen and on the server, I put that into


So I tried to then login through putty and first it prompted me for my username instead of asking for passphrase, and then when I entered it in (I tried both username and passphrase) it said my public key was invalid.

I thought maybe I somehow c/p'd or formatted the info into authorized_keys wrong, so I went back and double checked. I made sure it was all on one line, properly spaced etc...

I also checked in the following file /etc/ssh/ssh_config and I have the following:

IdentityFile ~/.ssh/id_rsa

I tried renaming my authorized_keys file to id_rsa and no joy.

I tried changing that line in ssh_config to

IdentityFile ~/.ssh/authorized_keys

...and no joy.

I went back to thinking maybe my public key was malformed or that putty wasn't configured properly so I asked a friend to make a temp account for me on his server and add my public key and I was able to login through putty just fine...when I connected to his server, it prompted me for the passphrase for my key and logged me in just fine.

So he suggested I look at that stuff above but no joy and he doesn't know what else to check soo...I guess I'm appealing to the experts here :P


  • Read the “troubleshooting” section of the ssh tag info, in particular the part about permissions. – Gilles Apr 6 '11 at 0:36
  • okay so I made sure my permissions are 700 on the files/folders...as far as ssh -vvv it doesn't give me anything to post..it just shows me usage instructions – user6319 Apr 6 '11 at 1:23

Check permissions. OpenSSH will not allow public-key authentication if a user's home directory, ~/.ssh, or ~/.ssh/authorized_keys is world writable. Also, ~/.ssh and ~/.ssh/authorized_keys should probably not be group-writable either. Leave IdentityFile at the default, it's has nothing to do with the server aspect. It points to the default private key file used by the ssh client on UNIX/Linux. ssh_config is used only by the ssh client, and not the OpenSSH sshd server. The contents of authorized_keys should be one line per public key that is authorized to log in and look something like this:

ssh-rsa AAA.../Us= My Public Key comment

Where ... is a bunch of base64 characters ([a-zA-Z/+=]). PuTTYGen can generate two forms of keys: PuTTY and OpenSSH compatible. The OpenSSH compatible will be one long line in the above format. If it's in PuTTY format, you can import it back into PuTTYGen and save as OpenSSH.

  • Also, look in the Event Log of PuTTY and see if it mentions public key attempted. – penguin359 Apr 6 '11 at 1:38

I ended up using ssh-keygen to generate a public/private key on my server and then importing the private key to puttygen and saving as the .ppk file for putty, and that worked.

I still don't really know what went wrong but I guess it had something to do with the public and/or private key generated by puttygen afterall... :/


Aaaah I figured it out! It was because my server wanted a 2048 bit key and I was generating a 1024 bit key with puttygen

Your Answer

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