This post explains how to register SSH Keys for setting up local authentication to interact with Google Cloud Source Repositories.
We can use SSH public key authentication to access Google Cloud Source Repositories. Follow below steps to set-up SSH authentication to Google Cloud Source Repositories.
1. Download and set-up Git for windows from https://gitforwindows.org/ .
2. In windows search for Git Bash and open Git Bash.
2. Enter below command in Git Bash. Replace USER EMAIL with your email address.
ssh-keygen -t ecdsa -C "USER EMAIL"
3. On prompt, To accept the default ~/.ssh location, press Enter, otherwise specify a filename.
4. On prompt, leave the passphrase empty and press Enter.
5. Navigate to ~/.ssh directory and copy the public key from id_ecdsa.pub.
6. Login to Google Cloud Console and navigate to Source Repositories.
7. In the Source Repositories click on More Items and than click on Manage SSH Keys.
8. Click on Register SSH Key.
9. Provide key name In the Key name field. In the Key field copy the key retrieved in Step 5 and click on Register.
After registering the SSH keys you should be able access Source Repositories. If you are getting below error than follow the below mentioned steps to fix this issue.
@source.developers.google.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
10. Navigate to ~/.ssh directory, create a file with name config and write following configuration, replace USER EMAIL with your email address.
Host source.developers.google.com
HostName source.developers.google.com
User <<USER EMAIL>>
IdentityFile ~/.ssh/id_ecdsa
IdentitiesOnly yes
Category: GCP