龙空技术网

ssh登录华测交换机错误

vip豆小豆 191

前言:

而今我们对“获取用户手机号时解密出错”可能比较看重,你们都需要剖析一些“获取用户手机号时解密出错”的相关资讯。那么小编在网上汇集了一些关于“获取用户手机号时解密出错””的相关内容,希望姐妹们能喜欢,大家一起来了解一下吧!

错误信息如下:

Unable to negotiate with 172.*.*.* port 22: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1

SSH连接原理

在A上使用ssh连接B

A向B发送连接请求B收到请求后,将自己的公钥发给AA收到公钥后,用公钥加密B的登陆密码,生成加密密文,发送给BB收到加密密文后,用自己的私钥解密,得到解密信息,然后与B的登陆密码做比较,正确则允许A登陆。SSH连接交换机密钥交换算法错误

我们尝试连接,提示如下提示:

C:\Windows\system32>ssh python@192.168.168.31Unable to negotiate with 192.168.168.31 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1,diffie-hellman-group-exchange-sha1
加密算法错误

根据提示显示没有匹配到密钥交换算法,所以我们先手动指定下加密算法,显示连接失败

C:\Windows\system32>ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 python@192.168.168.31Unable to negotiate with 192.168.168.31 port 22: no matching cipher found. Their offer: aes128-cbc,3des-cbc,des-cbc
密钥长度错误
C:\Windows\system32>ssh python@192.168.168.31

我们需要在交换机上重新生成密钥,一般指定为2048即可

[Layer3Switch-1]rsa local-key-pair create The key name will be: Layer3Switch-1_Host% RSA keys defined for Layer3Switch-1_Host already exist.Confirm to replace them? [y/n]:yThe range of public key size is (512 ~ 2048). NOTES: If the key modulus is greater than 512,        it will take a few minutes.Input the bits in the modulus[default = 512]:2048Generating keys..........................................+++......+++...++++++++...++++++++[Layer3Switch-1]q<Layer3Switch-1>sa	<Layer3Switch-1>save 
SSH连接成功

显示没有匹配到加密算法,我们在手动指定加密算法尝试,显示连接成功

C:\Windows\system32>ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -c 3des-cbc python@192.168.168.31The authenticity of host '192.168.168.31 (192.168.168.31)' can't be established.RSA key fingerprint is SHA256:j50h/p+PEsnv0XwuQ0Q5pEbwefyFLfCmVXLu9HwmwwY.Are you sure you want to continue connecting (yes/no/[fingerprint])? yesWarning: Permanently added '192.168.168.31' (RSA) to the list of known hosts.python@192.168.168.31's password:Info: The max number of VTY users is 5, and the number      of current VTY users on line is 1.      The current login time is 2023-06-26 22:26:48.<Layer3Switch-1>

显示我们连接成功,我们尝试运行个Display命令试试

<Layer3Switch-1>display clock2023-06-26 22:27:51-08:00MondayTime Zone(China-Standard-Time) : UTC-08:00
修改SSH配置文件

上面我们实现了SSH连接交换机没有问题,但是每次连接手动指定密钥交换算法和加密算法还是比较麻烦的,等于多台设备来说,太麻烦了,所以我们只需要在Windows用户SSH配置文件下指定好我们需要的算法,那么SSH默认会读取配置文件实现登录

配置文件路径默认于当前用户下的.ssh文件夹下:

至此Windows下SSH交换机可正常使用,可以批量执行Py脚本访问网络设备。

标签: #获取用户手机号时解密出错