Skip to content

proxy: support proxies behind SSH - #57

Open
rlahfa-dinum wants to merge 1 commit into
mainfrom
proxy-behind-ssh
Open

proxy: support proxies behind SSH#57
rlahfa-dinum wants to merge 1 commit into
mainfrom
proxy-behind-ssh

Conversation

@rlahfa-dinum

@rlahfa-dinum rlahfa-dinum commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator

A classical technique to authenticate proxies is to piggy back existing SSH authnz systems and perform SSH forwards to access an unprotected proxy.

To ease migrations on users with existing proxy fleet, we allow daisychaining to these sorts of proxies.

TODO:

  • Actually open an SSH tunnel as a TcpStream
  • E2E testing

@rlahfa-dinum
rlahfa-dinum force-pushed the proxy-behind-ssh branch 2 times, most recently from 45e2427 to d081349 Compare March 27, 2026 21:47
A classical technique to authenticate proxies is to piggy back existing
SSH authnz systems and perform SSH forwards to access an unprotected
proxy.

To ease migrations on users with existing proxy fleet, we allow
daisychaining to these sorts of proxies.

We implement a very opinionated support of SSH:

- .ssh/config must contain an entry with proper preconfiguration for
  User, etc.
- Portail configuration needs proxy-host (must match a .ssh/config
  entry) and target-address (final proxy target, can be 127.0.0.1)
- An SSH agent over UDS must be provided (otherwise it's guessed from the
  environment variable SSH_AUTH_AGENT_SOCKET) and should be able to
  authenticate over the SSH server
- The server must already be trusted in the standard known-hosts file
  from OpenSSH

If these conditions are reunited, the connection will succeed.

Signed-off-by: Ryan Lahfa <ryan.lahfa.ext@numerique.gouv.fr>
@rlahfa-dinum
rlahfa-dinum marked this pull request as ready for review March 27, 2026 23:25
Comment thread src/proxy/ssh.rs
&mut self,
server_public_key: &russh::keys::ssh_key::PublicKey,
) -> Result<bool, Self::Error> {
// TODO: check known hosts keys

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is checking it now

Comment thread src/proxy/ssh.rs
target_port: config.port(),
};

// TODO: this is using whoami as a last resort...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opinions? @agrimault-dinum

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I am not mistaken, for our use case, this fallback is always wrong. However I don't see a security problem. So I don't have a strong opinion either way.

@agrimault-dinum agrimault-dinum left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At one point, we might want to store the ssh session, call session.channel_open_direct_tcpip many times on it and have a mecanism to refresh it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants