MHA配置测试ssh连接报错Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

问题:

在 manager 节点上测试 ssh 无密码认证出现报错

[root@mysql2 .ssh]# masterha_check_ssh -conf=/etc/masterha/app1.cnf
Wed Sep 22 19:33:33 2021 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Sep 22 19:33:33 2021 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Wed Sep 22 19:33:33 2021 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Wed Sep 22 19:33:33 2021 - [info] Starting SSH connection tests..
Wed Sep 22 19:33:34 2021 - [error][/usr/local/share/perl5/MHA/SSHCheck.pm, ln63] 
Wed Sep 22 19:33:34 2021 - [debug]  Connecting via SSH from root@192.168.229.80(192.168.229.80:22) to root@192.168.229.90(192.168.229.90:22)..
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
Wed Sep 22 19:33:34 2021 - [error][/usr/local/share/perl5/MHA/SSHCheck.pm, ln111] SSH connection from root@192.168.229.80(192.168.229.80:22) to root@192.168.229.90(192.168.229.90:22) failed!
Wed Sep 22 19:33:34 2021 - [debug] 
Wed Sep 22 19:33:33 2021 - [debug]  Connecting via SSH from root@192.168.229.90(192.168.229.90:22) to root@192.168.229.80(192.168.229.80:22)..
Wed Sep 22 19:33:34 2021 - [debug]   ok.
Wed Sep 22 19:33:34 2021 - [debug]  Connecting via SSH from root@192.168.229.90(192.168.229.90:22) to root@192.168.229.70(192.168.229.70:22)..
Wed Sep 22 19:33:34 2021 - [debug]   ok.
Wed Sep 22 19:33:36 2021 - [debug] 
Wed Sep 22 19:33:34 2021 - [debug]  Connecting via SSH from root@192.168.229.70(192.168.229.70:22) to root@192.168.229.90(192.168.229.90:22)..
Wed Sep 22 19:33:35 2021 - [debug]   ok.
Wed Sep 22 19:33:35 2021 - [debug]  Connecting via SSH from root@192.168.229.70(192.168.229.70:22) to root@192.168.229.80(192.168.229.80:22)..
Wed Sep 22 19:33:35 2021 - [debug]   ok.
Bizarre copy of ARRAY in scalar assignment at /usr/share/perl5/vendor_perl/Carp.pm line 182.

查找问题并解决

查看配置文件:

[root@mysql2 .ssh]# vim /etc/masterha/app1.cnf

[server default]
manager_log=/var/log/masterha/app1/manager.log
manager_workdir=/var/log/masterha/app1
master_binlog_dir=/usr/local/mysql/data
master_ip_failover_script=/usr/local/bin/master_ip_failover
master_ip_online_change_script=/usr/local/bin/master_ip_online_change
password=manager
ping_interval=1
remote_workdir=/tmp
repl_password=12345
repl_user=myslave
secondary_check_script=/usr/local/bin/masterha_secondary_check -s 192.168.229.80 -s 192.168.229.70
shutdown_script=""
ssh_user=root
user=mha

[server1]
hostname=192.168.229.90
port=3306

[server2]
candidate_master=1
check_repl_delay=0
hostname=192.168.229.80
port=3306

[server3]
hostname=192.168.229.70
port=3306  

配置文件应该没什么问题

再查找ssh连接的问题

[root@mysql2 .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts

重新连接ssh,将./ssh目录下的文件全部删除,重新设置无密连接

[root@mysql1 ~]# cd ./.ssh/
[root@mysql1 .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[root@mysql1 .ssh]# rm -rf *
[root@mysql1 .ssh]# ls
[root@mysql1 .ssh]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:YH0mtNnSodwDmK3IQIwuM8gBKaDd9fKC4RWezuREx3A root@mysql1
The key's randomart image is:
+---[RSA 2048]----+
|==.   =*E .      |
|=oo. +oXoO .     |
|* ooo.X.X B      |
|=o .o@.+ = .     |
|.o  o = S        |
|       .         |
|                 |
|                 |
|                 |
+----[SHA256]-----+
[root@mysql1 .ssh]# ssh-copy-id 192.168.229.80
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.229.80 (192.168.229.80)' can't be established.
ECDSA key fingerprint is SHA256:kfiiDqRfaaR8s8E8VRXk+ZrgUEqUZaa1lW40fN0MgVw.
ECDSA key fingerprint is MD5:87:6a:4a:bf:58:17:5b:f1:10:4f:a8:af:96:06:62:3b.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.229.80's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh '192.168.229.80'"
and check to make sure that only the key(s) you wanted were added.

再次进行无密认证检测 

[root@mysql2 .ssh]# masterha_check_ssh -conf=/etc/masterha/app1.cnf
Wed Sep 22 20:03:21 2021 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Wed Sep 22 20:03:21 2021 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Wed Sep 22 20:03:21 2021 - [info] Reading server configuration from /etc/masterha/app1.cnf..
Wed Sep 22 20:03:21 2021 - [info] Starting SSH connection tests..
Wed Sep 22 20:03:22 2021 - [debug] 
Wed Sep 22 20:03:21 2021 - [debug]  Connecting via SSH from root@192.168.229.90(192.168.229.90:22) to root@192.168.229.80(192.168.229.80:22)..
Wed Sep 22 20:03:21 2021 - [debug]   ok.
Wed Sep 22 20:03:21 2021 - [debug]  Connecting via SSH from root@192.168.229.90(192.168.229.90:22) to root@192.168.229.70(192.168.229.70:22)..
Wed Sep 22 20:03:21 2021 - [debug]   ok.
Wed Sep 22 20:03:22 2021 - [debug] 
Wed Sep 22 20:03:21 2021 - [debug]  Connecting via SSH from root@192.168.229.80(192.168.229.80:22) to root@192.168.229.90(192.168.229.90:22)..
Warning: Permanently added '192.168.229.80' (ECDSA) to the list of known hosts.
Wed Sep 22 20:03:21 2021 - [debug]   ok.
Wed Sep 22 20:03:21 2021 - [debug]  Connecting via SSH from root@192.168.229.80(192.168.229.80:22) to root@192.168.229.70(192.168.229.70:22)..
Wed Sep 22 20:03:22 2021 - [debug]   ok.
Wed Sep 22 20:03:23 2021 - [debug] 
Wed Sep 22 20:03:22 2021 - [debug]  Connecting via SSH from root@192.168.229.70(192.168.229.70:22) to root@192.168.229.90(192.168.229.90:22)..
Wed Sep 22 20:03:22 2021 - [debug]   ok.
Wed Sep 22 20:03:22 2021 - [debug]  Connecting via SSH from root@192.168.229.70(192.168.229.70:22) to root@192.168.229.80(192.168.229.80:22)..
Wed Sep 22 20:03:22 2021 - [debug]   ok.
Wed Sep 22 20:03:23 2021 - [info] All SSH connection tests passed successfully.

检测成功,故障排除  

 

posted on 2021-09-22 22:06  笑洋仟  阅读(805)  评论(0编辑  收藏  举报

levels of contents