Jan*_*tze 5 java ssh openssh apache-mina sshd
我试图获取服务器的公钥.这是我试过的:
val serverKey = sshClient.connect("dyn mem", "localhost", "2222")
.verify()
.getSession()
.getKex()
.getServerKey()
Run Code Online (Sandbox Code Playgroud)
问题是得到的结果getServerKey()是null ...
如何使用Apache SSHD客户端获取SSH服务器的公钥.
和connect()后续的密钥交换都是异步操作,因此需要等待几次。例如:
ConnectFuture connectFuture = client.connect(username, host, 22);
connectFuture.await(5000);
ClientSession session = connectFuture.getSession();
session.waitFor(Arrays.asList(ClientSessionEvent.WAIT_AUTH), 5000);
session.getKex().getServerKey();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
349 次 |
| 最近记录: |