SSH密钥无法用于Google Cloud Source仓库的问题求助
Google Cloud Source仓库SSH克隆权限拒绝问题
我在GitHub、GitLab及其他代码仓库均成功配置过SSH密钥,但为Google Cloud Source仓库配置时遇到权限问题。
克隆命令及错误信息
执行以下克隆命令:
git clone ssh://<user_name>@<domain>.com@source.developers.google.com:2022/p/<project-id>/r/omni-orchestrator
返回错误:
Cloning into 'omni-orchestrator'... Warning: Permanently added the ECDSA host key for IP address '[<Some_IP>]:2022' to the list of known hosts. <user_name>@<domain>.com@source.developers.google.com: Permission denied (publickey). fatal: Could not read from remote repository.
验证访问权限
通过gcloud命令可正常克隆仓库,说明我拥有该仓库的访问权限:
$ gcloud source repos clone omni-orchestrator --project=<project_id> Cloning into '/home/<user>/workspaces/<client>/gcp/omni-orchestrator'... warning: You appear to have cloned an empty repository. Project [<project_id>] repository [omni-orchestrator] was cloned to [/home/<user>/workspaces/<client>/gcp/omni-orchestrator].
已尝试的解决方案
我已按照相关官方指引创建多个不同名称的密钥,并尝试了以下两种方案,但均未解决问题,仍提示公钥权限拒绝:
1. 配置~/.ssh/config指定私钥
在~/.ssh目录下创建config文件,内容如下:
Host gitserv Hostname source.developers.google.com IdentityFile ~/.ssh/<user_name>_<domain>_com User <user_name>@<domain>.com
2. 设置GIT_SSH_COMMAND环境变量
执行以下命令:
<user_name>@AWESOME-<user_name>3:~/workspaces/<domain>/gcp$ export GIT_SSH_COMMAND='ssh -v -i /home/<user_name>/.ssh/<user_name>_<domain>_com -o IdentitiesOnly=yes' <user_name>@AWESOME-<user_name>3:~/workspaces/<domain>/gcp$ git clone ssh://<user_name>@<domain>.com@source.developers.google.com:2022/p/<project_id>/r/omni-orchestrator fatal: destination path 'omni-orchestrator' already exists and is not an empty directory. <user_name>@AWESOME-<user_name>3:~/workspaces/<domain>/gcp$ cd .. <user_name>@AWESOME-<user_name>3:~/workspaces/<domain>$ git clone ssh://<user_name>@<domain>.com@source.developers.google.com:2022/p/<project_id>/r/omni-orchestrator Cloning into 'omni-orchestrator'... OpenSSH_7.6p1 Ubuntu-4ubuntu0.7, OpenSSL 1.0.2n 7 Dec 2017 debug1: Reading configuration data /home/<user_name>/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to source.developers.google.com [74.125.133.82] port 2022. debug1: Connection established. debug1: identity file /home/<user_name>/.ssh/<user_name>_<domain>_com type 2 debug1: key_load_public: No such file or directory debug1: identity file /home/<user_name>/.ssh/<user_name>_<domain>_com-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.7 debug1: Remote protocol version 2.0, remote software version Go debug1: no match: Go debug1: Authenticating to source.developers.google.com:2022 as '<user_name>@<domain>.com' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256@libssh.org debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:AGvEpqYNMqsRNIviwyk4J4HM0lEylomDBKOWZsBn434 debug1: Host '[source.developers.google.com]:2022' is known and matches the ECDSA host key. debug1: Found key in /home/<user_name>/.ssh/known_hosts:7 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 134217728 blocks debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Offering public key: ECDSA SHA256:z7IqQohzIjyZVpxTTGKams9JxhquHb9pYhtnWMfgkuE /home/<user_name>/.ssh/<user_name>_<domain>_com debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. <user_name>@<domain>.com@source.developers.google.com: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
内容的提问来源于stack exchange,提问作者Imad
相关产品推荐
相关产品推荐

