抱歉,这个问题太基础了。我的 Windows 10 安装了 cygwin,并安装了 openssh,防火墙允许该应用程序运行。我正在尝试设置密钥对,但无法连接到主机。主机默认启用了 ssh。
尝试关闭防火墙,尝试使用两种不同的网络连接(移动热点和家庭网络)。
这可能是个线索?我第一次也是唯一一次连接是在昨天早些时候使用 Cygwin,它最初确实连接了,但在密码提示符下,即使我正确输入了密码,它也会拒绝访问并断开连接。从那时起,我只遇到过超时......除了另一次,我第一次尝试使用 PuTTy 而不是 Cygwin,也发生了同样的事情。
ping 没有问题:
$ ping ***.***.***.*
Pinging ***.***.***.* with 32 bytes of data:
Reply from ***.***.***.*: bytes=32 time=171ms TTL=58
Reply from ***.***.***.*: bytes=32 time=283ms TTL=58
Reply from ***.***.***.*: bytes=32 time=115ms TTL=58
Reply from ***.***.***.*: bytes=32 time=123ms TTL=58
Ping statistics for ***.***.***.*:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 115ms, Maximum = 283ms, Average = 173ms
我也尝试过通过 IP 连接,但结果相同,我的主机也确认不需要 user@,只需要 IP 或域。
当我尝试连接到我的主机时出现错误:
$ ssh -vvv www.domain.com.au
OpenSSH_7.5p1, OpenSSL 1.0.2k 26 Jan 2017
debug1: Reading configuration data /etc/ssh_config
debug2: resolving "www.domain.com.au" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to www.domain.com.au [***.***.***.*] port 22.
debug1: connect to address ***.***.***.* port 22: Connection timed out
ssh: connect to host www.domain.com.au port 22: Connection timed out
但是我可以毫无问题地连接到其他主机。
这是 nmap 端口信息:
`$ nmap www.domain.com.au
Starting Nmap 7.40 ( httpsnmap.org ) at 2017-07-02 10:45 tra
Nmap scan report for www.domain.com.au (***.***.***.*)
Host is up (0.11s latency).
rDNS record for ***.***.***.*: server-2-r57.ipv4.au.syrahost.com
Not shown: 976 filtered ports
PORT STATE SERVICE
20/tcp closed ftp-data
21/tcp open ftp
25/tcp open smtp
80/tcp open http
110/tcp open pop3
143/tcp open imap
443/tcp open https
465/tcp open smtps
587/tcp open submission
993/tcp open imaps
995/tcp open pop3s
3306/tcp open mysql
5000/tcp open upnp
10000/tcp closed snet-sensor-mgmt
10001/tcp closed scp-config
10002/tcp closed documentum
10003/tcp closed documentum_s
10004/tcp closed emcrmirccd
10009/tcp closed swdtp-sv
10010/tcp closed rxapi
10012/tcp closed unknown
10024/tcp closed unknown
10025/tcp closed unknown
10082/tcp closed amandaidx
Nmap done: 1 IP address (1 host up) scanned in 14.10 seconds.
有什么想法可以调试这个吗?我的 IP 没有被阻止,我可以通过端口 21 上的 FTP 连接到域,不用担心。
调试:SSH 到本地主机
$ ssh -v localhost
OpenSSH_7.5p1, OpenSSL 1.0.2k 26 Jan 2017
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to localhost [::1] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/jpols/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jpols/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jpols/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jpols/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jpols/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jpols/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jpols/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/jpols/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.5
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.5
debug1: match: OpenSSH_7.5 pat OpenSSH* compat 0x04000000
debug1: Authenticating to localhost:22 as 'jpols'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:wywfb93uyAAcCFJeZ/68LZvn2Ym26v+0k7Ii3OAfrMc
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is SHA256vn2Ym26v+0k7Ii3OAfrMc.
Are you sure you want to continue connecting (yes/no)?
调试:Telnet 到远程
$ telnet domain.com.au 22
Trying ***.***.***.*...
telnet: Unable to connect to remote host: Connection timed out
调试:
尝试将sshd_config
端口更改为2222
。没有成功,22
现在又重新使用。
调试:Nmap Traceroute
jpols@MrComputer ~
$ nMAP --traceroute -Pn -p 22 www.domain.com.au
Starting Nmap 7.40 ( https://nmap.org ) at 2017-07-03 14:56 tra
Nmap scan report for www.domain.com.au (***.***.***.*)
Host is up (0.047s latency).
rDNS record for ***.***.***.*: server-2-r57.ipv4.au.syrahost.com
PORT STATE SERVICE
22/tcp filtered ssh
TRACEROUTE (using proto 1/icmp)
HOP RTT ADDRESS
1 0.00 ms ***.***.*.*
2 32.00 ms ***.**.***.5
3 32.00 ms 097.pth0304.pth.iprimus.net.au (***.***.***.**)
4 32.00 ms ae1.csr01.mlganxd.wa.m2core.net.au (***.***.116.57)
5 32.00 ms ae5.csr01.prthpri.wa.m2core.net.au (***.***.116.49)
6 47.00 ms xe-0-2-0-21.pthpe01.pth.m2core.net.au (***.**.207.70)
7 32.00 ms ten-2-0-4.bdr01.per05.wa.vocus.net.au (***.**.207.208)
8 32.00 ms ten-0-0-0-1.cor02.per02.wa.vocus.net.au (***.**.206.38)
9 32.00 ms ge-0-0-3.bdr02.per02.wa.VOCUS.net.au (***.**.206.95)
10 ... 11
12 32.00 ms server-2-r57.ipv4.au.syrahost.com (***.***.***.*)
Nmap done: 1 IP address (1 host up) scanned in 6.38 seconds
上面的输出显示端口 22 已被过滤,我的路由器和 PC 防火墙暂时被禁用,有人知道如何调试过滤器的源吗?
不确定这是否是正确的检查方法,但是使用检查工具时,我的外部 IP 显示端口 22 已打开,但我的设备静态 IP 显示已关闭,使用工具检查内部(设备) IP 是否准确?我已束手无策,但不会放弃,路由器有一条规则,将端口 22 设置为对设备开放...我还能做什么?参见图片:
显示防火墙状态的图像
调试:请注意,自从我发布此问题以来,我已将路由器和互联网服务从 ADSL 更改为光纤,但仍然遇到同样的问题。
已添加入站/出站规则以允许防火墙中的端口 22,以防万一,没有变化。
调试:跟踪路由
|------------------------------------------------------------------------------------------|
| WinMTR statistics |
| Host - % | Sent | Recv | Best | Avrg | Wrst | Last |
|------------------------------------------------|------|------|------|------|------|------|
| ***.***.*.* - 0 | 66 | 66 | 1 | 3 | 25 | 3 |
| ***.**.***.5 - 0 | 66 | 66 | 12 | 15 | 37 | 16 |
| 097.pth0304.pth.iprimus.net.au - 0 | 65 | 65 | 12 | 15 | 31 | 17 |
| ae1.csr01.mlganxd.wa.m2core.net.au - 0 | 66 | 66 | 13 | 16 | 38 | 14 |
| ae5.csr01.prthpri.wa.m2core.net.au - 0 | 66 | 66 | 13 | 17 | 44 | 17 |
| xe-0-2-0-21.pthpe01.pth.m2core.net.au - 0 | 65 | 65 | 13 | 16 | 36 | 15 |
| ten-2-0-4.bdr01.per05.wa.vocus.net.au - 0 | 66 | 66 | 13 | 15 | 37 | 13 |
| ten-0-0-0-1.cor02.per02.wa.vocus.net.au - 0 | 66 | 66 | 13 | 16 | 46 | 14 |
| ge-0-0-3.bdr02.per02.wa.VOCUS.net.au - 0 | 65 | 65 | 13 | 15 | 31 | 15 |
| No response from host - 100 | 13 | 0 | 0 | 0 | 0 | 0 |
| No response from host - 100 | 13 | 0 | 0 | 0 | 0 | 0 |
| ******-***.ipv4.au.****host.com - 0 | 65 | 65 | 13 | 16 | 40 | 19 |
|________________________________________________|______|______|______|______|______|______|
WinMTR v0.92 GPL V2 by Appnor MSP - Fully Managed Hosting & Cloud Provider
答案1
我已经解决了这个问题,但很生气的是,尽管主机说没有,但主机一直在屏蔽我。需要二级支持才能修复(实际上是检查??)。
感谢大家的帮助,我将把它留在这里,因为它详细介绍了使用 Windows 和 Cygwin 进行 SSH 的不同调试方法,这可能会对将来的某些人有用。