我从Cygwin运行Openssh sshd服务。 当RSA连接build立时:
$ ssh Administrator@ZETA
上次login:5月11日星期三13:58:50从10.1.1.140开始
– 没有错误信息。
但是,当我使用内联命令时:
$ ssh Administrator@ZETA "echo hi"
嗨
– 该命令起作用,但在ZETA上Windows事件日志现在说:
sshd:PID 7068:错误:get_socket_address:getnameinfo 2失败:未知错误
调用此函数通常会填充事件日志中的错误。
在debugging模式下在命令行上启动sshd:
/usr/sbin/sshd -ddd
– 不会产生错误。 它也运行在不同的用户,我不得不chown administrator /var/empty它的工作。
尝试以debugging模式作为Windows服务启动sshd,如https://cygwin.com/ml/cygwin/2014-03/msg00488.html中的build议失败:
$ /usr/bin/cygrunsrv -I sshd -d "CYGWIN sshd_debug" -p /usr/sbin/sshd -a "-D -d -d -d" -y tcpip
/ usr / bin / cygrunsrv:安装服务时出错:OpenService:Win32 error 1073:指定的服务已经存在。
要在安装sshd_debug服务时解决您的cygrunsrv错误,还必须更改<service_name> ,而不仅仅是<service display name> :
cygrunsrv -I <service_name> -d "<service display name>" -p <service_path>
哪里
<service_name>是Windows内部服务名称 <service display name>是显示在services.msc列表中的名称 或者您必须先停止并删除已经定义的服务sshd ,然后再尝试使用debugging参数进行定义。
注意:下面的命令必须input到具有pipe理权限的shell中。 当sshd使用-d , -dd或-ddd以debugging模式运行时,服务器不会分叉,只会处理一个连接,然后停止。
sshd_debug服务: 要安装名为sshd_debug的第二个服务:
/usr/bin/cygrunsrv -I sshd_debug -d "CYGWIN sshd_debug" -p /usr/sbin/sshd -a "-D -d -d -d" -y tcpip
请注意,一个特定的<service_name>或<service display name>不能被定义多次,否则cygrunsrv会抛出一个错误。
在开始新的sshd_debug服务之前,必须停止正常的sshd服务:
/usr/bin/cygrunsrv -E sshd
现在启动sshd_debug服务:
/usr/bin/cygrunsrv -S sshd_debug
sshd service_name重新定义: 另一个例子,将使你的问题cygrunsrv命令工作(使用服务名称: sshd ):
# Stop the service /usr/bin/cygrunsrv -E sshd # Remove the service /usr/bin/cygrunsrv -R sshd # Install using the same service_name with debug options /usr/bin/cygrunsrv -I sshd -d "CYGWIN sshd_debug" -p /usr/sbin/sshd -a "-D -d -d -d" -y tcpip # Start the service /usr/bin/cygrunsrv -S sshd
/usr/bin/cygrunsrv -I sshd_debug -d "CYGWIN sshd_debug" -p /usr/sbin/sshd -a "-D -d -d -d" -y tcpip -u "<account_name>" -w "<password>"
get_socket_address: getnameinfo 2 failed 抛出错误信息的函数get_socket_address在canohost.c定义:
static char * get_socket_address(int sock, int remote, int flags) { ... switch (addr.ss_family) { case AF_INET: case AF_INET6: /* Get the address in ascii. */ if ((r = getnameinfo((struct sockaddr *)&addr, addrlen, ntop, sizeof(ntop), NULL, 0, flags)) != 0) { error("get_socket_address: getnameinfo %d failed: %s", flags, ssh_gai_strerror(r)); return NULL; } return xstrdup(ntop); ... } }
它调用一个带有标志NI_NUMERICHOST的函数getnameinfo ,它应该返回一个string,其中包含(远程)peer_ipaddr或local_ipaddr的可读IP地址。 但是,该function失败,出现未知的EAI_SYSTEM错误( A system error occurred )。
所以这并没有太多的帮助,但是这可能表明这个错误与DNS名字parsing有关。
要排除故障,您可以检查名称parsing是否正常工作:
# netstat: check where sshd listens and if you have any errors netstat -ano | grep ":22" netstat -ao | grep ":22" # reverse dns lookup nslookup <remote_ip_address> nslookup <local_ip_address> # forward dns lookup (using the hostnames returned by the above commands) nslookup <remote_hostname> nslookup <local_hostname> # or for example using dig # reverse dns lookup dig -x <remote_ip_address> dig -x <local_ip_address> # forward dns lookup (using the hostnames returned by the above commands) dig <remote_hostname> +search dig <local_hostname> +search
reverse dns lookup应该返回fqdn forward dns lookup应该返回IP地址