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.

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 NeelyJun 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?
–
ZoredacheJun 2 '11 at 23:50

4 Answers
4

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.

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.....
–
user54898Jun 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.
–
ZoredacheJun 2 '11 at 20:52

i mean i copy pasted to authorized_keys file. it was in correct format.
–
user54898Jun 2 '11 at 21:21

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.