天天看點

ssh 無法登入問題 SSH2_MSG_KEXINIT

ssh 登入伺服器是最常用的登入方式。但是今天遇到突然無法登入的問題。

通過使用 ssh -vvv 可以檢查登入情況。

ssh -vvv -i xg-ss.pem root@xxxx       
OpenSSH_7.4p1, LibreSSL 2.5.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "xxxx" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to xxxx [xxxx] port 22.

debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file xg-ss.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file xg-ss.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.2 pat OpenSSH* compat 0x04000000
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to xxxxx:22 as 'root'
debug3: hostkeys_foreach: reading file "/xxxxx/.ssh/known_hosts"
debug3: record_hostkey: found key type ECDSA in file /xxxxx/.ssh/known_hosts:38
debug3: load_hostkeys: loaded 1 keys from xxxxx
debug3: order_hostkeyalgs: prefer hostkeyalgs: xxxxx
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent           

一直卡在 SSH2_MSG_KEXINIT,不動了。經過查詢,

發現是 mtu 的問題。

  1. 首先通過

    ifconfig eth0 mtu 1200

    ,測試發現,重新登入就好了。
  2. 1的配置隻能臨時生效,通過在/etc/network/interfaces 中增加 mut 1200 并重新開機網卡完成

繼續閱讀