18

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://username@gmail.com@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.

4

4 回答 4

9

我有同样的问题。
这两个命令对我也很有效:

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

但是这个没有用:

git push --all google

我必须编辑~/.ssh/config文件才能使其工作。它解决了我的问题。我补充说:

Host source.developers.google.com
    HostName source.developers.google.com
    User username@gmail.com
    IdentityFile ~/.ssh/your_private_key_file_registered_for_the_source_repo

在此处阅读有关~/.ssh/config文件的更多信息

于 2020-04-14T18:47:53.000 回答
1

当我尝试将现有存储库的远程设置为 Google Cloud Source Repos 时,我在 Linux(Mint/Ubuntu)上遇到了同样的问题。这就是你正在尝试的样子。但是,这是Expo CLI Quickstart生成的空 git 存储库,它根本没有文件或源历史记录。

我所做的是将 Google Cloud Source Repos 上的现有存储库克隆到我的计算机,添加一个虚拟文件,提交并推送。这对我有用。希望它对你有用。

于 2019-05-30T00:13:20.890 回答
1

我遇到了同样的问题,我发现的解决方案都没有奏效。事实证明 Google Cloud Source Repositories 不喜欢我的 SSH 密钥。(也许密钥太短了?)无论如何,我尝试切换到 ECDSA 密钥并且错误消失了。

ssh-keygen -t ecdsa -C "myuser@mygmailhost.com"

我也不得不用 ~/.ssh/config 中的新密钥替换我以前的密钥。

于 2022-01-09T22:21:45.840 回答
0

有类似的问题所以尝试了两件事:

1 - 本主题中的建议

是否 gcloud init 并创建和配置了 ~/.ssh/config 但这并没有解决问题。

2 - 然后在这里尝试了这个建议,它奏效了......

使用 Git 时如何解决 Permission denied (publickey) 错误?

于 2020-06-09T04:00:37.160 回答