【发布时间】:2020-05-28 20:43:28
【问题描述】:
我无法通过密码与服务器建立 ssh 连接。
C:\Users\hoyong>ssh username@SERVER_IP_ADDRESS
ssh_exchange_identification: read: Connection reset
这令人困惑,因为它适用于连接到不同网络的某些客户端。
(服务器端 /etc/hosts.deny 或 /etc/hosts.allow 中没有规则。)
(用IPTABLES似乎没有问题。IPTABLE规则如下。)
(base) name@server:/$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy DROP)
target prot opt source destination
DOCKER-USER all -- anywhere anywhere
DOCKER-ISOLATION-STAGE-1 all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (1 references)
target prot opt source destination
Chain DOCKER-ISOLATION-STAGE-1 (1 references)
target prot opt source destination
DOCKER-ISOLATION-STAGE-2 all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-ISOLATION-STAGE-2 (1 references)
target prot opt source destination
DROP all -- anywhere anywhere
RETURN all -- anywhere anywhere
Chain DOCKER-USER (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
可能是什么问题?
这是详细的调试信息。在客户端进行 ssh 连接试验。
C:\Users\hoyong>ssh -vvv username@SERVER_IP_ADDRESS
OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug3: Failed to open file:C:/Users/hoyong/.ssh/config error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolve_canonicalize: hostname SERVER_IP_ADDRESS is address
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to SERVER_IP_ADDRESS [SERVER_IP_ADDRESS] port 22.
debug1: Connection established.
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_rsa error:2
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_rsa.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\hoyong/.ssh/id_rsa type -1
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_rsa-cert error:2
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_rsa-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\hoyong/.ssh/id_rsa-cert type -1
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_dsa error:2
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_dsa.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\hoyong/.ssh/id_dsa type -1
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_dsa-cert error:2
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_dsa-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\hoyong/.ssh/id_dsa-cert type -1
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_ecdsa error:2
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_ecdsa.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\hoyong/.ssh/id_ecdsa type -1
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_ecdsa-cert error:2
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_ecdsa-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\hoyong/.ssh/id_ecdsa-cert type -1
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_ed25519 error:2
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_ed25519.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\hoyong/.ssh/id_ed25519 type -1
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_ed25519-cert error:2
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_ed25519-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\hoyong/.ssh/id_ed25519-cert type -1
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_xmss error:2
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_xmss.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\hoyong/.ssh/id_xmss type -1
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_xmss-cert error:2
debug3: Failed to open file:C:/Users/hoyong/.ssh/id_xmss-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\\Users\\hoyong/.ssh/id_xmss-cert type -1
debug3: send - WSASend() ERROR:10054, io:0000017EE48EFA70
write: Connection reset
服务器端的 /var/log/auth.log 是这样的
May 28 20:46:20 server01 sshd[29836]: Connection reset by CLIENT_IP_ADDRESS port 7768 [preauth]
【问题讨论】:
-
从调试输出看来,您没有
rsa或dsaID 文件。不确定这是否有助于您的连接,请尝试运行ssh-keygen -t rsa(也可能是dsa),然后重试您的ssh命令行。有更好的结果吗? -
尝试在端口 222 上以调试模式运行另一个 sshd 实例并从本地计算机进行测试。
-
@Milag 生成了公钥和私钥,但出现了同样的错误。 "debug3: send - WSASend() ERROR:10054, io:000001860B8E6400 write: Connection reset"