ssh参数:KexAlgorithms、HostKeyAlgorithms 和 PubkeyAcceptedKeyTypes


0. 前言

在 SSH (Secure Shell) 协议中,KexAlgorithmsHostKeyAlgorithmsPubkeyAcceptedKeyTypes 是三个重要的参数,它们控制着 SSH 会话中的密钥交换算法、主机密钥算法以及公钥认证所接受的密钥类型。这些参数可以在 SSH 配置文件(如 /etc/ssh/sshd_config~/.ssh/config)中定义。

例如:

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -oHostKeyAlgorithms=+ssh-rsa -oPubkeyAcceptedKeyTypes=+ssh-rsa root@127.0.0.1

1. KexAlgorithms

此参数用于指定 SSH 连接过程中使用的密钥交换算法列表。常见的算法包括:

  • curve25519-sha256
  • curve25519-sha256@libssh.org
  • ecdh-sha2-nistp256
  • ecdh-sha2-nistp384
  • ecdh-sha2-nistp521
  • diffie-hellman-group-exchange-sha256
  • diffie-hellman-group16-sha512
  • diffie-hellman-group18-sha512

配置示例:

KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256

2. HostKeyAlgorithms

此参数用于指定用于服务器身份验证的主机密钥算法列表。常见的算法包括:

  • ssh-ed25519
  • rsa-sha2-256
  • rsa-sha2-512
  • ecdsa-sha2-nistp256
  • ecdsa-sha2-nistp384
  • ecdsa-sha2-nistp521

配置示例:

HostKeyAlgorithms ssh-ed25519,rsa-sha2-256,rsa-sha2-512

3. PubkeyAcceptedKeyTypes

此参数用于指定允许用于客户端认证的公钥类型。常见的类型包括:

  • ssh-ed25519
  • rsa-sha2-256
  • rsa-sha2-512
  • ecdsa-sha2-nistp256
  • ecdsa-sha2-nistp384
  • ecdsa-sha2-nistp521

配置示例:

PubkeyAcceptedKeyTypes ssh-ed25519,rsa-sha2-256,rsa-sha2-512

4. 配置文件示例

/etc/ssh/sshd_config 文件中添加或修改上述参数的配置:

KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256
HostKeyAlgorithms ssh-ed25519,rsa-sha2-256,rsa-sha2-512
PubkeyAcceptedKeyTypes ssh-ed25519,rsa-sha2-256,rsa-sha2-512

~/.ssh/config 文件中添加或修改上述参数的配置:

Host example.com
    KexAlgorithms curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256
    HostKeyAlgorithms ssh-ed25519,rsa-sha2-256,rsa-sha2-512
    PubkeyAcceptedKeyTypes ssh-ed25519,rsa-sha2-256,rsa-sha2-512

欢迎关注本人,我是喜欢搞事的程序猿; 一起进步,一起学习;

欢迎关注知乎/CSDN:SmallerFL

也欢迎关注我的wx公众号(精选高质量文章):一个比特定乾坤
在这里插入图片描述

  • 6
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

SmallerFL

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值