Error 'Permission denied (publickey,password)'

Try to add the key again.

First set PasswordAuthentication yes in file sshd_config at the destination machine, and then do ssh-copy-id user@host, log in, and then it will copy the key over.

Now you can set PasswordAuthentication no (if you want, for extra security), and you should be able to log in automatically.

You could also use your curiosity and check if id_rsa.pub from the source machine is in the authorized_keys file on the destination machine.


It might be different because it looks like you are connecting to localhost or something (192.168.0.2 or is that just for the question?).

What often solves things like this is to edit the ~/.ssh/known_hosts file and delete the entry for the domain you are connecting to, it will re-prompt you for ssh credentials and avoid problems caused by incorrect "expectations".


First run cat $HOME/.ssh/id_rsa.pub on your computer. That will get you a key. Save this key somewhere.

Then open this file by running vim $HOME/.ssh/authorized_keys on the computer that you're are ssh'ing to. Then copy the key in a new line of this file and close it by typing :wq.

You are all set.