无法通过 MacOS 笔记本电脑连接到 Raspberry Pi。可通过包括 Linux 和 iOS 在内的其他设备工作。
这是 macOS 终端命令和输出:
ssh -vvvvvv -p 9091 [email protected]
OpenSSH_8.8p1, OpenSSL 1.1.1m 14 Dec 2021
debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname 192.168.1.103 is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/discord/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/discord/.ssh/known_hosts2'
debug3: ssh_connect_direct: entering
debug1: Connecting to 192.168.1.103 [192.168.1.103] port 9091.
debug3: set_sock_tos: set socket 3 IP_TOS 0x48
debug1: connect to address 192.168.1.103 port 9091: Bad file descriptor
ssh: connect to host 192.168.1.103 port 9091: Bad file descriptor
从我看到的 PI
error: kex_exchange_identification: Connection closed by remote host
Connection closed by 192.168.1.107: port 63461
答案1
调试日志表明,即使在通过 TCP 连接发送任何 SSH 特定数据之前,TCP 连接也因某种原因失败。您可以尝试使用命令禁用连接超时。如果此方法不起作用,请尝试使用 WireShark 分析 MAC 到 PI 的 TCP 连接失败的原因。ssh -vvvvvv -o ConnectTimeout=0 -p 9091 [email protected]
要检查是否可以从 MAC 到 PI 建立 TCP 连接,您可以尝试,telnet 192.168.1.103 9091
如果成功,您将看到类似以下内容:
bash> telnet 192.168.1.103 9091
Trying 192.168.1.103...
Connected to 192.168.1.103.
Escape character is '^]'.
SSH-1.1.1m-OpenSSH_8.8p1