Google Cloud Source and git on windows
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. (I tried to accomplish the ssh-agent install and startup via powershell, but ran into issues later on down this path...ssh-agent "$env:ProgramFiles\git\usr\bin\ssh-agent.exe" )
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). Note that you will need forward slashes on the file paths (since this is a bash emulator)
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 specify each folder name individually; underlying files in a folder are automatically added)
git remote add GoogleRepo ssh://[email protected]@source.developers.google.com:2022/p/projectid/.. git push --all GoogleRepo
On your local folder - Fatal - Not a git repo...
Fatal - Not a git repo...error
Simply fire up a bash for windows prompt and type git init
If you want to simply clone the remote repo locally
git clone ssh://[email protected]@source.developers.google.com:2022/p/projectid
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.
Leave a Reply