Build Status Maven Central Apache 2.0 Coverage Status

SSH Proxy

A pure Java implementation for SSH port tunneling that is able to understand OpenSSH configurations which involve multiple hops to reach a target host. This library essentially combines JSch with the ability to understand ProxyJump or ProxyCommand configurations in your local ~/.ssh/config file.


Add the following Maven dependency to your project:



# cat ~/.ssh/config

Host jumpHost1
    User my-user

Host jumpHost2
    User other-user
    ProxyJump jumpHost1

Host targetHost
    ProxyCommand ssh -q -W %h:%p jumpHost2
try (SshProxy sshProxy = new SshProxy()) {
    int targetPort = 1234;
    int port = sshProxy.connect("jumpHost2", "targetHost", targetPort);
    try (Socket s = new Socket(SshProxy.LOCALHOST, port)) {
        OutputStream out = s.getOutputStream();
        InputStream in = s.getInputStream();
        // ...