Trying to use Google Cloud Source as a git repo, you may encounter an authentication error (in spite of storing your SSH public key correctly with your IAM user profile)

 Permission denied (publickey).
fatal: Could not read from remote repository.Please make sure you have the correct access rights
and the repository exists.

The Solution

Firstly, if you are on windows, ensure that git bash for windows is installed.

Now, you need to add your private key (e.g. id_rsa) to the SSH-agent. This allows for Single Sign On (i.e. your private key is automatically checked by the agent against the public key on the remote repo)

Owner@DESKTOP   $ ssh-add c:/my_path_to_my_private_key Could not open a connection to your authentication agent.

Owner@DESKTOP $ ssh-agent bash

Owner@DESKTOP $ ssh-add c:/my_path_to_my_private_key/id_rsa

Identity added: (output from git bash)


Now, add all your local files to the remote repo (e.g. Google Cloud Source)

git add . (may have to add each folder individually – underlying files in a folder are automatically added)

git remote add GoogleRepo ssh://username@gmail.com@source.developers.google.com:2022/p/projectid/..

git push –all GoogleRepo

Summary

Using git for windows in conjunction with Google cloud source presented a couple of minor issues. Firstly, the private part of the key pair needs to be added to the ssh-agent. Secondly, to ensure the ssh-agent is running, you may need git bash for windows.

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.