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 的问题。
- 首先通过
ifconfig eth0 mtu 1200
,测试发现,重新登录就好了。 - 1的配置只能临时生效,通过在/etc/network/interfaces 中增加 mut 1200 并重启网卡完成