SSH connection asking for password instead of key

ssh

Ok so i'm trying to connect from one server to another using SSH.

I have copied across the key from the 'client' machine to the 'server' using ssh-copy-id, it was still coming up with the password prompt so I checked the log in /var/log/secure and saw the "Authentication refused: bad ownership or modes for directory" error which I fixed using chmod on the user account's (non-root account) .ssh directory and files.

Now there is are no longer any errors reported in the /var/log/secure file, the -v log from ssh on the 'client' side shows the following:

debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Next authentication method: password

It then asks for a password to be entered… Selinux is disabled.

Any ideas?

Thanks

Stuart

Best Answer

First of all, your permissions on the .ssh directory should be:

drwx------

On key files should be:

-rw-------

After you managed this, on server in your .ssh/authorized_keys append your public key used for authentication.

Also, names should be id_dsa* or id_rsa* for default ssh to work. If you have other names, use this:

ssh -i /path/to/mykey