I am having wierd issue with openSSH connecting to remote server. I can connect it with userID and password, but when I use the public key authentication, it shows the following lines in the putty.log and quits.

=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2011.06.02 13:44:04 =~=~=~=~=~=~=~=~=~=~=~=
Using username "******".

Authenticating with public key "comment-----"
Last login: Wed Jun  1 17:27:13 2011 from ****.com

ANd then the putty quits.

I went thru different posts, where they talk about shell cmd and other stuffs and I am lost now.

Both the machines are running in windows with openssh. Can anybody guide me from where to start now.

ANy help is appreciated.

  • 2
    Enabling debugging in your putty might be a place to start. If you are able to connect from that same machine using a password without the key enabled I would suspect something in your authorized_keys file on the destination machine, so you might want to look there. – Neil Neely Jun 2 '11 at 19:37
  • You mention you are running OpenSSH on Windows. How exactly are you doing that. Via Cygwin, CopSSH, or something else? If you have a full Cygwin on the server, can you use ssh on the server to make a connection to the localhost? Have you considered at least temporarily installing Cygwin on a client, and using that to attempt to connect? – Zoredache Jun 2 '11 at 23:50

Puttygen generates an SSH2 aka Tectia or ssh.com public key when you use the 'Save public key' button, not a OpenSSH key. Different servers need a different type of key.

In puttygen load your private key file, and copy the line that looks like this ssh-rsa AAAAB3... from the dialog box labeled 'Public key for pasting into OpenSSH authorized_keys file'.

Puttygen public key

OpenSSH Public key

ssh-rsa AAAB3NzaC1yc2EAAAABJQAAAIBQ2Si6NjLR40YTI+9Z/TTBSYUykO1RjAX3GA2Zs15v7wiBVz3JoeLXFAmXRApdWCHCsmZIAjiX+qC0Ks1MY4suphDQv1ZfJE1xmhRwqr7h4f+/i0QmGI05lr/yJqwSashUIF4YWqgC14ov57VtaiCp//GTU29exME/JX3FzzxVmw== rsa-key-20110602

ssh.com Public key

Comment: "rsa-key-20110602"
  • yes it looks the same ....it starts with ssh-rsa AAA- - - - - -...thanks – user54898 Jun 2 '11 at 21:34

I think your public and/or private key may be corrupt.

Are you saying the server uses Windows too? In that case I don't know where to look for the keys, but usually they're called id_rsa and id_rsa.pub. What is in id_rsa.pub? And what is in the file authorized_keys?

  • @Eduardo Ivanec public/private were generated by puttygen and public key was pasted on the authorized_keys in the server and private file with .pkk extension was supplied from putty. If there was sth wrong with keys then, wouldnt it be saying , key invalid or refused..... – user54898 Jun 2 '11 at 19:50
  • @user54898, puttygen generates a public key in a format that isn't appropriate for OpenSSH if you click the button. – Zoredache Jun 2 '11 at 20:52
  • i mean i copy pasted to authorized_keys file. it was in correct format. – user54898 Jun 2 '11 at 21:21

Check the authorized_keys file on the server - the server may be forcing a command based on the key you're using to authenticate, which could explain the different behaviour when logging in with a public key instead of a password.

To check this look for a command= string somewhere in the file.

  • I did a search but I could not find anything..... – user54898 Jun 2 '11 at 19:51

Another possibility is the permissions on the authorized_keys file itself. As you are on windows, I am unfamiliar with that side, but in the *nix world, if the ssh daemon sees that your authorized_keys file is world readable it will refuse to honor it.

  • Can you tell me how to see the log files in windows except putty.log(Which doesnot give enough info), – user54898 Jun 2 '11 at 22:28

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.