Skip to content
This repository was archived by the owner on Nov 14, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@

# SSH Proxy #

> [!WARNING]
> **This project is no longer maintained.**
>
> SSH Proxy is built on the original [JSch][jsch], which is no longer maintained
> and lacks support for modern algorithms such as `rsa-sha2-256/512` or `ssh-ed25519`.
> [Apache MINA SSHD][mina-sshd] now covers the use case of this library out of the box:
> it reads `~/.ssh/config` (including multi-hop `ProxyJump`) and supports local port forwarding.
> We recommend migrating to Apache MINA SSHD. See [Migration to Apache MINA SSHD](#migration-to-apache-mina-sshd).

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][jsch] with the ability to understand
Expand Down Expand Up @@ -55,10 +64,52 @@ try (SshProxy sshProxy = new SshProxy()) {
}
```

## Migration to Apache MINA SSHD ##

Add the dependency `org.apache.sshd:sshd-core`. The equivalent of the example above:

```java
import java.util.concurrent.TimeUnit;

import org.apache.sshd.client.SshClient;
import org.apache.sshd.client.config.keys.ClientIdentity;
import org.apache.sshd.client.keyverifier.DefaultKnownHostsServerKeyVerifier;
import org.apache.sshd.client.keyverifier.RejectAllServerKeyVerifier;
import org.apache.sshd.client.session.ClientSession;
import org.apache.sshd.common.config.keys.FilePasswordProvider;
import org.apache.sshd.common.util.net.SshdSocketAddress;

try (SshClient client = SshClient.setUpDefaultClient()) {
// The defaults accept any server key and load no keys from ~/.ssh
client.setServerKeyVerifier(new DefaultKnownHostsServerKeyVerifier(RejectAllServerKeyVerifier.INSTANCE));
client.setKeyIdentityProvider(ClientIdentity.loadDefaultKeyPairProvider(true, true, FilePasswordProvider.EMPTY));
client.start();

// ProxyJump hops from ~/.ssh/config are resolved automatically
try (ClientSession session = client.connect("jumpHost2").verify(10, TimeUnit.SECONDS).getClientSession()) {
session.auth().verify(10, TimeUnit.SECONDS);
int targetPort = 1234;
SshdSocketAddress local = session.startLocalPortForwarding(
new SshdSocketAddress("localhost", 0),
new SshdSocketAddress("targetHost", targetPort));
try (Socket s = new Socket("localhost", local.getPort())) {
// ...
}
}
}
```

Differences to be aware of:

- `ProxyCommand` is not executed. Replace `ProxyCommand ssh -q -W %h:%p jumpHost` with `ProxyJump jumpHost`.
- Like OpenSSH, entries in `~/.ssh/known_hosts` for non-default ports must have the form `[host]:port`.
- In strict mode (first argument of `loadDefaultKeyPairProvider`), `~/.ssh` and the key files must not be accessible by other users.

## Dependencies ##

- Java 17+
- [JSch (with JZlib)][jsch]

[jsch]: http://www.jcraft.com/jsch/
[mina-sshd]: https://github.com/apache/mina-sshd
[blog-post-ssh-configuration-files]: https://blog.cronn.de/en/ssh/configuration/2021/08/16/ssh-configuration.html
Loading