Reputation: 41
I am trying to add my public ssh-key to my project but can't seem to make it work. According to documentation : https://cloud.google.com/compute/docs/instances/adding-removing-ssh-keys?hl=fr#project-wide ; after creating my ssh txt file I need to use the command :
gcloud compute project-info add-metadata --metadata-from-file ssh-keys=[LIST_PATH]
I named my ssh txt file "ssh.txt" and my full path was to file was : C:\Users\33768\Desktop\ssh.txt .
I tried the following commands :
gcloud compute project-info add-metadata --metadata-from-file ssh-keys=C:\Users\33768\Desktop\ssh.txt
gcloud compute project-info add-metadata --metadata-from-file ssh-keys="C:\Users\33768\Desktop\ssh.txt"
gcloud compute project-info add-metadata --metadata-from-file ssh-keys=C:/Users/33768/Desktop/ssh.txt
gcloud compute project-info add-metadata --metadata-from-file ssh-keys="C:/Users/33768/Desktop/ssh.txt"
Yet, none of them worked, error being :
ERROR: (gcloud.compute.project-info.add-metadata) Unable to read file [LIST_PATH]: [Errno 2] No such file or directory: [LIST_PATH]
where I replaced the actual list path that command line tool showed by [LIST_PATH]. Please someone help, I am getting crazy. Thx.
Upvotes: 3
Views: 3844
Reputation: 302
@John Hanley: [LIST_PATH], or ssh.txt in this case, is the concatenation in a single file of all the public keys (.pub) to upload as metadata.
Upvotes: 0
Reputation: 41
Thanks everyone. I actually found why it was not working. I used ubuntu for windows and that messed up the path of my folders. Inside the ubuntu terminal, I do not have access to folder in my local machine that are not on my ubuntu folder. Just ran my commands outside of ubuntu terminal and it worked !
Upvotes: 1
Reputation: 4443
From your post I see you use Windows. I don't know how you generate your keys so I will write down everything starting from this procedure.
Download Putty (it also includes PuttyGen). Run PuttyGen, change "comment" field to your username@somemachine and click "Generate" button. After some "mouse moving" you will get your personal SSH-key which looks something like this:
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAtJqgJA1MLB7ZqIL+xF0cnZaXyGW9LYxlyj/JrK/eOkgvRN36zI7xJc1ML5uO2Hn+EPiTwKO5+0xmwomZKnu2nrCsuZzQZakGWHiyKBYSQ1x+l+PqISOniiHOGTHc0p//lwbCLKO7bUUYuS2+7Uw3lNhKytnNA7WbcfMmm+NTH2C8ZdWptWaGmX/Yt1kdUKFCyTLAlXqdoNyr4QssdaMo4BY07JUrYHGN8Uzt7/Knd6zqqsK4Hzf0lTzxYdiuP3Y6qYBcAMtLs7iaEibu8r/i1Js7DpSHQTUYbQ6lWBk7p1yI8XJ809FTXLy20doF3ElQjBrqk/dkDk1p3AV2RlplYQ== username@somemachine
Click "save public key" and save it on some directory. After that "save private key" - ideally to the same directory.
You have your keys generated and saved.
Now - add them to your GCP project. Easiest ways are:
gcloud compute project-info add-metadata --metadata-from-file ssh-keys=your_file_name/name/and/path
- when adding you might get a warning The following key(s) are missing the <username> at the front
- don't worry - they will still work.If in doubt just read the documentation how to add private SSH-keys to your GCP project. It's a bit long but everythin's explained in detail.
Furthermore - I generated keys on Linux, added them the same way to my project and it also works.
Upvotes: 0