我已经尝试解决这个问题好几天了。我曾经在 Ubuntu 中启动并运行了一个 samba 服务器和一个 ssh 服务器,我可以从我的树莓派连接到它们。现在我无法从任何设备连接到它们。我相信问题出在 ubuntu 上,而不是单个服务上,因为我收到相同的“对等方重置连接”错误消息。这是我尝试通过 ssh 连接的输出
OpenSSH_9.2p1 Debian-2+deb12u2, OpenSSL 3.0.11 19 Sep 2023
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname xxx.xxx.xxx.xxx is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/USER/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/USER/.ssh/known_hosts2'
debug3: ssh_connect_direct: entering
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x10
debug1: Connection established.
debug1: identity file /home/USER/.ssh/id_rsa type -1
debug1: identity file /home/USER/.ssh/id_rsa-cert type -1
debug1: identity file /home/USER/.ssh/id_ecdsa type -1
debug1: identity file /home/USER/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/USER/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/USER/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/USER/.ssh/id_ed25519 type -1
debug1: identity file /home/USER/.ssh/id_ed25519-cert type -1
debug1: identity file /home/USER/.ssh/id_ed25519_sk type -1
debug1: identity file /home/USER/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/USER/.ssh/id_xmss type -1
debug1: identity file /home/USER/.ssh/id_xmss-cert type -1
debug1: identity file /home/USER/.ssh/id_dsa type -1
debug1: identity file /home/USER/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.2p1 Debian-2+deb12u2
kex_exchange_identification: read: Connection reset by peer
Connection reset by xxx.xxx.xxx.xxx port 22
有人见过这些错误消息吗?有人知道如何解决它们吗?我检查了 /etc/ssh/ssh.allowed 和deny 文件,发现 ssh.deny 是空的,所以我为 pi 添加了本地 IP。我还尝试重新配置 ssh 并在 Ubuntu 和 pi 上卸载/重新安装它,看看是否有效。任何帮助都非常感谢
答案1
这可能有很多原因,例如网络问题、防火墙设置等。
运行cat /var/log/kern.log | grep netfiler
以检查您的服务器防火墙是否阻止连接。
sudo ufw allow 22/tcp
您可以尝试使用SSH 和sudo ufw allow 445/tcp
Samba解除端口阻塞。
如果您的客户端和服务器位于不同的网络上,则也可能是中间路由器上的防火墙,或者如果您使用 DNS 名称,则可能是 DNS 问题。
本文给出了更多解释。
答案2
Raspberry Pi 在路由器上被列为 DMZ。一旦将其从列表中删除,一切便会按预期运行。