【问题标题】:pull/push from gitlab results in Permission denied (publickey)从 gitlab 拉/推导致权限被拒绝(公钥)
【发布时间】:2020-06-16 13:17:54
【问题描述】:

我同时使用 git bash 和 VS 代码连接到我的 gitlab 存储库。一切正常,直到我创建了一个新的存储库并尝试通过 git bash 在本地克隆它。 我收到的错误是:

git@gitlab.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

我尝试更改 ./ssh 文件夹和公钥的权限,将 ssh 添加到代理,但这些都不起作用。

执行ssh -Tv <user name>@gitlab.com 显示以下输出:

OpenSSH_8.2p1, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to gitlab.com [172.65.251.78] port 22.
debug1: Connection established.
debug1: identity file /c/Users/user/.ssh/id_rsa type 0
debug1: identity file /c/Users/user/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.8
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.8 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to gitlab.com:22 as 'user'
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:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw
debug1: Host 'gitlab.com' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/user/.ssh/known_hosts:7
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: Bad file descriptor
debug1: Will attempt key: /c/Users/user
/.ssh/id_rsa RSA SHA256:rNZDTqdiVzM9+qjPlPV9wpd5Eg0t0tKKMonz+Q6+yGo
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/user/.ssh/id_rsa RSA SHA256:rNZDTqdiVzM9+qjPlPV9wpd5Eg0t0tKKMonz+Q6+yGo
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
<user name>@gitlab.com: Permission denied (publickey).

【问题讨论】:

    标签: git ssh gitlab public-key


    【解决方案1】:

    我尝试更改 ./ssh 文件夹和公钥的权限,将 ssh 添加到代理,但这些都不起作用。

    首先,确保您拥有registered the content of id_rsa.pub to your GitLab SSH keys profile page

    如果它仍然不起作用,请尝试重新生成该密钥,无需密码(用于测试,并排除任何 ssh-agent 问题,该问题仅用于缓存密码)

    ssh-keygen -m PEM -t rsa -P ""
    

    确保您的 Git for Windows 是最新的 (2.27)。

    确保set GIT_SSH=(意思是未设置GIT_SSH,不应指putty.exe)。

    【讨论】:

      猜你喜欢
      • 2019-03-08
      • 1970-01-01
      • 1970-01-01
      • 2014-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-08
      • 2022-08-09
      相关资源
      最近更新 更多