ssh3 icon indicating copy to clipboard operation
ssh3 copied to clipboard

Support for reverse connections

Open siepkes opened this issue 2 years ago • 3 comments

First of all let me say this seems like a really interesting project!

One thing I think it could also be useful for is remote access to IoT devices. IoT devices often sit behind a NAT and only have outbound HTTP access. Granted, sometimes they might not even have outbound HTTP/3 access due to UDP restrictions but I think those days are numbered and those cases are limited. These devices sometimes also have laggy Internet connections over 2G (for which SSH3 seems like a good fit). Therefore it would be beneficial if SSH3 supported a reverse persistent connection. Where the "client" sets up a persistent connection to a server (like for example autossh).

siepkes avatar Dec 16 '23 17:12 siepkes

Thanks for the feedback ! That would be great indeed. One "easy" way to achieve this would be to do reverse UDP port forwarding and then connect to the device using that, tunnelling the inbound connections through the UDP reverse tunnel.

I am a bit overloaded right now, so I might not implement this in the coming days but reverse port forwarding is for sure in the list of important features to implement next :-)

francoismichel avatar Dec 17 '23 14:12 francoismichel

There are numerous ways to achieve it, e.g. with the gost.run tool. You can make reverse connections (TCP / UDP ) to machines behind NAT.

ezbik avatar Dec 17 '23 15:12 ezbik

I have been working on implementing this functionality and submitted a pull request for this (https://github.com/francoismichel/ssh3/pull/148). In OpenSSH, the client sends a GLOBAL_REQUEST "tcpip-forward" message with information regarding reverse port forwarding, but in SSH3, it is not clear how these global messages are sent, so I used a channel request for that. More details are included in the pull request. Anyhow, I do not implement special UDP tunnels for reverse connections, relying only on the already existing SSH3 messages and channels framework.

jdhozdiego avatar Jul 29 '24 12:07 jdhozdiego