在Windows 10上使用Google Cloud SDK身份验证方法将Git推送到Google Cloud Source Repository的权限被拒绝(公钥)

Jec*_*cko 8 git google-cloud-platform windows-10 google-cloud-source-repos

我正在尝试使用Google Cloud Source资源库作为远程资源库。我遵循了所有过程,以使用Google Cloud SDK身份验证方法进行身份验证,该方法允许我不使用SSH密钥(如他们所说)。

问题是:Permission denied (publickey) fatal: Could not read from remote repository.尝试时总是收到消息git push --all google

gcloud命令位于Windows PATH(C:\Users\xxxxx\AppData\Local\Google\Cloud SDK\;)中,并且我是Google Cloud中项目的所有者,因此我的用户具有足够的权限。

我知道此消息通常是一个简单的SSH密钥问题,可以通过将我的公共密钥添加到项目中来解决,但是该方法应该在没有ssh密钥的情况下也可以工作,因此我想了解自己在做什么。

这是我按照Google Cloud Source Repository过程执行的前两个命令:

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
Run Code Online (Sandbox Code Playgroud)

这两个效果很好。

也许有人可以帮助我找到解决方法。

谢谢。

Emm*_*uel 12

我遇到了同样的问题,但我找到的解决方案都不起作用。事实证明,Google Cloud Source Repositories 不喜欢我的 SSH 密钥。(也许密钥太短?)无论如何,我尝试切换到 ECDSA 密钥,错误消失了。

ssh-keygen -t ecdsa -C "myuser@mygmailhost.com"
Run Code Online (Sandbox Code Playgroud)

我也必须在 ~/.ssh/config 中用新密钥替换以前的密钥。

  • 也为我工作过。因此,在使用 GitHub 时有类似的解决方案,我想知道它是否相关:https://github.blog/2021-09-01-improving-git-protocol-security-github/ (2认同)

小智 7

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

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
Run Code Online (Sandbox Code Playgroud)

但是这个没有用:

git push --all google
Run Code Online (Sandbox Code Playgroud)

我必须编辑~/.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
Run Code Online (Sandbox Code Playgroud)

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


小智 1

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

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