GitLab 错误消息 - 权限被拒绝(公钥) - Bitnami
Posted
技术标签:
【中文标题】GitLab 错误消息 - 权限被拒绝(公钥) - Bitnami【英文标题】:GitLab Error message - Permission denied (publickey) - Bitnami 【发布时间】:2021-05-08 16:52:15 【问题描述】:最后我设法在虚拟机上设置了 gitlab 服务器。静态 IP 是 192.168.xx.xx,我从浏览器正常进入 gitlab dashboar。到目前为止一切都很好。
我还在其他网络服务器上安装了 git,并创建了 git 文件,因此我可以将文件直接推送到 192.168.xx.xx(这是 gitlab 平台)。
我已生成 SSH 密钥 (id_ed25519) 并将它们存储在 /c/users/admin/.ssh/ 中。在这条路上我有
两个 id_ed25519 密钥(公钥和私钥) 名为 known_hosts 的文件我还将公钥复制到我的 gitlab 帐户中,因此 SHA256 在 Web 服务器和 gitlab 帐户上都是相同的。
我有一个问题,我无法完成我正在做的事情,因为我遇到了问题。当我运行这个命令时:
git clone git@192.168.xx.xx:root/sample.git
我收到一个错误:
Cloning into 'sample'...
git@192.168.xx.xx: Permission denied (publickey).
fatal: Could not read from remote repository.
我在整个互联网上搜索过,我发现这是一个常见问题,但我几乎尝试了所有方法。创建了文件等,但没有任何效果。
另外,我试过这个命令:
ssh-add /c/users/admin/.ssh/id_ed25519
Could not open a connection to your authentication agent.
我能做什么?
我跑
ssh -vT git@192.168.22.29 echo hello
OpenSSH_8.4p1, OpenSSL 1.1.1i 8 Dec 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 192.168.22.29 [192.168.22.29] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_rsa type 0
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_dsa type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ecdsa_sk type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ed25519 type 3
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ed25519_sk type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_xmss type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.9p1 Debian-10+deb10u2
debug1: match: OpenSSH_7.9p1 Debian-10+deb10u2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.22.29:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
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:YR5gM1BDDcT+p3EO8yehb4k42PUBs9W9x0bBwIi1mSM
debug1: Host '192.168.22.29' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/Administrator.CITY-1/.ssh/known_hosts:1
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: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_rsa RSA SHA256:PhxaREDKEGmjj2DYDvj+uAR/K1ns05O3S3JKgDMbvhQ
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_dsa
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_ecdsa
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_ecdsa_sk
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_ed25519 ED25519 SHA256:POB8QvlHpnMO0R/ViOTjwxfRegLlmmBca4jWRCgn/Hk
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_ed25519_sk
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/Administrator.CITY-1/.ssh/id_rsa RSA SHA256:PhxaREDKEGmjj2DYDvj+uAR/K1ns05O3S3JKgDMbvhQ
debug1: Authentications that can continue: publickey
debug1: Trying private key: /c/Users/Administrator.CITY-1/.ssh/id_dsa
debug1: Trying private key: /c/Users/Administrator.CITY-1/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/Administrator.CITY-1/.ssh/id_ecdsa_sk
debug1: Offering public key: /c/Users/Administrator.CITY-1/.ssh/id_ed25519 ED25519 SHA256:POB8QvlHpnMO0R/ViOTjwxfRegLlmmBca4jWRCgn/Hk
debug1: Authentications that can continue: publickey
debug1: Trying private key: /c/Users/Administrator.CITY-1/.ssh/id_ed25519_sk
debug1: Trying private key: /c/Users/Administrator.CITY-1/.ssh/id_xmss
debug1: No more authentication methods to try.
git@192.168.22.29: Permission denied (publickey).
===================================
经过研究,我忘记将公钥粘贴到 authorized_keys 中。 现在前面的命令显示了这个:
OpenSSH_8.4p1, OpenSSL 1.1.1i 8 Dec 2020
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to 192.168.22.29 [192.168.22.29] port 22.
debug1: Connection established.
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_rsa type 0
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_dsa type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ecdsa_sk type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ed25519 type 3
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ed25519-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ed25519_sk type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_xmss type -1
debug1: identity file /c/Users/Administrator.CITY-1/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.9p1 Debian-10+deb10u2
debug1: match: OpenSSH_7.9p1 Debian-10+deb10u2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 192.168.22.29:22 as 'bitnami'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
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:YR5gM1BDDcT+p3EO8yehb4k42PUBs9W9x0bBwIi1mSM
debug1: Host '192.168.22.29' is known and matches the ECDSA host key.
debug1: Found key in /c/Users/Administrator.CITY-1/.ssh/known_hosts:1
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: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_rsa RSA SHA256:PhxaREDKEGmjj2DYDvj+uAR/K1ns05O3S3JKgDMbvhQ
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_dsa
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_ecdsa
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_ecdsa_sk
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_ed25519 ED25519 SHA256:POB8QvlHpnMO0R/ViOTjwxfRegLlmmBca4jWRCgn/Hk
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_ed25519_sk
debug1: Will attempt key: /c/Users/Administrator.CITY-1/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/Administrator.CITY-1/.ssh/id_rsa RSA SHA256:PhxaREDKEGmjj2DYDvj+uAR/K1ns05O3S3JKgDMbvhQ
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /c/Users/Administrator.CITY-1/.ssh/id_dsa
debug1: Trying private key: /c/Users/Administrator.CITY-1/.ssh/id_ecdsa
debug1: Trying private key: /c/Users/Administrator.CITY-1/.ssh/id_ecdsa_sk
debug1: Offering public key: /c/Users/Administrator.CITY-1/.ssh/id_ed25519 ED25519 SHA256:POB8QvlHpnMO0R/ViOTjwxfRegLlmmBca4jWRCgn/Hk
debug1: Server accepts key: /c/Users/Administrator.CITY-1/.ssh/id_ed25519 ED25519 SHA256:POB8QvlHpnMO0R/ViOTjwxfRegLlmmBca4jWRCgn/Hk
debug1: Authentication succeeded (publickey).
Authenticated to 192.168.22.29 ([192.168.22.29]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Remote: /home/bitnami/.ssh/authorized_keys:5: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Remote: /home/bitnami/.ssh/authorized_keys:5: key options: agent-forwarding port-forwarding pty user-rc x11-forwarding
debug1: Sending command: echo hello
hello
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2616, received 2668 bytes, in 0.1 seconds
Bytes per second: sent 41858.5, received 42690.6
debug1: Exit status 0
退出状态 0 没问题。现在我的问题是我想将 .git 与 gitlab 连接,但是当我输入此命令时:
git clone git@192.168.22.29:user1/devnow.git
它显示密码提示。我有我用于此的所有密码的字段,但没有任何好的结果。 另外我想提一下我将 bitnami 与 debian + gitlab 一起使用。我想通过 ssh 登录到 user1 以访问 gitlab 以查看我的本地存储库。
【问题讨论】:
尝试运行“ssh -vT git@192.168.xx.xx echo hello”。这应该尝试连接到远程服务器并运行“echo hello”。 “-v”将导致 ssh 打印调试输出。然后edit你的问题包括调试输出。 我更新了我的帖子。又是同样的问题:/ 根据调试输出,ssh向远程服务器提供了.ssh/id_rsa和.ssh/id_ed25519,服务器均不接受。 我再次更新了我的帖子 请edit您的问题显示您收到的确切密码提示。不要解释事情。 【参考方案1】:首先尝试使用更简单的 rsa 方案的不带密码的密钥进行测试
# register mykey.pub content to your GitLab profile
ssh -i ~/.ssh/mykey git@192.168.22.29
# check you see a Welcome message
如果这不起作用,请尝试使用旧 PEM 格式的密钥:
ssh-keygen -t rsa -m PEM -P "" -f ~/.ssh/mykey
【讨论】:
是的,这太棒了!它有效.. 3 天后我终于收到了欢迎信息 :_)) @NickZagkanas 太好了,干得好!密码是问题吗?还是只使用 rsa 而不是 ed25519? 我只使用了 ed25519 键 :)以上是关于GitLab 错误消息 - 权限被拒绝(公钥) - Bitnami的主要内容,如果未能解决你的问题,请参考以下文章
权限被拒绝(公钥)。 GitLab 突然出现错误。我正确配置了私钥和公钥
在我的 Raspberry Pi 上从 Gitlab.com 克隆 Repo 时权限被拒绝(公钥)
SSH 到 GitLab 权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic)
无法将代码从 Vs Code 界面推送到 gitlab。 Git:git@gitlab.com:权限被拒绝(公钥,键盘交互)