无法通过 SSH 进入 MacOS Big Sur (11.7.3) 上的本地主机 --> kex_exchange_identification:远程主机关闭连接

无法通过 SSH 进入 MacOS Big Sur (11.7.3) 上的本地主机 --> kex_exchange_identification:远程主机关闭连接

我刚刚开始学习有关 Mac 上的 SSH 配置。

已通过“系统偏好设置”->“共享”->“远程登录”启用远程登录:开启

  • 允许远程用户完全访问磁盘:是
  • 允许访问:所有用户

我尝试通过 ssh 进入本地主机,但仍然失败。

$ ssh -vvv <username>@localhost
OpenSSH_9.5p1, OpenSSL 3.1.4 24 Oct 2023
debug1: Reading configuration data /usr/local/etc/ssh/ssh_config
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/Users/<username>/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/Users/<username>/.ssh/known_hosts2'
debug2: resolving "localhost" port 22
debug3: resolve_host: lookup localhost:22
debug3: ssh_connect_direct: entering
debug1: Connecting to localhost [::1] port 22.
debug3: set_sock_tos: set socket 5 IPV6_TCLASS 0x48
debug1: Connection established.
debug1: identity file /Users/<username>/.ssh/id_rsa type -1
debug1: identity file /Users/<username>/.ssh/id_rsa-cert type -1
debug1: identity file /Users/<username>/.ssh/id_ecdsa type -1
debug1: identity file /Users/<username>/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/<username>/.ssh/id_ecdsa_sk type -1
debug1: identity file /Users/<username>/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /Users/<username>/.ssh/id_ed25519 type 3
debug1: identity file /Users/<username>/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/<username>/.ssh/id_ed25519_sk type -1
debug1: identity file /Users/<username>/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /Users/<username>/.ssh/id_xmss type -1
debug1: identity file /Users/<username>/.ssh/id_xmss-cert type -1
debug1: identity file /Users/<username>/.ssh/id_dsa type -1
debug1: identity file /Users/<username>/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_9.5
kex_exchange_identification: read: Connection reset by peer
Connection reset by ::1 port 22
$ 

当我进入 /var/logs/system.log 时,我看到的是:

com.apple.xpc.launchd[1] (com.openssh.sshd.690C494C-FCE9-4947-80DB-3A01970C5794[29851]): Service exited with abnormal code: 1

我也尝试过通过命令行启动/停止服务器:

sudo launchctl start com.openssh.sshd

当我进入 /var/logs/system.log 时,我看到的是:

com.apple.xpc.launchd[1] (com.openssh.sshd[29897]): Service exited with abnormal code: 1

还有其他我应该查看的地方吗?我在其他地方读到过,我应该在 /etc/ssh 中有一个 sshd_config 文件(即https://unix.stackexchange.com/questions/461851/start-sshd-on-machttps://stackoverflow.com/questions/43382825/where-to-find-sshd-logs-on-macos-sierra)。

但是,我在 /etc/ssh 目录中看不到此文件。不确定这是否有区别。

相关内容