using VSCode with Google Cloud Source Repository

authentication is the struggle of the cloud engineer

For one of my side projects, I wanted to build an entire backend using only Google’s cloud tooling. That included using Google’s cloud source repositories instead of the ubiquitous GitHub. I also wanted to learn more industry-standard practices, which meant learning how to VSCode. This should be easy: after creating a cloud source repository inside Google Cloud, there is a nice Clone button to use VSCode …

Permission denied (publickey).

OK fine, cloud source repository tells me to go to documentation on how to set up SSH keys which is pretty standard fare. I install PuTTY and then run PuTTYGen to generate a private and public key. I register the public key with cloud source repositories and then try Clone and … same failure.

In reading some troubleshooting I find that VSCode does not support PuTTY. Instead I must generate an OpenSSH-friendly private key, which PuTTYGen can do by going to Conversions->Export OpenSSH as described here. I try to Clone and … same failure.

At this point, I look for extensions. There’s Cloud Code for VS Code but that is for deployment, not source control. There’s nothing else after that.

The above guide on using OpenSSH with PuTTYGen gave me an idea so I tried to copy their ~/.ssh/config file over but I couldn’t figure out all the fields. I then decide to Google for "cloud source repository" permission denied and find this answer to dealing with cloud source repository errors that has a better example .ssh/config. I use that example and Clone and … success!!!

So, to get VSCode to clone a Google cloud source repository in Windows, the key is to get your authentication right.

  • Download PuTTY and open PuTTYGen.
  • Generate a SSH key pair by clicking Generate.
  • Set the comment to something useful (I used desktop-name@repo-name).
  • Click Conversions->Export OpenSSH to save an OpenSSH key.
    • This is a private key; I saved it with extension .ppk.
  • In Google Cloud’s SSH key management, click Register SSH Key.
    • Name the key (I used the comment `desktop-name@repo-name).
    • Copy the public key from PuTTYGen into the key field.
    • Click Register.
  • Back on your computer, create a file ~/.ssh/config with the following

If your ~/.ssh/config file already exists, try to find a section that starts with


If that section exists, add the IdentityFile line above to that section. Otherwise, create a new section that is the above.

Now your authentication is ready: Google Cloud has a public key that matches the OpenSSH-friendly-and-thus-VSCode-friendly private key.

Create your repository and check that in your empty repository, cloud source repositories notices you’ve registered SSH keys by saying so in the middle. Then follow the remaining instructions (clicking the Clone button and making the initial commit/push). Done!

Published by using 475 words.