我可以在Ubuntu中建立端口转发会话,如下所示:
ssh -L 8000:dev.mycompany.com:443 jump.mycompany.com
现在我想用Jsch模仿:
public static void openTunnel() {
JSch jsch = new JSch();
String privateKey = "~/.ssh/id_rsa";
try {
jsch.addIdentity(privateKey);
log.info("Connecting to {}@{}", getJumpUser(), getJumpServer());
Session session = jsch.getSession(getJumpUser(), getJumpServer(), 22);
session.connect();
session.setPortForwardingL(8000, getHost(), 433);
} catch (JSchException e) {
log.error("", e);
}
}
但是在建立隧道之后,尝试使用RestTemplate连接到它(Spring HTTP Client-但curl也会产生错误):]
ssl.SSLHandshakeException: Remote host closed connection during handshake at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:744)
我必须在Jsch中配置什么才能使其与openssh客户端完全相同?
我可以在Ubuntu中建立端口转发会话,如下所示:ssh -L 8000:dev.mycompany.com:443 jump.mycompany.com现在,我想用Jsch来模拟它:public static void openTunnel(){。 ..
我想,您正在尝试建立与不公开的https网络服务器的连接。