Even if I create new Session instance in each connection "java.net.ConnectException: Cannot assign requested address" happened again. It is a problem in my socket factory. The real problem is that if Session instance is reconnected then "com.jcraft.jsch.JSchException: Packet corrupt" happens. Workaround: Create a new Session instance for each connection.
Th above test cases are done after I fixed my socket factory.
Hello! I found a problem in my socket factory that It was trying to reuse socket closed by JSch. Here are the results of my test cases: With socket factory: 1- session.connect() --> works 2- session.disconnect() --> works immediately after disconnect 3- session.connect() --> "java.net.ConnectException: Cannot assign requested address" 1 minute later: 4- session.connect() --> "com.jcraft.jsch.JSchException: Packet corrupt" I'm not sure; but, it looks JSch can not handle disconnect properly and I got...
"java.net.SocketException: Socket is closed" in next Session.connect()
I am going on this problem at https://stackoverflow.com/questions/52359207/secure-tunnel-from-ssh-server-to-target-host
The Jump Host example doesn't help. As I understand, it always creates local port forwarding in application side. So, I cannot create a JSch session between SSH servers.
There is a jump host example of Jsch at http://www.jcraft.com/jsch/examples/JumpHosts.java.html that cascades multiple JSch sessions. The flow can be: JavaApplicationHost --(JSchSession1)--> SSHServer1(3rd party utility runs) --(JSchSession2)--> SSHServer2 If I can create another tunnel by JSchSession2 between these SSH servers, I will be able to secure/compress the 3rd party application. I will test and update here. Thanks!
Hello! My java application connects to an SSH server and runs a third party utility by ChannelExec of Jsch. Then, this application makes unsecured/uncompresed file transfer to another server on which an SSH server is installed. The flow is: JavaApplicationHost --> SSHServer1(3rd party utility runs) --> SSHServer2 I want file transfers between these SSH servers to be secured/compressed. But, I cannot use any platform dependent utilities such as ssh command. I cannot install anything on these SSH servers....