我有一台运行 Pop! OS (20.04 LTS) 的笔记本电脑,我刚刚安装了 openssh-server sudo apt-get install openssh-server
,并尝试从我的 Windows 10 台式电脑通过 SSH 进入它,但出现以下错误:
PS C:\Users\enricojr\.ssh> ssh -vvv 192.168.254.203
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Reading configuration data C:\\Users\\enricojr/.ssh/config
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolve_canonicalize: hostname 192.168.254.203 is address
debug2: ssh_connect_direct
debug1: Connecting to 192.168.254.203 [192.168.254.203] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\enricojr/.ssh/id_rsa type 0
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_rsa-cert error:2
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_rsa-cert.pub error:2
debug1: identity file C:\\Users\\enricojr/.ssh/id_rsa-cert type -1
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_dsa error:2
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_dsa.pub error:2
debug1: identity file C:\\Users\\enricojr/.ssh/id_dsa type -1
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_dsa-cert error:2
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_dsa-cert.pub error:2
debug1: identity file C:\\Users\\enricojr/.ssh/id_dsa-cert type -1
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_ecdsa error:2
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_ecdsa.pub error:2
debug1: identity file C:\\Users\\enricojr/.ssh/id_ecdsa type -1
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_ecdsa-cert error:2
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_ecdsa-cert.pub error:2
debug1: identity file C:\\Users\\enricojr/.ssh/id_ecdsa-cert type -1
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_ed25519 error:2
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_ed25519.pub error:2
debug1: identity file C:\\Users\\enricojr/.ssh/id_ed25519 type -1
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_ed25519-cert error:2
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_ed25519-cert.pub error:2
debug1: identity file C:\\Users\\enricojr/.ssh/id_ed25519-cert type -1
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_xmss error:2
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_xmss.pub error:2
debug1: identity file C:\\Users\\enricojr/.ssh/id_xmss type -1
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_xmss-cert error:2
debug3: Failed to open file:C:/Users/enricojr/.ssh/id_xmss-cert.pub error:2
debug1: identity file C:\\Users\\enricojr/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
debug3: recv - from CB(2) ERROR:138, io:000001B6A4A39080
kex_exchange_identification: read: Connection timed out
Ping 正常,tracert 也正常(除非另有说明,否则所有命令均从 Windows Powershell 运行)
PS C:\Users\enricojr\.ssh> tracert 192.168.254.203
Tracing route to 192.168.254.203 over a maximum of 30 hops
1 2 ms 1 ms 2 ms 192.168.254.203
Trace complete.
PS C:\Users\enricojr\.ssh> ping 192.168.254.203
Pinging 192.168.254.203 with 32 bytes of data:
Reply from 192.168.254.203: bytes=32 time=2ms TTL=64
Reply from 192.168.254.203: bytes=32 time=2ms TTL=64
Reply from 192.168.254.203: bytes=32 time=2ms TTL=64
Reply from 192.168.254.203: bytes=32 time=2ms TTL=64
Ping statistics for 192.168.254.203:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 2ms, Maximum = 2ms, Average = 2ms
直接在远程运行ssh localhost
(我面前有一台笔记本电脑)会提示我输入密码,然后“连接”就好了。
我能够将scp
我想要使用的公钥从我的桌面顺利地传输到远程。
此外,我能够通过 SSH 从桌面连接到完全不同的远程设备,即我的 Macbook Pro。
我几乎可以肯定问题出在 pop os 上的 openssh-server 安装上,但它几乎是原装的,自从安装它之后我没有运行任何其他命令sudo systemctl stop/restart/status
,而且我以为它可以开箱即用。
知道可能是什么问题吗?
edit1:桌面->远程的 ssh-keyscan 的结果
PS C:\Users\enricojr\.ssh> ssh-keyscan 192.168.254.203
read (192.168.254.203): Connection timed out
read (192.168.254.203): Connection timed out
read (192.168.254.203): Connection timed out
答案1
我不知道这是否只是巧合——
当我第一次设置这台机器时,我设置了一个路由器 DHCP 范围之外的静态 IP 地址,但忽略了正确设置网络掩码。
将其从 0.0.0.0 -> 255.255.255.0 更改为重新启动似乎可以解决问题,但是我看不出网络掩码与这一切有什么关系,所以这可能只是巧合。