-2

For a project I've to access a localhost apache server of a computer (host_C) from my computer (host_A) via another computer (host_B) all with ssh.

I've already succeeded to connect to host_C with host_A via host_B using :

ssh username_host_C@host_C

with this in my .ssh/config file :

Host host_C
ProxyCommand ssh username_host_B@host_B -W %h:%p

So I tried to do a ssh tunnel to access the local webserver of host_C in my browser at address http://localhost:8080 with this command :

ssh -L 8080:host_C:80 username_host_B@host_B -N

When I connect to http://localhost:8080/ it doesn't work and says in terminal :

debug1: Connection to port 8080 forwarding to host_C port 80 requested.
debug1: channel 4: new [direct-tcpip]
  • "it doesn't work" In what way does it not work? The debug messages indicate that the connection is being forwarded. What problem are you having at that point? Be detailed and specific. – Kenster Dec 15 '16 at 16:40
  • It's all the terminal tells me. My browser is stucked at "waiting for localhost" – tomatediabolik Dec 15 '16 at 16:56

1 Answers1

0

You're connecting to B and trying from there to get at host_C:80 -- port 80 on the public address of host_C. If your server is only listening on localhost on C, that won't work -- you need to connect to C with ssh, and forward to localhost:80. Something like

ssh -L 8080:localhost:80 username_host_C@host_C -N

should do it, assuming you can connect to host_C

Chris Dodd
  • 119,907
  • 13
  • 134
  • 226
  • On host_A, the command `ssh -L 8080:host_C:80 username_host_B@host_B -N` tells me `Local connections to LOCALHOST:8080 forwarded to remote address host_C:80` Then on host_C, the command `ssh -L 80:localhost:80 username_host_C@host_C -N -v` tells me `Local connections to LOCALHOST:80 forwarded to remote address 127.0.0.1:80`. I can see on terminal of host_A that a connection is forwarded but nothing on terminal of host_C and the browser is still stuck at "waiting for localhost". – tomatediabolik Dec 15 '16 at 18:05
  • `-L 80:localhost:80` makes no sense as it forwards localhost:80 to localhost:80 in a loop -- and should fail if you already have a server listening on localhost:80 – Chris Dodd Dec 16 '16 at 01:03