After generating an RSA-based SSH key:
ssh-keygen -t rsa -f ~/.ssh/id_rsa -C id_rsa
#=>
Generating public/private rsa key pair.
Created directory '/. . ./.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /. . ./.ssh/.id_rsa.
Your public key has been saved in /. . ./.ssh/.id_rsa.pub.
The key fingerprint is:
SHA256:. . . id_rsa
The key's randomart image is:
+---[RSA 3072]----+
| . . . |
+----[SHA256]-----+
I am able to add it to my Google Cloud Platform (GCP) project's ($GCP_PROJECT_NAME
) Compute metadata:
gcloud compute project-info add-metadata \
--metadata-from-file ssh-keys=./.ssh/id_rsa.pub
#=>
WARNING: The following key(s) are missing the <username> at the front
ssh-rsa . . . id_rsa
Format ssh keys following https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys
Updated [https://www.googleapis.com/compute/v1/projects/$GCP_PROJECT_NAME].
with a warning, but unable to connect to a GCP Compute instance with it.
If I:
pbcopy < ~/.ssh/id_rsa.pub
and I paste it into the GCP Console, I am able to use it.
How would I accomplish the same thing with the GCP SDK (gcloud
)?