免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1238 | 回复: 7
打印 上一主题 下一主题

[服务应用] SSH失败,求救 [复制链接]

论坛徽章:
3
数据库技术版块每日发帖之星
日期:2016-05-26 06:20:00数据库技术版块每日发帖之星
日期:2016-07-07 06:20:00数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2016-04-27 15:02 |只看该作者 |倒序浏览
手动执行ssh 命令的时候可以正常连接目标机器
但是程序调用脚本执行ssh命令的时候,却报错,以下为详细报错:
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.206.44 [192.168.206.44] port 22.
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug1: identity file /home/mysql/.ssh/identity type -1
debug1: identity file /home/mysql/.ssh/identity-cert type -1
debug1: identity file /home/mysql/.ssh/id_rsa type 1
debug1: identity file /home/mysql/.ssh/id_rsa-cert type -1
debug1: identity file /home/mysql/.ssh/id_dsa type -1
debug1: identity file /home/mysql/.ssh/id_dsa-cert type -1
debug1: identity file /home/mysql/.ssh/id_ecdsa type -1
debug1: identity file /home/mysql/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.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.206.44' is known and matches the RSA host key.
debug1: Found key in /home/mysql/.ssh/known_hosts:4
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,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/mysql/.ssh/identity
debug1: Offering public key: /home/mysql/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/mysql/.ssh/id_dsa
debug1: Trying private key: /home/mysql/.ssh/id_ecdsa
debug1: No more authentication methods to try.
Permission denied (publickey,password).


试了很多网上找的方法,但是没有一个管用的,求大神帮忙,谢谢~

论坛徽章:
0
2 [报告]
发表于 2016-04-27 18:01 |只看该作者
回复 1# lvchenotl
应该是权限问题,将主机私钥cp到被访问的主机中,实现ssh无密码访问试试!

   

论坛徽章:
2
IT运维版块每日发帖之星
日期:2016-04-15 06:20:0015-16赛季CBA联赛之福建
日期:2016-08-08 13:37:03
3 [报告]
发表于 2016-04-27 18:09 |只看该作者
手动ssh时,是用的mysql用户无密码登录吗?
比较一下手动和脚本执行ssh命令有什么区别。

论坛徽章:
3
数据库技术版块每日发帖之星
日期:2016-05-26 06:20:00数据库技术版块每日发帖之星
日期:2016-07-07 06:20:00数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00
4 [报告]
发表于 2016-04-27 19:04 |只看该作者
lsx1970152733 发表于 2016-04-27 18:01
回复 1# lvchenotl
应该是权限问题,将主机私钥cp到被访问的主机中,实现ssh无密码访问试试!


权限我都仔细核对过了,应该没有问题,ssh无密码访问已经做好,而且手动ssh一切正常

论坛徽章:
3
数据库技术版块每日发帖之星
日期:2016-05-26 06:20:00数据库技术版块每日发帖之星
日期:2016-07-07 06:20:00数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00
5 [报告]
发表于 2016-04-27 19:06 |只看该作者
shenyue_sam 发表于 2016-04-27 18:09
手动ssh时,是用的mysql用户无密码登录吗?
比较一下手动和脚本执行ssh命令有什么区别。


是的,是用mysql用户无密码登录的
手动ssh的时候没有问题,这是手动ssh的详细过程:
[mysql@nj-192-168-206-44 ~]$ ssh -v 192.168.208.47
OpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to 192.168.208.47 [192.168.208.47] port 22.
debug1: Connection established.
debug1: identity file /home/mysql/.ssh/identity type -1
debug1: identity file /home/mysql/.ssh/identity-cert type -1
debug1: identity file /home/mysql/.ssh/id_rsa type 1
debug1: identity file /home/mysql/.ssh/id_rsa-cert type -1
debug1: identity file /home/mysql/.ssh/id_dsa type -1
debug1: identity file /home/mysql/.ssh/id_dsa-cert type -1
debug1: identity file /home/mysql/.ssh/id_ecdsa type -1
debug1: identity file /home/mysql/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.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.208.47' is known and matches the RSA host key.
debug1: Found key in /home/mysql/.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,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/mysql/.ssh/identity
debug1: Offering public key: /home/mysql/.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: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
Last login: Wed Apr 27 18:56:05 2016 from 192.168.140.11
[mysql@nj-192-168-208-47 ~]$


MHA调用时候显示的报错如1楼所示。

论坛徽章:
2
IT运维版块每日发帖之星
日期:2016-04-15 06:20:0015-16赛季CBA联赛之福建
日期:2016-08-08 13:37:03
6 [报告]
发表于 2016-04-28 09:01 |只看该作者
看log,登录的不是同一台主机啊。

debug1: Host '192.168.206.44' is known and matches the RSA host key.

debug1: Host '192.168.208.47' is known and matches the RSA host key.

求职 : Linux运维
论坛徽章:
203
拜羊年徽章
日期:2015-03-03 16:15:432015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:57:092015小元宵徽章
日期:2015-03-06 15:58:182015年亚洲杯之约旦
日期:2015-04-05 20:08:292015年亚洲杯之澳大利亚
日期:2015-04-09 09:25:552015年亚洲杯之约旦
日期:2015-04-10 17:34:102015年亚洲杯之巴勒斯坦
日期:2015-04-10 17:35:342015年亚洲杯之日本
日期:2015-04-16 16:28:552015年亚洲杯纪念徽章
日期:2015-04-27 23:29:17操作系统版块每日发帖之星
日期:2015-06-06 22:20:00操作系统版块每日发帖之星
日期:2015-06-09 22:20:00
7 [报告]
发表于 2016-04-28 10:43 |只看该作者
.47
.44
都不是同一个主机。。哈哈

论坛徽章:
3
数据库技术版块每日发帖之星
日期:2016-05-26 06:20:00数据库技术版块每日发帖之星
日期:2016-07-07 06:20:00数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00
8 [报告]
发表于 2016-04-28 11:53 |只看该作者
回复 6# shenyue_sam


确实是,程序执行过程先是ssh到需要执行命令的主机上,然后再执行ssh的命令
看来是我配置文件里把执行程序的机器也加进去了导致的。。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP