CYGWIN sshd“端口22:连接被拒绝”

谷歌search这个死亡,无法解决。 我无法从另一台机器连接到我的CYGWIN sshd。 Netstat显示连接已build立。 可以连接本地,没问题。

[oracle@aserver ~]$ ssh myid@mycomp ssh: connect to host mycomp port 22: Connection refused 

在mycomp上:

 $ netstat -a | grep ssh TCP MYCOMP:ssh MYCOMP.mydomain.com:0 LISTENING TCP MYCOMP:1161 aserver.mydomain.com:ssh ESTABLISHED 

从本地主机成功login:

 $ ssh myid@mycomp myid@mycomp's password: Last login: Tue Sep 14 14:27:30 2010 from mycomp.mydomain.com Fanfare!!! You are successfully logged in to this server!!! 

我在XP sp3上,今天更新了CYGWIN。 试图清理和重新configuration,没有帮助。

清理(​​信贷香草Maeder http://www.cygwin.com/ml/cygwin/2008-10/msg00370.html ):

 # Remove sshd service cygrunsrv --stop sshd cygrunsrv --remove sshd # Delete any sshd or related users (such as cyg_server) from /etc/passwd # (use your favorite editor) # Delete any sshd or relaged users (such as cyg_server) from the system net user sshd /delete 

configuration:

 $ ssh-host-config -y *** Query: Overwrite existing /etc/ssh_config file? (yes/no) yes *** Info: Creating default /etc/ssh_config file *** Query: Overwrite existing /etc/sshd_config file? (yes/no) yes *** Info: Creating default /etc/sshd_config file *** Info: Privilege separation is set to yes by default since OpenSSH 3.3. *** Info: However, this requires a non-privileged account called 'sshd'. *** Info: For more info on privilege separation read /usr/share/doc/openssh/README.privsep. *** Query: Should privilege separation be used? (yes/no) yes *** Info: Note that creating a new user requires that the current account have *** Info: Administrator privileges. Should this script attempt to create a *** Query: new local account 'sshd'? (yes/no) yes *** Info: Updating /etc/sshd_config file *** Query: Overwrite existing /etc/inetd.d/sshd-inetd file? (yes/no) yes *** Info: Creating default /etc/inetd.d/sshd-inetd file *** Info: Updated /etc/inetd.d/sshd-inetd *** Warning: The following functions require administrator privileges! *** Query: Do you want to install sshd as a service? *** Query: (Say "no" if it is already installed as a service) (yes/no) yes *** Query: Enter the value of CYGWIN for the daemon: [] *** Info: The sshd service has been installed under the LocalSystem *** Info: account (also known as SYSTEM). To start the service now, call *** Info: `net start sshd' or `cygrunsrv -S sshd'. Otherwise, it *** Info: will start automatically after the next reboot. *** Info: Host configuration finished. Have fun! myid@MYCOMP /cygdrive/c/Documents and Settings/myid $ cygrunsrv -S sshd myid@MYCOMP /cygdrive/c/Documents and Settings/myid $ cygrunsrv -Q sshd Service : sshd Display name : CYGWIN sshd Current State : Running Controls Accepted : Stop Command : /usr/sbin/sshd -D 

你能telnet到另一台电脑的22端口吗?

 telnet <mycomp> 22 

如果你的连接被拒绝(你可以通过本地连接),这绝对是一个防火墙问题。 除了Windows防火墙 – McAfee,ZoneAlarm等,还有其他的防火墙,听起来好像被阻止 – 因为你可以在内部访问它(指示它正在侦听正确的端口),但是你不能在外部访问它(指示外部端口已closures)。

令人惊讶的是, Mozilla在configuration防火墙(包括Windows防火墙) 方面看起来很棒 。 试一试。 只是因为你认为没有防火墙运行 – 并不意味着没有。

有没有机会运行Windows防火墙?

你是否在冗长或debugging模式下运行你的SSH客户端?

我一直在处理这个确切的问题几个星期。 它可能不适用于这种情况。 但是我想在这里分享我的经验,希望能帮到别人。

Cygwin SSHD运行在我的Windows 7 Home Premium Box上。

  • 我能够从本地主机ssh进入机器,或通过input我的IP地址。 这是尝试,并在腻子成功。
  • 我无法从LAN上的任何其他设备进入机器。
    • 我确认这不是防火墙,防病毒或安全问题。 我在端口22上使用apache portable进行了testing。我能够在端口22上访问它。我还确保sshd.exe具有在networking上进行通信的完整function。
    • 我closures了机器上的所有防火墙function。 这只是Windows Defender和Windows防火墙。 这并没有解决这个问题
  • 经过一番挖掘。 我能够发现这是用腻子本身。 出于某种原因,我可以从我的Linux服务器(在云端)使用openssh客户端,没有任何问题。 我认为这与腻子键有关。
  • 我跑了putty.exe -cleanup,仍然有问题。
  • 在我的一台linux服务器上,我得到这个ssh_exchange_identification:由远程主机closures连接
  • 在另一个我的Linux服务器上,它只是连接。

希望这可以帮助。

德文

– 好的 – 好的。 它开始变得陌生。 我有4个云服务器,每个绑定到不同的域。 一台服务器可以login到我的sshd而其他人不能。

我通过注释掉hosts.deny中的所有条目来解决这个问题。 我也调整了我的hosts.allow文件看起来像这样。

 ALL : localhost 127.0.0.1/32 [::1]/128 [::ffff:127.0.0.1]/128 : allow SSHD : ALL 

这为我修好了。

我面临同样的错误,发现我的sshd没有运行。 所以使用net start sshd启动你的sshd,它可能适用于你。