Ubuntu终端连接出错:Couldn’t agree a client-to-server cipher (available: aes128-ctr,aes192-ctr......)

在安装了SSH-Server之后终端连接的过程中被中断

sudo apt-get install openssh-server

抛出的异常信息

Couldn’t agree a client-to-server cipher (available: aes128-ctr,aes192-ctr,aes256-ctr,chacha20-poly1305@openssh.com)

原因

CBC block cipher mode of operation已经不够安全了,所以新的SSH-Server不支持该模式,而用的终端又不支持上面的CTR的模式所以就被拒绝连接了


解决方法

有两种方案

一种是把你的终端更新至最新版本

另一种是更改支持的加密算法

vi /etc/ssh/sshd_config
在最后一行添加

Ciphers aes128-ctr,aes192-ctr,aes256-ctr,chacha20-poly1305@openssh.com,aes256-cbc
然后重新启动ssh

/etc/init.d/ssh restart




  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
AES-128-CTR是一种对称加密算法,它使用128位密钥和计数器模式(CTR)进行加密。CTR模式将计数器作为输入,然后使用加密函数生成密钥流,该密钥流与明文异或以生成密文。由于CTR模式中的加密和解密使用相同的操作,因此CTR模式可以用于加密和解密。 以下是使用Python中的pycryptodome库实现AES-128-CTR加密和解密的示例代码: ```python from Crypto.Cipher import AES from Crypto.Util import Counter import binascii # 加密函数 def aes_ctr_encrypt(key, iv, data): # 将iv转换为计数器对象 ctr = Counter.new(128, initial_value=int(binascii.hexlify(iv),16)) # 创建AES加密器 aes = AES.new(key, AES.MODE_CTR, counter=ctr) # 加密数据 ciphertext = aes.encrypt(data) # 返回密文 return ciphertext # 解密函数 def aes_ctr_decrypt(key, iv, ciphertext): # 将iv转换为计数器对象 ctr = Counter.new(128, initial_value=int(binascii.hexlify(iv), 16)) # 创建AES解密器 aes = AES.new(key, AES.MODE_CTR, counter=ctr) # 解密数据 data = aes.decrypt(ciphertext) # 返回明文 return data # 测试 key = b'2B7E151628AED2A6ABF7158809CF4F3C' iv = b'F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF' data = b'6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5' ciphertext = aes_ctr_encrypt(key, iv, data) print('加密结果:', binascii.hexlify(ciphertext)) plaintext = aes_ctr_decrypt(key, iv, ciphertext) print('解密结果:', plaintext) # 输出: # 加密结果: b'874d6191b620e3261bef6864990db6ce9806f66b7970fdff8617187bb9fffdff5ae4df3edbd5d35e5b4f09020db03eab1e031dda2fbe03d1792170a0f3009cee' # 解密结果: b'6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5' ```

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值