Example usage for org.apache.commons.net.ssh SSHClient getTransport

List of usage examples for org.apache.commons.net.ssh SSHClient getTransport

Introduction

In this page you can find the example usage for org.apache.commons.net.ssh SSHClient getTransport.

Prototype

public Transport getTransport() 

Source Link

Document

Returns the associated Transport instance.

Usage

From source file:examples.ssh.RemotePF.java

public static void main(String... args) throws Exception {
    SSHClient client = new SSHClient();
    client.loadKnownHosts();//from  ww  w.  ja  va2 s.c  om

    client.connect("localhost");
    try {

        client.authPublickey(System.getProperty("user.name"));

        /*
         * We make _server_ listen on port 8080, which forwards all connections to us as a channel, and we further
         * forward all such channels to google.com:80
         */
        client.getRemotePortForwarder().bind(new Forward(8080), //
                new SocketForwardingConnectListener(new InetSocketAddress("google.com", 80)));

        // Something to hang on to so forwarding stays
        client.getTransport().join();

    } finally {
        client.disconnect();
    }
}