gerrit 抛出 gerrit@localhost: Permission denied (publickey) 错误
gerrit throwing an gerrit@localhost: Permission denied (publickey) error
我已经使用 docker-compose 设置了 Gerrit。
参考文档:https://github.com/GerritCodeReview/docker-gerrit
我正在尝试使用 SSH 协议登录 Gerrit 服务器。
http 工作正常。但是对于 jenkins
我也需要 ssh
ssh -vv -p 29418 本地主机
日志:
[gerrit@957ec687d4a3 ~]$ ssh -vv -p 29418 localhost
OpenSSH_8.0p1, OpenSSL 1.1.1c FIPS 28 May 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug2: checking match for 'final all' host localhost originally localhost
debug2: match not found
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: configuration requests final Match pass
debug1: re-parsing configuration
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug2: checking match for 'final all' host localhost originally localhost
debug2: match found
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug2: resolving "localhost" port 29418
debug2: ssh_connect_direct
debug1: Connecting to localhost [127.0.0.1] port 29418.
debug1: Connection established.
debug1: identity file /var/gerrit/.ssh/id_rsa type 0
debug1: identity file /var/gerrit/.ssh/id_rsa-cert type -1
debug1: identity file /var/gerrit/.ssh/id_dsa type -1
debug1: identity file /var/gerrit/.ssh/id_dsa-cert type -1
debug1: identity file /var/gerrit/.ssh/id_ecdsa type -1
debug1: identity file /var/gerrit/.ssh/id_ecdsa-cert type -1
debug1: identity file /var/gerrit/.ssh/id_ed25519 type -1
debug1: identity file /var/gerrit/.ssh/id_ed25519-cert type -1
debug1: identity file /var/gerrit/.ssh/id_xmss type -1
debug1: identity file /var/gerrit/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.0
debug1: Remote protocol version 2.0, remote software version GerritCodeReview_3.3.3 (APACHE-SSHD-2.4.0)
debug1: no match: GerritCodeReview_3.3.3 (APACHE-SSHD-2.4.0)
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to localhost:29418 as 'gerrit'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc,3des-cbc
debug2: ciphers stoc: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc,3des-cbc
debug2: MACs ctos: umac-128-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128@openssh.com,hmac-sha1,hmac-sha2-256,hmac-sha2-512
debug2: MACs stoc: umac-128-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128@openssh.com,hmac-sha1,hmac-sha2-256,hmac-sha2-512
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group18-sha512,diffie-hellman-group17-sha512,diffie-hellman-group16-sha512,diffie-hellman-group15-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc
debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: ecdh-sha2-nistp256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: aes256-ctr MAC: hmac-sha1-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes256-ctr MAC: hmac-sha1-etm@openssh.com compression: none
debug1: kex: ecdh-sha2-nistp256 need=32 dh_need=32
debug1: kex: ecdh-sha2-nistp256 need=32 dh_need=32
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:QJIkQCiy/Pi43QI2H6A9OBVOY4f+7tpIK+W+Nwi2C6g
debug1: Host '[localhost]:29418' is known and matches the ECDSA host key.
debug1: Found key in /var/gerrit/.ssh/known_hosts:1
debug2: set_newkeys: mode 1
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: /var/gerrit/.ssh/id_rsa RSA SHA256:dBSjzg5IkLz0ShVN2T2ig8S+VuEB2/Qf4/l4t6YPv+Y
debug1: Will attempt key: /var/gerrit/.ssh/id_dsa
debug1: Will attempt key: /var/gerrit/.ssh/id_ecdsa
debug1: Will attempt key: /var/gerrit/.ssh/id_ed25519
debug1: Will attempt key: /var/gerrit/.ssh/id_xmss
debug2: pubkey_prepare: done
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /var/gerrit/.ssh/id_rsa RSA SHA256:dBSjzg5IkLz0ShVN2T2ig8S+VuEB2/Qf4/l4t6YPv+Y
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug1: Trying private key: /var/gerrit/.ssh/id_dsa
debug1: Trying private key: /var/gerrit/.ssh/id_ecdsa
debug1: Trying private key: /var/gerrit/.ssh/id_ed25519
debug1: Trying private key: /var/gerrit/.ssh/id_xmss
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
gerrit@localhost: Permission denied (publickey).
我正在 Gerrit 容器中尝试这些场景
请有人帮助解决这个问题,
您可以在下图中看到添加 ssh 密钥按钮被禁用。我不能够
添加密钥。
你有几处做错了
- 您不应从 gerrit 容器中登录,因为它将使用 gerrit 用户和 ssh 密钥。 gerrit中没有这样的gerrit用户
- 您应该创建一个新用户,您使用的是 LDAP 吗?
- 接下来,使用该用户凭据登录到 gerrit,并在用户配置文件中添加来自该用户的 public ssh 密钥。取决于您的服务器 url:https://myserver.net/settings/#SSHKeys
- 现在您应该可以连接了
当您在上面显示“新 SSH 密钥”的框中输入 public ssh 密钥时,它会被启用
我已经使用 docker-compose 设置了 Gerrit。
参考文档:https://github.com/GerritCodeReview/docker-gerrit
我正在尝试使用 SSH 协议登录 Gerrit 服务器。 http 工作正常。但是对于 jenkins
我也需要 sshssh -vv -p 29418 本地主机
日志:
[gerrit@957ec687d4a3 ~]$ ssh -vv -p 29418 localhost
OpenSSH_8.0p1, OpenSSL 1.1.1c FIPS 28 May 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug2: checking match for 'final all' host localhost originally localhost
debug2: match not found
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: configuration requests final Match pass
debug1: re-parsing configuration
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug2: checking match for 'final all' host localhost originally localhost
debug2: match found
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug2: resolving "localhost" port 29418
debug2: ssh_connect_direct
debug1: Connecting to localhost [127.0.0.1] port 29418.
debug1: Connection established.
debug1: identity file /var/gerrit/.ssh/id_rsa type 0
debug1: identity file /var/gerrit/.ssh/id_rsa-cert type -1
debug1: identity file /var/gerrit/.ssh/id_dsa type -1
debug1: identity file /var/gerrit/.ssh/id_dsa-cert type -1
debug1: identity file /var/gerrit/.ssh/id_ecdsa type -1
debug1: identity file /var/gerrit/.ssh/id_ecdsa-cert type -1
debug1: identity file /var/gerrit/.ssh/id_ed25519 type -1
debug1: identity file /var/gerrit/.ssh/id_ed25519-cert type -1
debug1: identity file /var/gerrit/.ssh/id_xmss type -1
debug1: identity file /var/gerrit/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.0
debug1: Remote protocol version 2.0, remote software version GerritCodeReview_3.3.3 (APACHE-SSHD-2.4.0)
debug1: no match: GerritCodeReview_3.3.3 (APACHE-SSHD-2.4.0)
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to localhost:29418 as 'gerrit'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1,ext-info-c
debug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc,3des-cbc
debug2: ciphers stoc: aes256-gcm@openssh.com,chacha20-poly1305@openssh.com,aes256-ctr,aes256-cbc,aes128-gcm@openssh.com,aes128-ctr,aes128-cbc,3des-cbc
debug2: MACs ctos: umac-128-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128@openssh.com,hmac-sha1,hmac-sha2-256,hmac-sha2-512
debug2: MACs stoc: umac-128-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128@openssh.com,hmac-sha1,hmac-sha2-256,hmac-sha2-512
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group18-sha512,diffie-hellman-group17-sha512,diffie-hellman-group16-sha512,diffie-hellman-group15-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc
debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: ecdh-sha2-nistp256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: aes256-ctr MAC: hmac-sha1-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes256-ctr MAC: hmac-sha1-etm@openssh.com compression: none
debug1: kex: ecdh-sha2-nistp256 need=32 dh_need=32
debug1: kex: ecdh-sha2-nistp256 need=32 dh_need=32
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:QJIkQCiy/Pi43QI2H6A9OBVOY4f+7tpIK+W+Nwi2C6g
debug1: Host '[localhost]:29418' is known and matches the ECDSA host key.
debug1: Found key in /var/gerrit/.ssh/known_hosts:1
debug2: set_newkeys: mode 1
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug2: set_newkeys: mode 0
debug1: rekey in after 4294967296 blocks
debug1: Will attempt key: /var/gerrit/.ssh/id_rsa RSA SHA256:dBSjzg5IkLz0ShVN2T2ig8S+VuEB2/Qf4/l4t6YPv+Y
debug1: Will attempt key: /var/gerrit/.ssh/id_dsa
debug1: Will attempt key: /var/gerrit/.ssh/id_ecdsa
debug1: Will attempt key: /var/gerrit/.ssh/id_ed25519
debug1: Will attempt key: /var/gerrit/.ssh/id_xmss
debug2: pubkey_prepare: done
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /var/gerrit/.ssh/id_rsa RSA SHA256:dBSjzg5IkLz0ShVN2T2ig8S+VuEB2/Qf4/l4t6YPv+Y
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug1: Trying private key: /var/gerrit/.ssh/id_dsa
debug1: Trying private key: /var/gerrit/.ssh/id_ecdsa
debug1: Trying private key: /var/gerrit/.ssh/id_ed25519
debug1: Trying private key: /var/gerrit/.ssh/id_xmss
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
gerrit@localhost: Permission denied (publickey).
我正在 Gerrit 容器中尝试这些场景
请有人帮助解决这个问题,
您可以在下图中看到添加 ssh 密钥按钮被禁用。我不能够 添加密钥。
你有几处做错了
- 您不应从 gerrit 容器中登录,因为它将使用 gerrit 用户和 ssh 密钥。 gerrit中没有这样的gerrit用户
- 您应该创建一个新用户,您使用的是 LDAP 吗?
- 接下来,使用该用户凭据登录到 gerrit,并在用户配置文件中添加来自该用户的 public ssh 密钥。取决于您的服务器 url:https://myserver.net/settings/#SSHKeys
- 现在您应该可以连接了
当您在上面显示“新 SSH 密钥”的框中输入 public ssh 密钥时,它会被启用