Closed
Description
Hi Folks
as we work behind the firewall, the SSH connection need go over HTTP proxy, but I found SSHj only support SOCKS proxy. here is the code snappet with HTTP proxy
try (SSHClient ssh = new SSHClient()) {
ssh.setConnectTimeout(60 * 1000);
ssh.setTimeout(60 * 60 * 1000);
ssh.getConnection().getKeepAlive().setKeepAliveInterval(30);
ssh.loadKnownHosts();
ssh.addHostKeyVerifier(new PromiscuousVerifier());
ssh.connect(host, new Proxy(Proxy.Type.HTTP, new InetSocketAddress("16.85.88.10", 8080)));
ssh.authPublickey(user, ssh.loadKeys(privateKey, null, null));
try (Session session = ssh.startSession()) {
final Session.Command cmd = session.exec("echo sleeping && date && sleep 3000 && date && echo awake");
System.out.println(IOUtils.readFully(cmd.getInputStream()).toString());
cmd.join(90, TimeUnit.MINUTES);
System.out.println("\n** exit status: " + cmd.getExitStatus());
}
}
i got exception:
java.lang.IllegalArgumentException: Invalid Proxy
at java.net.Socket.<init>(Socket.java:147)
at net.schmizz.sshj.SocketClient.connect(SocketClient.java:57)
at net.schmizz.sshj.SocketClient.connect(SocketClient.java:71)
at net.schmizz.sshj.SocketClient.connect(SocketClient.java:107)
at com.hp.es.cto.sp.remote.SshjTest.testKeepAlive(SshjTest.java:32)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
by dig into the source code of java.net.Socket.Socket(Proxy), we can see it only support SOCKS and NO_PROXY proxy.
I saw both jsch and ganymed support HTTP proxy, so would you consider to add HTTP proxy support? thanks