debug1: expecting SSH2_MSG_KEX_ECDH_REPLY 解决SSH连接问题以及实现免密登录

#经过Wiregurard连接的两台电脑无法进行SSH连接,困扰我几天,最终解决的过程#

主电脑:10.79.12.31  OS:Debian 11

被连接的电脑:10.79.12.32  OS: Debian 12

上面的 IP 请自行替换

1. 测试网络是否通畅

ping 10.79.12.32

通过上面的测试,验证网络是正常的

2. 进行 SSH 连接

直接用 ssh 10.79.12.32 时,终端一直卡住不动, 通过详细日志查看连接的具体过程

ssh -vT 10.79.12.32

最终执行时,卡在 debug1: expecting SSH2_MSG_KEX_ECDH_REPLY

3. 解决问题

ssh -vT -o KexAlgorithms=ecdh-sha2-nistp521 root@10.79.12.32

输入连接目标电脑的秘密,不显示直接输入后回车

卡着时直接按 Ctrl + C

4. 生成秘钥

ssh-keygen -t rsa

回车三次,就可以生成秘钥

查看是否生成秘钥

cd ~/.ssh
ls -al

其中 id_rsa 是私钥;id_rsa.pub 是公钥

5. 把公钥传输到目标电脑

ssh-copy-id -i ~/.ssh/id_rsa.pub -o KexAlgorithms=ecdh-sha2-nistp521 root@10.79.12.32

按提示输入 yes 和 目标电脑的 root 用户密码

6. ssh 连接目标电脑

ssh -o KexAlgorithms=ecdh-sha2-nistp521 root@10.79.12.32
ip a

记得要增加参数 -o KexAlgorithms=ecdh-sha2-nistp521

连接成功后,我们可以验证

7. 把参数加到ssh配置文件中去

如果感觉每次都要带参数,比较麻烦,可以把参数写入配置文件中

vim ~/.ssh/config
cat ~/.ssh/config

按 i 后输入 KexAlgorithms=ecdh-sha2-nistp521

再按 ESC 输入 :wq

重启 ssh 服务

service ssh restart

连接测试

大功告成!欢迎收藏并点赞。

大家有问题欢迎加微信讨论!

OpenSSH_9.2p1 Debian-2, OpenSSL 3.0.9 30 May 2023 debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files debug1: /etc/ssh/ssh_config line 21: Applying options for * debug1: Connecting to lxslc702.ihep.ac.cn [2401:de00:2:332::186] port 22. debug1: Connection established. debug1: identity file /home/fyf/.ssh/id_rsa type -1 debug1: identity file /home/fyf/.ssh/id_rsa-cert type -1 debug1: identity file /home/fyf/.ssh/id_ecdsa type -1 debug1: identity file /home/fyf/.ssh/id_ecdsa-cert type -1 debug1: identity file /home/fyf/.ssh/id_ecdsa_sk type -1 debug1: identity file /home/fyf/.ssh/id_ecdsa_sk-cert type -1 debug1: identity file /home/fyf/.ssh/id_ed25519 type -1 debug1: identity file /home/fyf/.ssh/id_ed25519-cert type -1 debug1: identity file /home/fyf/.ssh/id_ed25519_sk type -1 debug1: identity file /home/fyf/.ssh/id_ed25519_sk-cert type -1 debug1: identity file /home/fyf/.ssh/id_xmss type -1 debug1: identity file /home/fyf/.ssh/id_xmss-cert type -1 debug1: identity file /home/fyf/.ssh/id_dsa type -1 debug1: identity file /home/fyf/.ssh/id_dsa-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_9.2p1 Debian-2 debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4 debug1: compat_banner: match: OpenSSH_7.4 pat OpenSSH_7.4* compat 0x04000006 debug1: Authenticating to lxslc702.ihep.ac.cn:22 as 'fanyufan' debug1: load_hostkeys: fopen /home/fyf/.ssh/known_hosts: No such file or directory debug1: load_hostkeys: fopen /home/fyf/.ssh/known_hosts2: No such file or directory debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory debug1: load_hostkeys: fopen /etc/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 Connection closed by 2401:de00:2:332::186 port 22
07-08
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值