Host key verification failed message is a common error that triggers during a rsync operation. It happens when the host key of the remote host changes
As a part of our Server Management Services, we help our Customers to fix rsync related errors regularly.
Let us today discuss the possible causes and fixes for this error.
When does the host key verification failed error show up in rsync?
Rsync uses a remote-shell program like SSH or RSH to contact the remote server. Host validation checks to make sure that you are connecting to the host that you think you are connecting to. It appends the server’s public host key to the user’s ~/.ssh/known_hosts file during the first login and then compares this value with the one that server supplies in following connections.
If this comparison fails, it shows the result, “Host key verification failed”.
Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(226) [Receiver=3.1.1]
The possible reasons for this error include:
- Mismatch of the private key in the hosts files
- Incorrect access rights to /dev/tty
How to fix the host key verification failed error in rsync?
Let us now discuss how to fix the host key verification failed error in rsync.
Manual removal of old keys
To fix the error caused by changed host key, we will need to remove the host key from the file using the command below:
ssh-keygen -R hostname/IP address
It may then ask for a verification on the next login. Once confirmed, it will add the new key to the host file.
Correct the permission issue
As this error could happen due to the wrong permission of the /dev/tty file, it can be fixed by correcting them. Setting the permission of the file to 666 can help in correcting the issue.
chmod 666 /dev/tty
Alternate Fixes
Apart from the major reasons mentioned above, some other reasons like using the wrong hostname/IP address can also trigger this error. The fix here would be to double-check the IP address or hostname used for the connection.
Alternatively, this error can be fixed by disabling the host key check with rsync. This can be done by appending the parameter “ssh -o StrictHostKeyChecking=no” with the rsync command.
[Need help to fix SSH errors? We are available 24×7.]
Conclusion
In short, the host key verification failed error show up in rsync when the host key of the remote server changes, and the system does not allow access for security purposes. Today we saw how our Support Engineers fixes this error.
0 Comments