From 3a2bc2a0627820cb408ed023419794ea239cf5f6 Mon Sep 17 00:00:00 2001 From: Benedikt Waldvogel Date: Sat, 14 Nov 2026 14:59:06 +0100 Subject: [PATCH] Add end-of-life notice with migration guide to Apache MINA SSHD --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/README.md b/README.md index 56b0e7d..61bc5be 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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