Why ssh connection fails if `id_rsa.pub` file exists in local `.ssh` directory?

0

I just noticed if id_rsa.pub exists in local ~/.ssh directory, I can't connect my remote server with ssh command.

But I have no idea why is that. Is it dangerous for security if public key exists at same place of secret key?

And I don't get a error that indicates the public key should not be placed there, even if I run ssh command with -v option.

Why I must not put a public key in ~/.ssh/?

This is a part of ssh log with -v option. I'm using ssh in cygwin environment.

debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/ironsand/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic
debug1: Trying private key: /home/ironsand/.ssh/id_dsa
debug1: Trying private key: /home/ironsand/.ssh/id_ecdsa
debug1: Trying private key: /home/ironsand/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

ironsand

Posted 2014-03-03T18:22:42.157

Reputation: 1 757

Anything logged before that part? It doesn't explain why password isn't a possible authentication. – Daniel Beck – 2014-03-03T18:34:50.197

1It looks like your host is trying to validate off of your public key which is fine. However, your public key does not authenticate successfully. Make sure that you've provided your public key to the host in the authorized_keys under the user account in which the key is meant to access. – kobaltz – 2014-03-03T18:50:16.573

No answers