MHA配置时碰到了Permission denied (publickey,gssapi-with-mic,password)这个错误提示,同时在使用ssh -v时,出现了Unspecified GSS failure错误。这个主要是使用了GSSAPI 的认证功能导致的。1、故障现象
# masterha_check_ssh --conf=/etc/app1.cnf
Wed Apr 8 14:33:26 2015 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
...............
Permission denied (publickey,gssapi-with-mic,password).
Wed Apr 8 14:33:26 2015 - [error][/usr/lib/perl5/site_perl/5.8.8/MHA/SSHCheck.pm, ln86] SSH connection from
root@vdbsrv1(192.168.1.6:22) to root@vdbsrv2(192.168.1.7:22) failed!
### ssh到另一主机时,花费20s左右
# time ssh 192.168.1.7 date
Wed Apr 15 21:33:53 CST 2015
real 0m20.245s
user 0m0.013s
sys 0m0.007s
### 使用-v参数ssh连接
# ssh -v 192.168.1.7
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.1.7 [192.168.1.7] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/identity type -1
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: loaded 3 keys
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '192.168.1.7' is known and matches the RSA host key.
debug1: Found key in /root/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure. Minor code may provide more information
No credentials cache found
debug1: Unspecified GSS failure. Minor code may provide more information
No credentials cache found
debug1: Unspecified GSS failure. Minor code may provide more information
No credentials cache found
debug1: Next authentication method: publickey
debug1: Trying private key: /root/.ssh/identity
debug1: Offering public key: /root/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Wed Apr 15 16:56:12 2015 from 192.168.1.124
2、故障解决
###查看目标端的GSSAPI options
[root@vdbsrv2 ~]# grep GSSAPI /etc/ssh/sshd_config
# GSSAPI options
#GSSAPIAuthentication no
GSSAPIAuthentication yes ###此时为开启GSSAPI认证
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes
### Author : Leshami
### Blog :http://blog.csdn.net/leshami
[root@vdbsrv2 ~]# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bk
[root@vdbsrv2 ~]# vi /etc/ssh/sshd_config ###关闭该认证方式
[root@vdbsrv2 ~]# grep GSSAPI /etc/ssh/sshd_config ###查看关闭后的结果
# GSSAPI options
GSSAPIAuthentication no
#GSSAPIAuthentication yes
#GSSAPICleanupCredentials yes
GSSAPICleanupCredentials yes
###重启sshd服务
[root@vdbsrv2 ~]# service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
###再次测试,仅仅0.191s,ssh -v时也无异常报错
[root@vdbsrv1 ~]# time ssh 192.168.1.7 date
Wed Apr 15 21:48:10 CST 2015
real 0m0.191s
user 0m0.014s
sys 0m0.003s
--转自