SSH keys are not working

Hi,

I've generated and posted pub. keys in the source system and the target. However, it is still prompting me for the password.

Steps that I have taken.

  1. Generated ssh keys : ssh-keygen. It created two files.
    1. .ssh/id_rsa
    2. .ssh/id_rsa.pub.

  2. I have scp .ssh/id_rsa.pub over to target user's .ssh folder and renames to authorized_keys.

When I'm trying to do ssh to target server/user, it is still prompting me for the pass.

Any idea why?

Try ssh -v or even -vv or -vvv to see what it thinks it's doing. I suspect it's either a different protocol version of ssh or the permissions of one of the files are wrong...

Try this command:

ssh-copy-id <hostname or IP>

Here is the result for ssh-copy-id <hostname>

/usr/bin/ssh-copy-id: ERROR: No identities found

ssh -v or ssh -vv/vvv does not recognize.

Then you don't have the files in the correct location(/home/username/.ssh/), or incorrectly named, or the wrong kind of file(Try making a DSA key instead), or incorrect ownership and/or permissions on ~/.ssh/ or the files themselves. ls -l ~/.ssh/

You are running ssh -v username@host, yes? not just -v.

First of all, make sure you already generate your rsa key by doing this :
ssh-keygen

and then do these 2 steps:
cd ~
ssh-copy-id .ssh/id_rsa.pub user@target-host

or these 3 steps:
ssh-agent $SHELL
ssh-add
ssh-copy-id user@target-host

in case you still need it :slight_smile:

I have been there.Please check the permissions on the directory ( probably home of user for whom you have generated keys) it has to be 700 and authorized_keys has to be 640.So if we are doing it for user xyz

Then

700 /home/xyz
700 /home/xyz/.ssh
640 /home/xyz/.ssh/authorized_keys

try doing this at the client side...
chmod 777 .ssh/authorized_keys

Permissions "400" is enough for the authorized_keys file. Also important is the permissions on the .ssh directory itself, for which "100" would likely be enough.

777 is not the magic sledgehammer that solves everything. Do you really want the world to be able to modify that file?

ssh can be very picky about the permissions it will accept. too permissive and it considers it insecure and won't go...

you can use this command

ssh-copy-id -i /path/of/public/key username@Hostname

and the will ask you about password , and then will transfer the key