3

When I try to ssh to my server from a linux computer with debian, I just get

Host key verification failed.

The only help I found online was deleting the key from ~/.ssh/known_hosts... well I did not only that, I deleted the whole ~/.ssh just to be sure, and it didn't help either, I still have Host key verification failed. error.

9

OK, answered.

When I run ssh with -v option, it showed me the actual error.

It was caused by mistakenly setting wrong access rights to /dev/tty, whatever that is, and ssh somehow didn't like it. sudo chmod 777 /dev/tty seemed to fix it.

  • 5
    Make it 666. There's no point giving execution permission to that device. – Stéphane Chazelas Sep 23 '12 at 7:56
  • OK, if you say so :) – Karel Bílek Sep 23 '12 at 12:50
  • 1
    I have similar problem (debug1: read_passphrase: can't open /dev/tty: No such device or address) but chmod 666 /dev/tty does not help. It works with my user, but after I switched to another user with su it fails. – dma_k Mar 28 '13 at 20:31
  • @dma_k I had this problem as well. The fix was to run su with -s /bin/bash – EM0 Dec 24 '17 at 18:54
4

So the poster's problem has been resolved. But in case others come to this question by searching and their symptoms are not coming from the same cause:

Deleting ~/.ssh/known_hosts (or just the offending line in it) will purge the cached host key. However, there is also a system-wide cache, which will be stored someplace like /etc/ssh/ssh_known_hosts. Host keys won't be cached there unless that's specifically requested. But if you're having host key verification issues, have a look in both of these files.

0

It is also possible to run into this issue in various other ways, especially when dealing with Windows which may have several implementations of SSH tacked on to it.

I ran into this when ssh'ing into a Windows 10 machine that was running SSH server under Cygwin. When you run ssh from that prompt, it runs the cygwin version of ssh, which uses ~/.ssh to store the ssh files --- under cygwin that is /home/username.

However, if you run git from that same prompt, and Git has been installed via Windows (which in my case it had been), it uses the ssh files from C:\Users\username.ssh.

Normally you run ssh hostname to cache the host key for git, but in this case it does not work, since there are different known_hosts files.

Once I copied the key from one known_hosts file to the other, the git commands worked fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.