与密钥的SSH连接是不可靠的

我是一个小公司的实习生系统pipe理员。 当我遇到问题时,没有真正的系统pipe理员可以问我。 谢谢您的帮助

该公司使用Nagios来监控他们的networking服务器。 他们使用connect_by_ssh来使用公钥和私钥。 问题是,有时它的工作,有时它不。 总有人可以使用名字和密码login。 它只是不总是工作的关键。

一些日志给你:

Jan 16 13:23:10 localhost nagios3: SERVICE ALERT: Server02;SSH;CRITICAL;SOFT;1;Connection timed out Jan 16 13:24:10 localhost nagios3: SERVICE ALERT: Server02;SSH;CRITICAL;SOFT;2;Connection timed out Jan 16 13:24:50 localhost nagios3: SERVICE ALERT: Server02;SSH;OK;SOFT;3;SSH OK - OpenSSH_5.3 (protocol 2.0) Jan 16 14:15:10 localhost nagios3: SERVICE ALERT: Server02;SSH;CRITICAL;SOFT;1;Connection timed out Jan 16 14:15:50 localhost nagios3: SERVICE ALERT: Server02;SSH;OK;SOFT;2;SSH OK - OpenSSH_5.3 (protocol 2.0) 

可以肯定的是,即使SSH用户/密码

 nmap server02.8p-hosting.com Starting Nmap 5.00 ( http://nmap.org ) at 2014-01-16 14:16 EST Interesting ports on abc.domain.com (xxx.xxx.xxx.xxx): Not shown: 971 closed ports PORT STATE SERVICE 22/tcp open ssh 

下面是一个普通的星期的样子:

本周ssh

会是什么呢?

日志/debugging

 ssh -vvv [email protected] OpenSSH_5.5p1 Debian-6+squeeze4, OpenSSL 0.9.8o 01 Jun 2010 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug2: ssh_connect: needpriv 0 debug1: Connecting to abc.domain.com [xxx.xxx.xxx.xxx] port 22. debug1: connect to address xxx.xxx.xxx.xxx port 22: Connection timed out ssh: connect to host abc.domain.com port 22: Connection timed out 

这看起来更像是超时问题,而不像SSH本身。

看看你的nagios检查。

你可能想要添加一个-t选项check_by_ssh:

  -t, --timeout=INTEGER Seconds before connection times out (default: 10) 

你应该也可以在你的nagios.cfg中检查service_check_timeout

矿被设置为60秒。

http://nagios.sourceforge.net/docs/nagioscore/3/en/configmain.html

不幸的是,它可能是任何数量的东西,我要做的第一件事是打开ssh服务器上的ssh日志logging到“DEBUG”。

此外,我假设你的意思是他们正在使用check_ssh监视框上的SSH服务器。 在nagios里面,有几件事你可以做,看看什么命令正在执行。 如果您有ssh访问nagios服务器的权限,那么您只需login并查看nagios services.cfg,就可以准确find正在调用哪个nagios插件,以及哪些开关。

然后看看commands.cfg看看执行什么。 然后,尝试使用该命令从命令行手动testingssh服务器。

另一种方法是使用nagios的界面。 在左侧的导航栏上,底部是一个configuration链接。 点击它,然后使用下拉菜单,转到服务,并确切地find该服务正在调用哪个插件。 接下来使用下拉goto命令扩展并获得该命令的方式。 然后手动检查。

最后,看看SELinux是否启用,如果是这样,selinux上下文可能需要在文件上进行更改。 如果你使用的是木偶或者厨师,那么有可能是因为文件被打乱而被打破了。 等等。

更新:

我会尝试添加-E和/或-S到check_by_ssh命令。 有时候奇怪的ssh输出可能会让连接混乱,如果它认为它应该等待。 另外,在-v中添加将会给你一个指示。

我之前看到过这个问题。

也许rDNS查找超时(如上面注释中所述)或者服务器实际上是使用循环DNS的多个服务器(一个域名的多个Alogging),并且只有一部分服务器脱机,不运行SSH,或者否则testing失败。