2

I know I can create an ssh tunnel and then tell a program (with tsocks) to use it for networking. But. How can I put an ssh tunnel in an ssh tunnel? I mean I can't again use the tsocks in tsocks because I can't provide a good tsocks.conf [and not a solution even if someone could:)].

So how can I tell an ssh tunnnel to use an ssh tunnel?

Scenario:

PC-A ->> ROUTER -->> PC-B
  • PC-A: I'm this guy
  • ROUTER: this is the router (we don't want port forward on it, only ssh)
  • PC-B: the machine that I need to ssh tunnel from PC-A.

So I need a tunnel to the router. Then I need a tunnel that uses the router's tunnel so that I can reach PC-B behind NAT.

LanceBaynes
  • 40,135
  • 97
  • 255
  • 351
  • Could you try and explain a bit better what you are trying to achieve? What would that "tunnel in a tunnel" connect to? (Simply listing what hosts you have, who can connect to what, and what tunnels you want to set up should clarify things.) – Mat Jan 04 '12 at 10:10
  • I updated the Question – LanceBaynes Jan 04 '12 at 10:16
  • 2
    See: http://superuser.com/questions/96489/ssh-tunnel-via-multiple-hops – Mat Jan 04 '12 at 10:24

1 Answers1

3

The first tunnel wouldnt be a socks tunnel. Say you have PC->hostA->hostB and you want the proxy through hostB from PC

ssh -t -L 1080:localhost:1080 hostA "ssh -D 1080 hostB"

Then use localhost:1080 as the socks server on PC.

When you connect to localhost:1080 from PC, the connection is forwarded to localhost:1080 on hostA which is the socks server that tunnels through hostB.

phemmer
  • 71,831