【问题标题】:Ssh certificate authentication using certificate of type ssh-rsa-cert-v01使用 ssh-rsa-cert-v01 类型证书的 SSH 证书身份验证
【发布时间】:2020-04-14 18:35:04
【问题描述】:

我已经使用 ssh-keygen 创建了一个证书,但我在 maverick 最新包中找不到合适的方法来建立连接..尽管 maverick 提供了该功能。我在哪里可以 加载我的私钥和证书?因为我无法使用密钥库,它用于维护 X.509 类型的证书。请让我知道验证 ssh-rsa-cert-v01 类型证书的方法..

【问题讨论】:

    标签: ssh certificate openssh ssh-keygen


    【解决方案1】:

    您需要像加载任何公钥一样加载证书。这意味着加载以“-cert.pub”结尾的证书文件

        SshPublicKey publicKey = SshKeyUtils.getPublicKey(
              new File("user_key-cert.pub"));
        SshPrivateKey privateKey = SshKeyUtils.getPrivateKey(
              new File("user_key"), "xxx"));
    
        SshKeyPair pair = new SshKeyPair();
        pair.setPrivateKey(privateKey);
        pair.setPublicKey(publicKey);
    

    然后,您可以像使用任何普通 SSH 密钥一样将其用于身份验证。

        // Create SshClient
        SshClient ssh = SshConnector.createInstance()
               .connect(new SocketTransport("host", 22), "user"));
        ssh.authenticate(new PublicKeyAuthentication(pair));
    

    【讨论】:

      猜你喜欢
      • 2021-04-16
      • 2018-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-18
      • 2019-09-28
      • 2023-03-29
      相关资源
      最近更新 更多