更改 ssh-keygen 中的默认证书签名算法

Arl*_*ion 5 linux ssh fedora centos arch-linux

目前,OpenSSH 7.8 (Fedora 28/Arch) 无法使用证书签名密钥与 OpenSSH 7.4 (CentOS 7) 服务器协商,如redhat 的 bugzilla 上提交的错误所述。OpenSSH 发行说明表明现在必须明确定义签名协商算法的更改。虽然现在允许使用 2 个新的签名算法(自 7.7 起),但由于错误或有意,ssh-rsa-cert-v01@openssh.com 用户证书不再能够用于身份验证。

重现步骤:

  1. ssh-keygen -t rsa -b 2048 -f 测试
  2. ssh-keygen -s cert.key -I "signedcert" -n testuser test.pub
  3. ssh -i 测试 -vvv 用户@serverip

我试图通过修改证书签名过程中使用的算法来解决这个问题。

ssh-keygen -L -f test.crt
test.crt:
    Type: ssh-rsa-cert-v01@openssh.com user certificate
    Public key: RSA-CERT SHA256:<fingerprint>
    Signing CA: RSA SHA256:<fingerprint>
Run Code Online (Sandbox Code Playgroud)

ssh-keygen 的默认设置是在 ssh-rsa-cert-v01@openssh.com 中对密钥进行签名。

根据 OpenSSH 7.8 文档,PROTOCOL.certkeys。

All certificate types include certification information along with the
public key that is used to sign challenges. In OpenSSH, ssh-keygen
performs the CA signing operation.

Certified keys are represented using new key types:

    ssh-rsa-cert-v01@openssh.com
    ssh-dss-cert-v01@openssh.com
    ecdsa-sha2-nistp256-cert-v01@openssh.com
    ecdsa-sha2-nistp384-cert-v01@openssh.com
    ecdsa-sha2-nistp521-cert-v01@openssh.com

Two additional types exist for RSA certificates to force use of
SHA-2 signatures (SHA-256 and SHA-512 respectively):

    rsa-sha2-256-cert-v01@openssh.com
    rsa-sha2-512-cert-v01@openssh.com
Run Code Online (Sandbox Code Playgroud)

这告诉我有 7 种密钥类型可用,如何在 ssh-keygen 证书签名过程中指定一种。

请注意:

  • 客户端或服务器上的以下配置更改对我不起作用。

    PubkeyAcceptedKeyTypes rsa-sha2-256,rsa-sha2-512,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh .com

  • 以 ed25519 格式对密钥进行签名与具有 openssh 5.3 的服务器(例如 CentOS 6)不向后兼容,因此不会被视为解决方案。

这里有两种可能的解决方案。

  1. 找到合适的解决方法以再次允许 ssh-rsa-cert-v01@openssh.com 用户证书。
  2. 找到一种方法来更改 ssh-keygen 中的证书签名算法。

更新:(1天后)

根据#openssh 上的用户的说法,证书签名算法由用于签署私钥的密钥设置。这意味着,如果我能弄清楚如何将 RSA 算法从 RSA:SHA1 更改为 RSA:SHA2,我可能能够强制证书签名算法为 sha2-256,这在双方都可以通过额外的解决方法实现。

更新:(12天后)

看着提交的错误报告,几乎没有取得任何进展……至少看起来是这样。我能够与一位 RHEL 员工进行非正式对话,他查看了我的错误并表示正确的人正在查看它,并且由于这也会影响 RHEL 可能会在 RHEL/CentOS 7.6 上进行修复

小智 1

链接的文章记录了以下方法:

ssh-keygen -s cert.key -I "signedcert" -n testuser  -t rsa-sha2-256 test.pub
Run Code Online (Sandbox Code Playgroud)

关键是-t rsa-sha2-256参数。