Today we came across a quite uncommon error with SSH. The error actually happened when trying to clone a github repository. When trying to connect to the remote server, we were getting “Host key verification failed.”. The SSH keys were there, but the connection was dying.
The problem was solved when adding the remote server’s key to the .ssh/known_hosts file, but why didn’t ssh add the key to this file automatically as it always does? Well, this was happening inside a CHROOT environment, so more debugging was needed.
After running the ssh email@example.com command with strace, we noticed that the /dev/tty device file did not exist, and the ssh commands could not prompt us to confirm that we wanted to add the key to the known_hosts file. The solution was quite simple, copy the /dev/tty device file to the dev directory of the CHROOT environment. After this, everything worked as expected.