Using HTTP or SOCKS Proxies

Lee Painter

You can use an HTTP or SOCKS 4/5 proxy to establish client connections with Maverick Synergy.

This requires that you create the SshClientContext and pass this to the SshClient constructor.

HTTP

For a simple anonymous HTTP Proxy

SshClientContext ctx = new SshClientContext();
ctx.enableHTTPProxy("localhost", 9999);

Then establish the connection as usual with your SshClient, passing the SshClientContext to the constructor.

try(SshClient ssh = new SshClient("localhost", 22, "lee", ctx)) {
...
}

If required you can pass credentials when setting up the proxy.

ctx.enableHTTPProxy("localhost", 9999, "lee", "password123?");

SOCKS

There are options for SOCKS 4 and SOCKS 5 Proxies. Again as outlined above this is a configuration on the SshClientContext.

SOCKS 4 does not support authentication. J

ctx.enableSocks4Proxy("localhost", 8889, "lee");

Now establish the connection as usual with your SshClient, passing the SshClientContext to the constructor.

try(SshClient ssh = new SshClient("localhost", 22, "lee", ctx)) {
...
}

SOCKS 5 support authentication, you can pass an empty or null string if you don't need to use authentication. The boolean flag on the end determines if the API tries to resolve the hostname locally (true) or remotely (false).

ctx.enableSocks5Proxy("localhost", 8889, "lee", "", false);