How to Address SSH Host Key Verification Issues in Cloud Shell (temporary)
Why is Host Key Verification Important? Host key verification ensures the authenticity of the server you are connecting to. It protects against Man-in-the-Middle (MitM) attacks. Ignoring or bypassing this verification can expose sensitive data and compromise the security of your server.
Option 1: Manual Verification
- Delete the problematic server entry from the
known_hosts
file in your cloud shell. - Try to log in to the server again. If it does not prompt for host key verification, proceed to the next step.
- Log in to your server using a Windows terminal or Linux terminal (not the cloud shell).
- Obtain a copy of the server's host key fingerprint using:
ssh-keygen -lf /etc/ssh/ssh_host_rsa_key.pub
- Copy the displayed fingerprint and paste it into your
known_hosts
file in the cloud shell:
nano .ssh/known_hosts
- Try logging in again; it should work.
Option 2: Temporarily Bypass Verification (Not recommended!)
- In your cloud shell, navigate to the
.ssh
directory:
cd .ssh/
- Create or edit the
config
file using a text editor likevim
:
vim config or nano config
- Add the following lines to disable host key checking:
Host *
StrictHostKeyChecking no
- After logging in and verifying the server's host key, delete the
config
file or comment out the lines you added:
#Host *
#StrictHostKeyChecking no
Warning: Disabling StrictHostKeyChecking
is risky and not recommended for regular use. Always ensure you are connecting to the intended server.