无法 ssh 到本地主机,但可以 ssh 到其他人

无法 ssh 到本地主机,但可以 ssh 到其他人

目前,我遇到了一个问题,我无法在 MacBook 中 ssh 到本地主机,但可以从 MacBook ssh 到其他计算机。这是命令的输出。

    ssh -v localhost
    OpenSSH_7.6p1, LibreSSL 2.6.2
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 52: Applying options for *
    debug1: Connecting to localhost port 22.
    debug1: Connection established.
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/something/.ssh/id_rsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/something/.ssh/id_rsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/something/.ssh/id_dsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/something/.ssh/id_dsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/something/.ssh/id_ecdsa type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/something/.ssh/id_ecdsa-cert type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/something/.ssh/id_ed25519 type -1
    debug1: key_load_public: No such file or directory
    debug1: identity file /Users/something/.ssh/id_ed25519-cert type -1
    debug1: Local version string SSH-2.0-OpenSSH_7.6
    ssh_exchange_identification: read: Connection reset by peer

答案1

我知道这已经很旧了,但我认为处理此问题的正确方法是sshd在调试模式下手动启动服务器,侦听不同的端口并尝试连接到此端口而不是默认端口22

# Start the server
sudo /usr/sbin/sshd -d -p 2222

# connect to server from another terminal
ssh -p 2222 localhost

我也遇到了同样的问题并且花了很多时间。结账这个问题详细答案。

相关内容