I struggled for some time this morning with why Forge was telling me that the host keys weren't correct.
I finally renamed my ~/.ssh/known_hosts file and ran
ssh [email protected] host_key_info
and this remade my known_hosts file without a conflicting line.
I put this here just in case anyone else has run into this problem.
I tried all the steps described in this thread and also in the Bitbucket blog, but it still gives me the "Host key verification failed." error when trying to deploy.
The command "ssh [email protected] host_key_info" also gives me "Host key verification failed."
The problem seems to be over at Forge itself.
When SSH'ing manually into the server and running "ssh [email protected] host_key_info" I get:
"Warning: the ECDSA host key for 'bitbucket.org' differs from the key for the IP address [...] Are you sure you want to continue connecting (yes/no)?", but when you confirm with "yes", it shows the correct fingerprint.
When running the command through Forge (https://forge.laravel.com/servers/XXXXX/sites/YYYYY/commands), you get: "Host key verification failed."
Reached out to Forge support and got the issue resolved:
I simply ran ssh [email protected] host_key_info, looked at the output, and deleted any offending key lines.
In case the ssh command doesn't show you an ECDSA or ED25519 key, you would need to run ssh-keygen -R bitbucket.org && curl https://bitbucket.org/site/ssh >> ~/.ssh/known_hosts for each isolation user (when you run sudo -u <USER> -i as root, it will give you an interactive shell for <USER>). If you needed the ssh-keygen command, please run ssh [email protected] host_key_info afterwards again, to be sure to be sure.
Thanks @semgov , I had the same response from Forge. Running "ssh-keygen -R bitbucket.org && curl https://bitbucket.org/site/ssh >> ~/.ssh/known_hosts" completes ok but ssh [email protected] host_key_info cmd just fails with "Host key verification failed." Deployments still do not work. I have to admit devops is not my strongest area hence my reliance on Forge.
Ok, so James at Forge team was super helpful and fixed this for me. If the cmds above do not work you can remove the entries manually using sed -i.old -e '/AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/d' ~/.ssh/known_hosts