Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DNABeast's avatar

Bitbucket rotating their host keys

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.

0 likes
17 replies
aurawindsurfing's avatar

Same problem here but it looks like bitbucked messed up something with private keys of forge as I'm not able to see it or replace it

Sjon's avatar

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."

semgov's avatar

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."

Should we refresh the Bitbucket token in Forge? (https://forge.laravel.com/user-profile/source-control)

Sjon's avatar

After contacting Bitbucket support, running the following command through forge fixed it:

ssh-keygen -R bitbucket.org && sed -i.old -e '/AAAAB3NzaC1yc2EAAAABIwAAAQEAubiN81eDcafrgMeLzaFPsw2kNvEcqTKl/d' ~/.ssh/known_hosts && curl https://bitbucket.org/site/ssh >> ~/.ssh/known_hosts

1 like
MikePageDev's avatar

I'm still having issues and unfortunately, I can just move to github as much as I would like to.

leemgu's avatar

Same issues here, I've messaged Forge support also, I'd like some clarification before I go running any commands against a productions server.

leemgu's avatar

@MikePageDev Hey Mike, see below. Forge gave me some cmds to run but no luck my end at the moment.

semgov's avatar

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.

1 like
leemgu's avatar

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.

leemgu's avatar

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

kkhicher1's avatar
Level 2

Login to SSH as Forge user and hit command below one by one.

First Command

mv ~/.ssh/known_hosts ~/.ssh/known_hosts.old2

Second Command

touch ~/.ssh/known_hosts

Third Command

ssh-keygen -R bitbucket.org && curl https://bitbucket.org/site/ssh >> ~/.ssh/known_hosts

After that you try to deploy from Forge Command

Please check this medium post for Visual guide - https://medium.com/@kkhicher1/solved-forge-issue-host-key-verification-failed-bitbucket-rotating-host-keys-16a428b19842

3 likes

Please or to participate in this conversation.