4

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.

3 Answers 3

11

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 666 /dev/tty seemed to fix it.

4
  • 5
    Make it 666. There's no point giving execution permission to that device. Commented Sep 23, 2012 at 7:56
  • OK, if you say so :) Commented Sep 23, 2012 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
    Commented Mar 28, 2013 at 20:31
  • @dma_k I had this problem as well. The fix was to run su with -s /bin/bash
    – EM0
    Commented Dec 24, 2017 at 18:54
5

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.

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .