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

时间:2021-02-04 11:33:51

标签: git ssh ssh-keys bitnami ssh-agent

最后我设法在虚拟机上设置了 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 在网络服务器和 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 没问题。现在我的问题是我想用 gitlab 连接 .git 但是当我输入这个命令时:

git clone git@192.168.22.29:user1/devnow.git

它显示密码提示。我有我为此使用的所有密码的字段,但没有任何好的结果。 另外我想说我将 bitnami 与 debian + gitlab 一起使用。我想通过 ssh 登录到 user1,以便访问 gitlab 以查看我的本地存储库。

1 个答案:

答案 0 :(得分: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