I want to open an SSH tunnel in a Java program, so that the connection to the rest of the system can be accessed (for example , If I forward a port to the local host for the database then I should be able to open the database in another program) ... in other words I need to create a Java wrapper to do something like unix command ssh . Although I need a program to be a cross platform, so if possible I would like to use a library from Java.
Is it possible (I'm looking at different libraries, but the tunnel, so the rest of the system can still use it)
The library definitely makes it easy and supports ports forwarding:
JSch jsch = new JSch (); Session session = jsch.getSession (user, host); Session.setPassword (password); Session.connect (timeout); Session.setPortForwardingL (Sourceport, destHost, destport);
Comments
Post a Comment