简体   繁体   中英

Combining SOCAT with SSH to have dynamic port forwarding through socks proxy

My issue is very simple, what I want to do is to connect to my ssh through socat, this means if I have server 10.0.0.1 that has SSH and SOCAT together I listen to 5555 port of my socat, then my socat forwards all tcp packets to my ssh server 22 port for dynamic port forwarding.

I hope hear from you and Thank you in advance

Here is a basic configuration that seems to be what you want.

socat TCP-LISTEN:5555 TCP:localhost:22

If you want to use ssh on the server as a SOCKS proxy then you don't need socat. On the server run

ssh -D 10.0.0.1:5555 localhost 

Of course it is more secure if you run the ssh client on your local machine and change your socks proxy to point to localhost using

ssh -D 5555 10.0.0.1 

on the client machine.

If you can only use ssh indirectly then you can combine the above by running ssh on the server listening to 5550 on localhost and having socat listening on 5555 and forwarding it to 5550:

socat TCP-LISTEN:5555,fork TCP:localhost:5550 &
ssh -N -D 5550 localhost

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM