Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cronn/ssh-proxy
Pure Java implementation for SSH port tunneling that understands ProxyJump and ProxyCommand
https://github.com/cronn/ssh-proxy
java ssh tunnel
Last synced: about 1 month ago
JSON representation
Pure Java implementation for SSH port tunneling that understands ProxyJump and ProxyCommand
- Host: GitHub
- URL: https://github.com/cronn/ssh-proxy
- Owner: cronn
- License: apache-2.0
- Created: 2016-07-07T14:07:06.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-07-12T07:32:27.000Z (5 months ago)
- Last Synced: 2024-07-30T05:18:17.182Z (5 months ago)
- Topics: java, ssh, tunnel
- Language: Java
- Homepage:
- Size: 661 KB
- Stars: 34
- Watchers: 13
- Forks: 16
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-network-stuff - **19**星
README
[![CI](https://github.com/cronn/ssh-proxy/workflows/CI/badge.svg)](https://github.com/cronn/ssh-proxy/actions)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/de.cronn/ssh-proxy/badge.svg)](http://maven-badges.herokuapp.com/maven-central/de.cronn/ssh-proxy)
[![Apache 2.0](https://img.shields.io/github/license/cronn/ssh-proxy.svg)](http://www.apache.org/licenses/LICENSE-2.0)
[![codecov](https://codecov.io/gh/cronn/ssh-proxy/branch/main/graph/badge.svg?token=qhZPq2vKnv)](https://codecov.io/gh/cronn/ssh-proxy)
[![Valid Gradle Wrapper](https://github.com/cronn/ssh-proxy/workflows/Validate%20Gradle%20Wrapper/badge.svg)](https://github.com/cronn/ssh-proxy/actions/workflows/gradle-wrapper-validation.yml)# 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][jsch] with the ability to understand
`ProxyJump` or `ProxyCommand` configurations in your local `~/.ssh/config`
file.See our [blog post "Tunneling Basics – Part II: OpenSSH Configuration Files"][blog-post-ssh-configuration-files] for
some context where and how this library can be used.## Usage ##
Add the following Maven dependency to your project:```xml
de.cronn
ssh-proxy
1.6```
### Example ###
```
# cat ~/.ssh/configHost jumpHost1
User my-user
HostName jumphost1.my.domainHost jumpHost2
User other-user
ProxyJump jumpHost1Host targetHost
ProxyCommand ssh -q -W %h:%p jumpHost2
``````java
try (SshProxy sshProxy = new SshProxy()) {
int targetPort = 1234;
int randomLocalPort = sshProxy.connect("jumpHost2", "targetHost", targetPort);
try (Socket s = new Socket(SshProxy.LOCALHOST, randomLocalPort)) {
OutputStream out = s.getOutputStream();
InputStream in = s.getInputStream();
// ...
}
}
```## Dependencies ##
- Java 11+
- [JSch (with JZlib)][jsch][jsch]: http://www.jcraft.com/jsch/
[blog-post-ssh-configuration-files]: https://blog.cronn.de/en/ssh/configuration/2021/08/16/ssh-configuration.html