Git权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic)?

Posted

技术标签:

【中文标题】Git权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic)?【英文标题】:Git Permission denied (publickey,gssapi-keyex,gssapi-with-mic)? 【发布时间】:2017-12-21 04:57:43 【问题描述】:

客户端:操作系统 Ubuntu,git 版本 2.7.4。

服务器:OS Centos,git-version 2.7.4。

我的客户端有一个私有 ssh 密钥,而服务器中有一个公钥。

我可以使用shell进入我的服务器(无密码)。

但是无法推送origin master!

sudo ssh -i /path/to/key/ -vT git@xxx.xx.xxx.xxx OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g 1 Mar 2016 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to xxx.xx.xxx.xxx [xxx.xx.xxx.xxx] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /home/whj/.ssh/whjwebsite type 1 debug1: key_load_public: No such file or directory debug1: identity file /home/whj/.ssh/whjwebsite-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1 debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000 debug1: Authenticating to xxx.xx.xxx.xxx:22 as 'git' 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:aC1Ydp+6x8IP+TV5jEl7WwqW6sEycbznbfL09qON/OA debug1: Host 'xxx.xx.xxx.xxx' is known and matches the ECDSA host key. debug1: Found key in /root/.ssh/known_hosts:1 debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: rekey after 134217728 blocks debug1: SSH2_MSG_NEWKEYS received debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-debug1: Next authentication method: gssapi-keyex debug1: No valid Key exchange context debug1: Next authentication method: gssapi-with-mic debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available debug1: Unspecified GSS failure. Minor code may provide more information debug1: Unspecified GSS failure. Minor code may provide more information No Kerberos credentials available debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/whj/.ssh/whjwebsite debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-debug1: No more authentication methods to try. Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

'whjwebsite'是我的私钥。

drwx------.ssh/

-rw-----whj网站

服务器:sshd_config:

``` RSA认证是 公钥认证是 GSSAPIAuthentication 是 GSSAPICleanupCredentials 否 使用 DNS 否 地址家庭网络 PermitRootLogin 是 SyslogFacility AUTHPRIV 密码验证无 ChallengeResponseAuthentication no

客户端:ssh_config

enter image description here

【问题讨论】:

密钥被服务器拒绝 更糟糕的是:甚至没有使用公钥,因为连接“意外”失败 - Authentications that can continue: ...Next authentication method: gssapi-keyex ... Next authentication method: gssapi-with-mic Gaaah!这是一个致命的陷阱,因为 Kerberos 身份验证失败通常会导致连接崩溃,而不允许使用其他方法(例如 publickey 【参考方案1】:

我的 2 美分:在服务器端,禁用 GSSAPIAuthentication(即由 Kerberos 支持的 SSO),除非您在公司防火墙内的 Linux 上使用 Active Directory 身份验证(使用 Centrify 或 SSSD)。

如果您确实处于 SSO 场景中,但单点登录由于某种原因无法开箱即用,请使用客户端选项绕过 Kerberos,例如

ssh -o GSSAPIAuthentication=no -o GSSAPIKeyExchange=no

【讨论】:

以上是关于Git权限被拒绝(公钥,gssapi-keyex,gssapi-with-mic)?的主要内容,如果未能解决你的问题,请参考以下文章

EC2 ssh 权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic)

SSH 到 GitLab 权限被拒绝(公钥、gssapi-keyex、gssapi-with-mic)

GPDB:SSH 权限被拒绝(公钥)

git push:权限被拒绝(公钥)

git@github.com:权限被拒绝(公钥)[主目录回购] [重复]

Ansible git clone github 权限被拒绝(公钥)