GitLab 错误消息 - 权限被拒绝(公钥) - Bitnami

GitLab Error message - Permission denied (publickey) - Bitnami

最后,我设法在虚拟机上设置了 gitlab 服务器。静态 IP 是 192.168.xx.xx,我从浏览器正常输入到 gitlab 仪表板。到目前为止一切都很好。

我还在其他网络服务器上安装了 git 并创建了 git 文件,这样我就可以将文件直接推送到 192.168.xx.xx(这是 git实验室平台)。

我已经生成了 SSH 密钥 (id_ed25519) 并将它们存储在 /c/users/admin/.ssh/ 中。在这条路上我有

另外,我将 public 密钥复制到我的 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).

==================================

经过研究,我忘记将 public 键粘贴到 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 的访问权限以查看我的本地存储库。

先尝试一个没有密码的密钥,使用更简单的 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