How to bind SOCKS proxies?

I have a working proxy from my laptop (machine A) for machine B:

[A]$ ssh -ND 8888 B

I can configure firefox to use the socks proxy on local port 8888, and browsing works. So far so good.

But I also have a proxy for socks between machines B and C:

[B]$ ssh -ND 8157 C

So, I can browse B as if I were in C.

Is there a way to link the two proxies so that I can use firefox locally (on A) when using a connection to C? That is, somehow redirecting all requests to firefox socks path from A to C. A and C cannot see each other directly, but I have ssh root access all over the world. All machines are Debian.

Note that I do not want to forward a single port (for example, 80), I need a full chained proxy server.

+6
source share
3 answers

on machine B, configure a dynamic proxy on machine C

 ssh -ND 8888 user@C 

then by car A

 ssh -L 8888:localhost:8888 user@B 

This makes the SOCKS connection on machine B and makes port 8888 of machine B88 connectable from the local port 8888 on machine A.

This may require 3 ssh connections if you cannot connect directly to machine B. If you can connect to machine B, you only need 2 and can actually send commands if necessary.

+8
source

These are the two solutions that I use.

SOCKS Public Proxy Launch SOCKS proxy on the public port on machine B

 [machineB]$ ssh -ND <public_ip>:8080 user@machineC 

or, do it from machine A (two jumps)

 [machineA]$ ssh user@machineB ssh -ND <machine_b_public_ip>:8080 user@machineC 

Then install your browser proxy on port 8080

Note. Verify that port 8080 is open on machine B's firewall.

Tunnel proxy SOCKS local proxy tunnel from machine B to machine A

Separate teams:

 [machineB]$ ssh -ND 8080 user@machineC [machineA]$ ssh -L 8080:localhost:8080 user@machineB 

or do it in one shot:

  [machineA]$ ssh -L 8080:localhost:8080 user@machineB ssh -ND 8080 user@machineC 

Now set your browser proxy to localhost on port 8080

0
source

you can cancel ssh from machine a to machine b, then transfer it to machine c ie machine c

 ssh -R 6333:localhost:22 user@machine _b_ip 

this will connect machine c to b through an encrypted tunnel and listen on port 22, now everything connected to port 6333 on machine b will be sent to machine_c_ip on port 22

Now connect to machine a to b

 ssh user_oof_machine_c@machine _b -p 6333 

now your port 6333 connected to device b, everything sent from machine c will be redirected to the device

you can perform the reverse process on different ports to run cmds from a to c

I know this chain of socks, but it's a hack problem

-1
source

Source: https://habr.com/ru/post/977766/


All Articles