SSH: In private network how to access the remote machine from source machine without using ssh public key
As you know the first time you ssh
to a remote host it asks you whether you'd like to store the remote host key to ~/.ssh/known_hosts
. Every time you access the remote host afterwards ssh
verifies received host key against ~/.ssh/known_hosts
.
However when ssh
runs in CodeBuild or some other non-interactive setup it can't ask whether to accept the remote key (because there's no one to ask in a non-interactive session) and to be on the safe side it fails with Host key verification failed
You've got two options how to fix it:
More secure is to provide the Ubuntu server's host key to your CodeBuild and store it to a
known_hosts
file wheressh
can verify it. Make sure it's in the right path with the correct ownership and permissions.Less secure is to disable the check:
ssh -o StrictHostKeyChecking=no {your-ubuntu-server}
Hope that helps :)