SSH key exchange is not working

Try ssh -v this should provide additional information about the authentication process.

debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password,keyboard-interactive,hostbased
debug1: Offering RSA public key: /home/nce/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277

Just to confirm your steps: You created a keypair via ssh-keygen Then you uploaded the key at .ssh/id_rsa.pub to the server(B) and appended it to the .ssh/authorized_keys for the user1.

On server(A) you connect via ssh user1@host? You might try ssh -o PreferredAuthentications=publickey user1@host

And you could provide a special/different identityfile by ssh -i ~/.ssh/serverB/id_rsa user1@host


Check the permissions of the serverb authorized_keys file. If it has write permission for group/other then login using public keys will fail and fall back to password if it's available. If required change the permissions on the authorized_keys file to 644.

Possible but less likely is that you have public key authentication disables in your /etc/ssh/sshd_config file. Check that the config file does not contain a line

PubkeyAuthentication no

IF it does just comment it out (the default is yes) and restart the sshd service.


A tip for you: take a look at serverB's sshd log (/var/log/secure on Red Hat based)

http://www.openssh.org/faq.html#3.14

And for the future, you should use ssh-copy-id instead of manual copy.


Check to see whether sshd on B is configured to accept key-based authentication. On RedHat based systems the config file is /etc/ssh/sshd_config.