Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Unable to connect to VM's through Cloud Shell

I've been trying to connect to my VMs through Cloud Shell using the cloud command. 

udaysrinivas_1-1654484103923.png

But every time I try it's giving me this error:

root@cs-551720538893-default:/home/user# gcloud compute ssh --zone "us-east4-a" "hostname" --tunnel-through-iap --project "project_id"
Writing 3 keys to /root/.ssh/google_compute_known_hosts
WARNING:

To increase the performance of the tunnel, consider installing NumPy. For instructions,
please see https://cloud.google.com/iap/docs/using-tcp-forwarding#increasing_the_tcp_upload_bandwidth

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:****************************************.
Please contact your system administrator.
Add correct host key in /root/.ssh/google_compute_known_hosts to get rid of this message.
Offending RSA key in /root/.ssh/google_compute_known_hosts:3
remove with:
ssh-keygen -f "/root/.ssh/google_compute_known_hosts" -R "compute.***********"
ECDSA host key for compute.******** has changed and you have requested strict checking.
Host key verification failed.

Recommendation: To check for possible causes of SSH connectivity issues and get
recommendations, rerun the ssh command with the --troubleshoot option.

gcloud compute ssh hostname --project=projectId --zone=us-east4-a --troubleshoot

Or, to investigate an IAP tunneling issue:

gcloud compute ssh hostname --project=projectId --zone=us-east4-a --troubleshoot --tunnel-through-iap

ERROR: (gcloud.compute.ssh) [/usr/bin/ssh] exited with return code [255].
root@cs-*******-default:/home/user#

Solved Solved
0 3 4,490
1 ACCEPTED SOLUTION

Thanks for the reply but what helped me was, adding this flag --strict-host-key-checking=no to the gcloud command. 

View solution in original post