ComputerA connects though putty to Server at port 77, and there is a reverse tunnel set up from the Server at port 6666 to ComputerA at port 22. ComputerA also has a ssh server set up with a user account named ComputerA_user_name.

I can ssh from ComputerB into Server with the command ssh admin@Server -p 9000 -D 6000. Then I run a ruby program on my computer, ComputerB, which makes a socks proxy connection on port 6000 and it runs through Server. How do I make the ruby program connect through proxy from ComputerB to ComputerA?

What I am trying now is after I ssh in from ComputerB to Server runnng this command on Server ssh -D 9000 localhost -p 6666 -l ComputerA_user_name to bind from ComputerB to the Server, and then bind from Server to ComputerA but it gives me the message, bind: Address already in use.


I found the answer


SOCKS proxy via an Intermediate Host

If you want to open a SOCKS proxy via an intermediate host, it is possible:

$ ssh -L 8001:localhost:8002 user1@machine1.example.org -t ssh -D 8002 user2@machine2.example.org

The client will see a SOCKS proxy on port 8001 on the local host, which is actually a connection to machine1 and traffic will ultimately enter and leave the net through machine2. Port 8001 on the local host connects to port 8002 on machine1 which is a SOCKS proxy to machine2. The port numbers can be chosen to be whatever you needed, but forwarding privileged ports still requires root privileges.

So in my case I used:

ssh -L 6000:localhost:6001 -p 9000 admin@ip
ssh -D 6001 -p 6666 localhost -l username -N

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.