Documentation
Open Source Release Policy
Export Compliance
Using BouncyCastle
Installing the API
Enabling Logging
Per-Connection Logging
Third Party Dependencies
Generating SSH Keys
Using BouncyCastle
Using SSH Public Keys in Java
Supporting ED25519/Curve25519
Supporting Compression
Integrating Licensing into Maven Builds
Creating an SSH Client
Public Key Authentication
Keyboard Interactive Authentication
Public Key Authentication with sshagent
Executing Single Commands
Executing Commands within a Shell
Transferring Files
Connecting through Proxies
Display the Authentication Banner
Using the SFTP Client
Port Forwarding
Working Examples
Configuring Listening Interfaces
Configuring Host Keys
Password Authentication
Public Key Authentication
Challenge-Response Authentication
Configuring Port Forwarding
Configuring SFTP
Supporting SCP
Implementing your own File System
Creating an Interactive Terminal
Proxy Protocol Support
Using HTTP or SOCKS Proxies
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);
Code language: JavaScript (javascript)
Then, establish the connection with your SshClient, passing the SshClientContext to the constructor.
try (SshClient ssh = SshClientBuilder.create()
.withHostname("localhost")
.withPort(2222)
.withUsername("root")
.withPassword("xxxx")
.withSshContext(ctx)
.build()) {
}
Code language: JavaScript (javascript)
If required, you can pass credentials when setting up the proxy.
ctx.enableHTTPProxy("localhost", 9999, "lee", "password123?");
Code language: JavaScript (javascript)
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.
ctx.enableSocks4Proxy("localhost", 8889, "lee");
Code language: JavaScript (javascript)
Now, connect with your SshClient, passing the SshClientContext to the constructor.
try (SshClient ssh = SshClientBuilder.create()
.withHostname("localhost")
.withPort(2222)
.withUsername("root")
.withPassword("xxxx")
.withSshContext(ctx)
.build()) {
}
Code language: JavaScript (javascript)
SOCKS 5 supports 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);
Code language: JavaScript (javascript)