Why does Google recommend removing SSH keys from GCE for security?

The critical detail is that the page you’ve referenced is about creating a new Compute Engine machine image. Specifically, when you create a new virtual machine image, you want to ensure it does NOT include any host keys. That way, when the image is cloned and reconstituted into an actual VM, the sshd startup script will recognize that there are no host keys, and automatically generate new ones. This is desirable because having multiple machines using the same host key is a very bad idea.

So, in the general case, please do not go deleting your host keys, but if you are creating a new image, it’s an important step in order to ensure there’s a one-to-one relationship between host keys and machines.

Leave a Comment