[英]Get Permission denied (publickey) for Git push to Google Cloud Source Repository with Google Cloud SDK authentication method on Windows 10
[英]Google Cloud Source Repositories: Permission denied (publickey)
我在项目中设置了源存储库。 我有我的主要管理员用户,我创建了第二个用户(首先尝试了一个服务帐户)并授予该用户“项目所有者”对带有源代码库的项目的访问权限。
我通过运行以下命令在本地计算机上创建了一个 SSH 密钥: ssh-keygen -t rsa -P "" -C "user@domain.com" -f "mysshfile"
我在 my.ssh 文件夹中创建了一个配置文件:
Host source.developers.google.com
HostName source.developers.google.com
Port 2022
IdentityFile /Users/XXXXX/.ssh/mysshfile
我复制了我的 mysshfile.pub 的内容并使用 Cloud repo SSH 密钥注册了它。
当 git 克隆为我的第二个用户时,它失败并显示错误消息: Permission denied (publickey) 。 当我 git 克隆为我的主要管理员用户时,它可以工作。
所以我运行了详细的 ssh 命令来检查: ssh -p 2022 -l admin@domain.com -v source.developers.google.com
,我得到:
…………
debug1: Offering public key: /Users/xxxxxx/.ssh/mysshfile RSA SHA256:U+XREDACTED explicit
debug1: Server accepts key: /Users/xxxxxx/.ssh/mysshfile RSA SHA256:U+XREDACTED explicit
debug1: Authentication succeeded (publickey).
Authenticated to source.developers.google.com ([74.125.197.82]:2022).
当我运行与我的测试用户相同的命令时: ssh -p 2022 -l test@domain.com -v source.developers.google.com
,我得到:
debug1: Offering public key: /Users/xxxxxxx/.ssh/mysshfile RSA SHA256:U+XJREDACTED explicit
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
test@domain@source.developers.google.com: Permission denied (publickey).
我不明白为什么使用 ssh 的 git 克隆适用于一个用户(我什至不想要的那个)而不是另一个?
您需要将以下行添加到您的配置文件中:
PubkeyAcceptedKeyTypes +ssh-rsa
所以现在应该是:
Host source.developers.google.com
HostName source.developers.google.com
Port 2022
IdentityFile /Users/XXXXX/.ssh/mysshfile
PubkeyAcceptedKeyTypes +ssh-rsa
在详细模式下,您将看到以下几行:
debug1: send_pubkey_test: no mutual signature algorithm
这意味着ssh-rsa
算法被禁用。 可以按照此处的说明重新启用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.