ssh卡在debug1: SSH2_MSG_KEXINIT sent解决方法

本文介绍了一种解决SSH连接过程中出现的特定错误的方法。当主机间的SSH连接卡在debug1:SSH2_MSG_KEXINITsent阶段时,可以通过调整网络接口的MTU值来解决。该问题通常由IPv4与GRE报头结构差异导致的数据包处理错误引起。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

现象:主机间互通正常且可以判断对方ssh端口是开放的,但是用ssh xxx.xxx.xxx.xxx -v这种方式连接的时候会卡在debug1: SSH2_MSG_KEXINIT sent这步

解决方法:echo "1454" > /sys/class/net/eth0/mtu

原因:详情参考http://techbackground.blogspot.com/2013/06/path-mtu-discovery-and-gre.html   简单解释就是IPV4报头与GRE报头结构不同,导致GRE数据包最大内容载荷只有1454,默认mtu如果是1500的话,就会有46字节的内容无法处理导致错误


xyc@xyc-virtual-machine:~$ ssh -Tv -p 29418 xiayuchen@gerrit-ce.tp-link.com OpenSSH_7.6p1 Ubuntu-4ubuntu0.7, OpenSSL 1.0.2n 7 Dec 2017 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: Applying options for * debug1: Connecting to gerrit-ce.tp-link.com [10.176.69.107] port 29418. debug1: Connection established. debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_rsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /home/xyc/.ssh/id_ed25519-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.7 debug1: Remote protocol version 2.0, remote software version GerritCodeReview_3.3.3 (APACHE-SSHD-2.4.0) debug1: no match: GerritCodeReview_3.3.3 (APACHE-SSHD-2.4.0) debug1: Authenticating to gerrit-ce.tp-link.com:29418 as 'xiayuchen' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: ecdh-sha2-nistp256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none debug1: sending SSH2_MSG_KEX_ECDH_INIT debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:94zokm8g9MOxm56wKUpvlohudHHs+WfWn+YsZ1pWeDM debug1: Host '[gerrit-ce.tp-link.com]:29418' is known and matches the ECDSA host key. debug1: Found key in /home/xyc/.ssh/known_hosts:1 debug1: rekey after 4294967296 blocks debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: rekey after 4294967296 blocks debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: /home/xyc/.ssh/id_rsa debug1: Trying private key: /home/xyc/.ssh/id_dsa debug1: Trying private key: /home/xyc/.ssh/id_ecdsa debug1: Trying private key: /home/xyc/.ssh/id_ed25519 debug1: No more authentication methods to try. xiayuchen@gerrit-ce.tp-link.com: Permission denied (publickey). |这是什么问题
最新发布
08-13
[root@localhost ~]# ssh -vT git@gitee.com OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 58: Applying options for * debug1: Connecting to gitee.com [180.76.198.225] port 22. debug1: Connection established. debug1: permanently_set_uid: 0/0 debug1: identity file /root/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ecdsa-cert type -1 debug1: identity file /root/.ssh/id_ed25519 type 4 debug1: key_load_public: No such file or directory debug1: identity file /root/.ssh/id_ed25519-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 ssh-pilot-1.8.4 debug1: no match: ssh-pilot-1.8.4 debug1: Authenticating to gitee.com:22 as 'git' debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ecdsa-sha2-nistp256 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: curve25519-sha256 need=64 dh_need=64 debug1: kex: curve25519-sha256 need=64 dh_need=64 debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: Server host key: ecdsa-sha2-nistp256 SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc debug1: Host 'gitee.com' is known and matches the ECDSA host key. debug1: Found key in /root/.
04-02
PS C:\Users\赵嘉楠> ssh -v 10.10.11.160 OpenSSH_for_Windows_9.5p1, LibreSSL 3.8.2 debug1: Reading configuration data C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/config debug1: C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/config line 1: Applying options for * debug1: C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/config line 5: Applying options for 10.10.11.160 debug1: Connecting to 10.10.11.160 [10.10.11.160] port 22. debug1: Connection established. debug1: identity file C:\\Users\\\350\265\265\345\230\211\346\245\240\\.ssh\\id_ed25519 type 3 debug1: identity file C:\\Users\\\350\265\265\345\230\211\346\245\240\\.ssh\\id_ed25519-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_for_Windows_9.5 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.7 debug1: compat_banner: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.7 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002 debug1: Authenticating to 10.10.11.160:22 as 'jianan.zhao' debug1: load_hostkeys: fopen C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts: No such file or directory debug1: load_hostkeys: fopen C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts2: No such file or directory debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: algorithm: curve25519-sha256 debug1: kex: host key algorithm: ssh-ed25519 debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none debug1: expecting SSH2_MSG_KEX_ECDH_REPLY debug1: SSH2_MSG_KEX_ECDH_REPLY received debug1: Server host key: ssh-ed25519 SHA256:SYUrRbM7d3XNt087+kqB/Lwq94oVzTY8CUgX8bT1Ej0 debug1: load_hostkeys: fopen C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts: No such file or directory debug1: load_hostkeys: fopen C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen __PROGRAMDATA__\\ssh/ssh_known_hosts2: No such file or directory debug1: hostkeys_find_by_key_hostfile: hostkeys file C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file C:\\Users\\\350\265\265\345\230\211\346\245\240/.ssh/known_hosts2 does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file __PROGRAMDATA__\\ssh/ssh_known_hosts does not exist debug1: hostkeys_find_by_key_hostfile: hostkeys file __PROGRAMDATA__\\ssh/ssh_known_hosts2 does not exist The authenticity of host '10.10.11.160 (10.10.11.160)' can't be established. ED25519 key fingerprint is SHA256:SYUrRbM7d3XNt087+kqB/Lwq94oVzTY8CUgX8bT1Ej0. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])?
03-20
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值