Cygwin SSHD 仅在本地调用时重置连接

Cygwin SSHD 仅在本地调用时重置连接

我有一个安装了 Cygwin 的 WinXP 机器(称为 PETER)。这是它的版本:

C:\bin> uname -a
CYGWIN_NT-5.1 peter 1.7.24(0.269/5/3) 2013-08-15 11:55 i686 Cygwin

我已经在上面安装了 SSHD 多年,一切都运行良好。最近,我将路由器从 Speedport 722V 更改为 Speedport 921V(我需要 IPv6)。我已经正确设置了端口转发规则,它们似乎有效。

现在我有了这个奇怪的效果:

  • 来自互联网的用户可以连接;
  • 我可以通过 SSH 连接到我的 Uni,然后从那里连接到 PETER;
  • 我可以连接到 PETER 的本地 IP 地址 192.168.2.107;
  • 但我无法连接到它通过使用公共 IP 地址(由 dyndns.com 提供)或 DNS 名称。

我已检查 IP 地址是否正确。它不适用于 DNS 名称和数字 IPv4 地址。端口转发有效:互联网用户可以连接,并且如日志文件所示,我可以连接,但我的连接重置,即主动终止。

这是我尝试时的 SSH 输出:

C:\> ssh -vvvv 79.223.25.218
OpenSSH_6.2p2, OpenSSL 1.0.1e 11 Feb 2013
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 61: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 79.223.25.218 [79.223.25.218] port 22.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/cygdrive/c/text/id_rsa" as a RSA1 public key
debug1: identity file /cygdrive/c/text/id_rsa type 1
debug1: identity file /cygdrive/c/text/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
ssh_exchange_identification: read: Connection reset by peer

我只得到这个 eventvwr 输出:... sshd: PID 720: Comparing 79.223.25.218 to 79.223.25.218 (p4FDF19DA.dip0.t-ipconnect.de:p4FDF19DA.dip0.t-ipconnect.de).

这是我的 sshd_config:

Port 22
AddressFamily inet
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
#Protocol 2

# HostKey for protocol version 1
#HostKey /etc/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh_host_rsa_key
#HostKey /etc/ssh_host_dsa_key
#HostKey /etc/ssh_host_ecdsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin yes
StrictModes no
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication no
PermitEmptyPasswords no

# Change to no to disable s/key passwords
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to 'yes' to enable PAM authentication, account processing, 
# and session processing. If this is enabled, PAM authentication will 
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
#UsePAM no

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
UsePrivilegeSeparation yes
#PermitUserEnvironment no
Compression yes

# after 3*2min of no answer from the client, terminate the connection
# so after a hibernation etc. the connection will most likely be dead.
ClientAliveInterval 2m
ClientAliveCountMax 3

#UseDNS yes
#PidFile /var/run/sshd.pid
#MaxStartups 10
#PermitTunnel no
#ChrootDirectory none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem   sftp    /usr/sbin/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#   X11Forwarding no
#   AllowTcpForwarding no
#   ForceCommand cvs server

更令人费解的是,前几天我通过修改文件“修复”了这个问题/etc/hosts.allow,但这个“修复”不再起作用了。过去几年里反正也用不上,所以我更加困惑了。前几天我以为路由器可能会将 IP 号码反向解析为名称,旧路​​由器的做法可能与新路由器不同??

有人知道吗?我一无所知,但我真的不了解所有的工作原理(例如/etc/hosts.allow.deny文件对我来说是新的)。

更多信息:hosts.allow即使是空文件,它也无法工作.deny。SSHD DEBUG3 日志记录未显示任何断开连接的原因。现在,我认为这是路由器的硬件问题……

答案1

TCP 连接重置的原因是我的新路由器的“改进”。我试图做的是所谓的“NAT 环回”,参见 WP,而我的路由器制造商似乎也持有这样的观点(在我看来是错误的),即 NAT 环回是一个安全问题。我不知道怎么会这样,但事实就是如此:我的路由器主动禁止此类连接。

我的解决方案是黑客攻击,在使用 SSH 之前运行一个脚本。该脚本检查我是否在办公室,如果是,则用本地地址替换我服务器的 DNS 地址。很蠢,但我没有其他办法。

相关内容