I'm not able to establish an ssh connection to one of my remote servers.

I have the address, username and password for both.

To create the ssh connections as follow ssh user@server which gives me the following error Host key verification failed.

The most common answer to this topic is to run ssh-keygen -R hostname. The problem is on my remote server I have very limited rights and it gives me the error ssh-keygen: command is not found. Usually commands like service or su all give me the same error command is not found.

Since I'm able to create a connection over SFTP with Filezilla, can I manually fix this is problem? Also, if it's important, my .ssh directory is empty, so there is no known_host or something like this.

Here is the full output of ssh -v user@server

OpenSSH_6.6.1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Connecting to XXX port 22.
debug1: Connection established.
debug1: identity file /.ssh/id_rsa type -1
debug1: identity file /.ssh/id_rsa-cert type -1
debug1: identity file /.ssh/id_dsa type -1
debug1: identity file /.ssh/id_dsa-cert type -1
debug1: identity file /.ssh/id_ecdsa type -1
debug1: identity file /.ssh/id_ecdsa-cert type -1
debug1: identity file /.ssh/id_ed25519 type -1
debug1: identity file /.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.7p1Debian-5+deb8u4
debug1: match: OpenSSH_6.7p1 Debian-5+deb8u4 pat OpenSSH* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: kex: [email protected] need=20 dh_need=20
debug1: kex: [email protected] need=20 dh_need=20
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA XXX
debug1: read_passphrase: can't open /dev/tty: No such file or directory
Host key verification failed.

I use my Windows PC which connects to a remote server over ssh (let's call it Server 1) with PuTTy. On server 1 I have nearly zero rights to run anything besides scp and ssh and basic shell commands. On this server, I run a webshop which backups should stall on an other server (lets call it Server 2).

I wish I could use sftp, but I can't use it and can't install it on server 1. So I have to go with scp. I tried it with curl sftp://xxx.xxx which to my surprise did work, but still gets me an new error curl: (51) SSL peer certificcate or SSH remote key was not ok.

2 Answers 2


The Host key verification failed error message means that your SSH client has compared the received public key of the remote server and noticed that it does not match the stored version of the host key in ~/.ssh/known_hosts file.

The command ssh-keygen -R hostname does not do anything to the remote host and does not require any special permissions: all it does is remove the old host key for hostname from your local known_hosts file. Then, the next time you connect to hostname, your SSH client will display the fingerprint of hostname's current host key and will prompt you to accept it. Just like when connecting to some host for the first time.

But if you don't have that command available, you could try connecting with

ssh -o StrictHostKeyChecking=no user@server

The default value for the StrictHostKeyChecking option is ask, which prompts you to accept or reject previously-unknown host keys... but since your session apparently has no pseudo-TTY, the ssh client is in non-interactive mode and won't prompt. The value no should auto-accept the host key: if possible, ssh will write the host key to ~/.ssh/known_hosts file. If this is successful, you'll need to use the -o StrictHostKeyChecking=no option only when connecting to a particular server for the first time.

  • 3
    After i tried it with ssh -o StrictHostKeyChecking=no user@server i got an new error Permission denied (publickey, password). After that i switched to .ssh/ and the file known_hosts got created. In the following i tried the normal ssh user@server and got the error ssh: connect to host server port 22: connection refused
    – sHamann
    Commented Jan 11, 2018 at 21:48
  • OK, so it looks like you got through the host key check now, but failed authentication... and on the second time the server just rejected the connection attempt. Because you don't seem to have a /dev/tty device node, the SSH client thinks it won't be able to ask for passwords securely. You really should contact the administrator of the first server: this is probably an error in the setup of your restricted chroot environment.
    – telcoM
    Commented Jan 12, 2018 at 7:40
  • Glad it wasnt my fault all the way. I will get in contact with the administrator of the first server (we rent a sever at an webhost). I will keep you updatet if i got some new informations.
    – sHamann
    Commented Jan 12, 2018 at 9:10
  • @sHamann : so what happened after that ??
    – StanGeo
    Commented Jun 2, 2023 at 12:33
  • I have exactly the same issue, with bitbucket.org :-o They just changed their type of keys, all seems config seems okay at my side.
    – jaques-sam
    Commented Jun 22, 2023 at 14:05

I faced this issue when trying to SSH to remote machine from host running a custom built buildroot rootfs.

What I observed is the error message echoed "Host Key Verification failed" is misleading for scenario I faced. It was not actually about known_hosts file but regarding a echo that ssh want to do (like below)

This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])?

And for that it needs /dev/tty, which it is unable to find/write hence the error

read_passphrase: can't open /dev/tty: No such file or directory

So we need to fix this so that we can key in "yes" in console thereafter ssh can add the host key to known_hosts.

Solution which worked for me is, remove /dev/tty and softlink current tty to it.

ln -s $console /dev/tty

You must log in to answer this question.

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