I use a notebook with Ubuntu 12.10 and try to connect a server with Ubuntu 12.04. The server has already installed openssh-server. And allow publick key and password to login. But I connect the server sometime well but after minutes it will be error. First, it will show me these messages:

   WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
   ......
   Add correct host key in /home/myname/.ssh/known_hosts to get rid of this message.

but I never reinstall system and the openssh-server. Both are never changed! The server nerver shutdown or reboot.

Second, after I remove the relative key from my known_hosts and use ssh connect the server again, it will let me type my password. then my nightmare coming... Permission denied (publickey,password)

But I typed the correct password!

PS: I used password and public key both success. But the problem will appear again after i logout then login.

migrated from stackoverflow.com Nov 23 '12 at 10:18

This question came from our site for professional and enthusiast programmers.

Do you want to allow password auth? If so you can edit the /etc/ssh/sshd_config to include:

PasswordAuthentication yes

Also make sure these are set correctly for your key auth:

PubkeyAuthentication yes
AuthorizedKeysFile     %h/.ssh/authorized_keys

You can also have it ignore your known_hosts file... for debugging only please :)

IgnoreUserKnownHosts yes

Also ensure you have correct perms on your key files.. ssh is very particular about it:

chmod 700 ~/.ssh
chmod 600 ~/.ssh/*

Lastly, if all else fails send us output of your session attempt using 'ssh -vvvv'.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.