code: def _SetSshHostKeys(self, host_key_types=None):
      
      section = 'Instance'
      instance_id = self._GetInstanceId()
      if instance_id != self.instance_config.GetOptionString(
          section, 'instance_id'):
        self.logger.info('Generating SSH host keys for instance %s.', instance_id)
        file_regex = re.compile(r'ssh_host_(?P<type>[a-z0-9]*)_key\Z')
        key_dir = '/etc/ssh'
        key_files = [f for f in os.listdir(key_dir) if file_regex.match(f)]
        key_types = host_key_types.split(',') if host_key_types else []
        key_types_files = ['ssh_host_%s_key' % key_type for key_type in key_types]
        for key_file in set(key_files) | set(key_types_files):
          key_type = file_regex.match(key_file).group('type')
          key_dest = os.path.join(key_dir, key_file)
          self._GenerateSshKey(key_type, key_dest)
        self._StartSshd()
        self.instance_config.SetOption(section, 'instance_id', str(instance_id))
docs: Regenerates SSH host keys when the VM is restarted with a new IP address.
  
      Booting a VM from an image with a known SSH key allows a number of attacks.
      This function will regenerating the host key whenever the IP address
      changes. This applies the first time the instance is booted, and each time
      the disk is used to boot a new instance.
  
      Args:
        host_key_types: string, a comma separated list of host key types.