Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Permission denied (publickey) for Git push to Google Cloud Source Repository with Google Cloud SDK authentication method on Windows 10

I'm trying to use Google Cloud Source Repository as a remote repository. I followed all the procedures to authenticate with the Google Cloud SDK authentication method that allows me to not use SSH keys (as they say).

The problem is: I always get Permission denied (publickey) fatal: Could not read from remote repository. message when I try git push --all google.

The gcloud command is in my Windows PATH (C:\Users\xxxxx\AppData\Local\Google\Cloud SDK\;) and my user has enough permission as I'm the owner of the project in Google Cloud.

I know this message is usually a simple SSH key problem that can be resolved by adding my public key to the project, but this method is supposed to work without ssh keys, so I would like to learn what I am doing wrong.

Here the 2 first commands I made following the Google Cloud Source Repository procedure:

gcloud init && git config --global credential.https://source.developers.google.com.helper gcloud.cmd
git remote add google ssh://[email protected]@source.developers.google.com:2022/p/my-website-project/r/my_website

These 2 worked well.

Maybe someone could help me to find what to do to fix that.

Thank you.

like image 877
Jecko Avatar asked Mar 02 '19 18:03

Jecko


1 Answers

I had the same problem.
These two commands worked well for me too:

gcloud init && git config --global credential.https://source.developers.google.com.helper gcloud.cmd
git remote add google ssh://[email protected]@source.developers.google.com:2022/p/my-website-project/r/my_website

But this one didn't work:

git push --all google

I had to edit ~/.ssh/config file to make it work. It solved my problem. I added:

Host source.developers.google.com
    HostName source.developers.google.com
    User [email protected]
    IdentityFile ~/.ssh/your_private_key_file_registered_for_the_source_repo

Read more about ~/.ssh/config file here

like image 155
Kyrylo Bulat Avatar answered Sep 22 '22 12:09

Kyrylo Bulat