使用Jsch到Jump服务器时如何解决连接超时异常?

时间:2014-09-17 14:21:56

标签: java ssh jsch

我正在尝试通过跳转服务器连接到服务器。我正在使用Jsch 0.51并尝试使用setPortForwardingL方法进行连接。

但是,我在连接时遇到以下异常: java.net.ConnectException: Connection timed out

我基本上遵循此处给出的示例:http://www.jcraft.com/jsch/examples/JumpHosts.java.html

这种例外可能是什么原因?

修改:添加抛出异常的代码段:

//Trying to connect to the Jump server in this snippet
JSch jsch = new JSch();
Properties config = new Properties();
config.put("StrictHostKeyChecking", "no");
Session session = jsch.getSession(username, hostname, 22);
session.setPassword(password);
session.setConfig(config);
session.connect(); //Getting the ConnectException here

0 个答案:

没有答案