[英]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.