List of usage examples for org.apache.commons.net.ssh SSHClient newLocalPortForwarder
public LocalPortForwarder newLocalPortForwarder(SocketAddress address, String host, int port) throws IOException
From source file:examples.ssh.LocalPF.java
public static void main(String... args) throws Exception { SSHClient ssh = new SSHClient(); ssh.loadKnownHosts();/*from ww w .j a v a 2 s .c om*/ ssh.connect("localhost"); try { ssh.authPublickey(System.getProperty("user.name")); /* * _We_ listen on localhost:8080 and forward all connections on to server, which then forwards it to * google.com:80 */ ssh.newLocalPortForwarder(new InetSocketAddress("localhost", 8080), "google.com", 80).listen(); } finally { ssh.disconnect(); } }