【发布时间】:2020-04-14 18:35:04
【问题描述】:
我已经使用 ssh-keygen 创建了一个证书,但我在 maverick 最新包中找不到合适的方法来建立连接..尽管 maverick 提供了该功能。我在哪里可以 加载我的私钥和证书?因为我无法使用密钥库,它用于维护 X.509 类型的证书。请让我知道验证 ssh-rsa-cert-v01 类型证书的方法..
【问题讨论】:
标签: ssh certificate openssh ssh-keygen
我已经使用 ssh-keygen 创建了一个证书,但我在 maverick 最新包中找不到合适的方法来建立连接..尽管 maverick 提供了该功能。我在哪里可以 加载我的私钥和证书?因为我无法使用密钥库,它用于维护 X.509 类型的证书。请让我知道验证 ssh-rsa-cert-v01 类型证书的方法..
【问题讨论】:
标签: ssh certificate openssh ssh-keygen
您需要像加载任何公钥一样加载证书。这意味着加载以“-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));
【讨论】: