hierynomus / hierynomus/sshj

connect InputStream / OutputStream before handshake ( ProxyCommand support )

Open
#970 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.7k
Forks
620
Avg merge
3d 23h
Merged PRs (30d)
11

Description

Hi there.

I'm trying to implement an SSH tunnel that uses AWS SSM ("AWS Systems Manager") commands to communicate with a host. The way this apparently works with an `openssh` client is to configure a 'ProxyCommand' directive which I believe forks a process and then sends the SSH handshake and data to/from that process instead of a socket. ( AWS docs here: https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started-enable-ssh-connections.html ).

I was looking around the sshj source files looking for a way of doing this, but I can't see if this has been implemented anywhere.

I can see I might be able to connect my own InputStream/OutputStreams by calling `SSHClient.connectVia()` instead of calling `SSHClient.connect()`, but the only example I can find is Jump.java here: https://github.com/hierynomus/sshj/blob/master/examples/src/main/java/net/schmizz/sshj/examples/Jump.java
which passes in a DirectConnection, but that class still seems network-oriented rather than stream-oriented.

Is what I'm looking for possible out of the box using sshj or do I have to create a new kind of Channel / Transport / Connection class ?

There is mention of proxy connections in this PR: https://github.com/hierynomus/sshj/pull/756 but this looks like it's referring to SOCKS/HTTP proxies rather than `ProxyCommand`s

I wasn't sure how 'ProxyCommand' was implemented in `openssh` either... if it helps their implementation is here: https://github.com/openssh/openssh-portable/blob/master/sshconnect.c#L196
which is called from https://github.com/openssh/openssh-portable/blob/master/ssh.c#L1641

The command I need to use in the java equivalent to the openssh `ProxyCommand` is some AWS-supplied abomination written in go, but for the purposes of the java code is just a process that communicates via stdin/stdout.

Hoping you can give me some tips on what I need to do to get this use-case to work :)

Thanks in advance,
Greg

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.