Last active
November 27, 2023 02:37
-
-
Save henri/56d424d6f22caf30e602550b43cff01e to your computer and use it in GitHub Desktop.
socat cheat sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this example sets up a tunnel on the remote system on port 8090 to the system initiating the ssh connection on port 8080 | |
# | |
# starting socat ipv4 tunnel between ports on remote system (forking and lock file enabled with socat) | |
# and killing socat with control-c / tunnel close | |
# | |
# tags : proxy port | |
# most direct approach | |
ssh -t [email protected] -R 8080:127.0.0.1:8080 "socat -L/tmp/socat.lock tcp4-listen:8090,reuseaddr,fork tcp:localhost:8080" | |
# more complex | |
ssh -t [email protected] -R 8080:127.0.0.1:8080 "(socat -L/tmp/socat.lock tcp4-listen:8090,reuseaddr,fork tcp:localhost:8080 & ) 2> /dev/null ; sleep infinity" | |
# more compatible | |
ssh -t [email protected] -R 8080:127.0.0.1:8080 "(socat -L/tmp/socat.lock tcp4-listen:8090,reuseaddr,fork tcp:localhost:8080 & ) 2> /dev/null ; trap 'exit 0' SIGINT ; while true ; do sleep 100 ; done" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment