In my test user, who is invoking 'gcloud compute ssh' is already granted roles/compute.instanceAdmin.v1
$ gcloud compute ssh test-vm-02
Updating project ssh metadata...failed.
Updating instance ssh metadata...failed.
ERROR: (gcloud.compute.ssh) Could not add SSH key to instance metadata:
- The user does not have access to service account '
1220045221...@developer.gserviceaccount.com'. User: '
jd...@acme.com'. Ask a project owner to grant you the iam.serviceAccountUser role on the service account
After creating a binding, it works
$ gcloud iam service-accounts add-iam-policy-binding 105769910040773408142 --member='
user:jd...@acme.com' --role='roles/iam.serviceAccountUser'
$ gcloud compute ssh test-vm-02
Updating project ssh metadata...failed.
Updating instance ssh metadata...⠛Updated [
https://www.googleapis.com/compute/v1/projects/playground-337303/zones/asia-southeast1-b/instances/test-vm-02].
Updating instance ssh metadata...done.
Waiting for SSH key to propagate.
Warning: Permanently added 'compute.8169197730585635041' (ECDSA) to the list of known hosts.
Linux test-vm-02 4.19.0-18-cloud-amd64 #1 SMP Debian 4.19.208-1 (2021-09-29) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.