Skip to main content
10 events
when toggle format what by license comment
Mar 25, 2011 at 10:46 vote accept ghickman
Mar 25, 2011 at 10:46 comment added ghickman @MaQleod your initial -L switch was right to forward local port to the remote one rather than remote to local with -R. Thanks for the help!
Mar 18, 2011 at 15:46 comment added ghickman The tunnel appears to be working fine. I get the success messages: "Remote connections from LOCALHOST:8080 forwarded to local address user@destination:22022" and "remote forward success for: listen 8080, connect user@destination:22022". However when I try start the second ssh (with "ssh user@localhost:8080 -p 22022 -v") it tries to connect to one of OpenDNS' servers: "Connecting to localhost:8080 [67.215.65.132] port 22022". Any ideas? Can I debug further than -v or -vvv?
Mar 18, 2011 at 14:17 comment added MaQleod No, you would open it up like ssh user@gateway -N -R 22:destination:22 (sorry, I use -L as that is for putty, on unix the port forward is -R) and then on the for the destination ssh you would use the local host address (ssh [email protected])
Mar 18, 2011 at 10:47 comment added ghickman Just to clarify - I'd open the tunnel to the gateway like so: ssh -N -L 22:<gateway>:22 then ssh to the destination with ssh 127.0.0.1:22 ? So far using this method the tunnel appears to setup fine but the second ssh is timing out (I'm using verbose mode to check).
Mar 17, 2011 at 17:22 comment added MaQleod If you are going to do this in bash, or really any other scripting language, you can make the destination IP a variable that is fed by an argument given on the command line for this script. That way you just need to type a command with an IP and you will get your tunnel and your connection all at once (just create the tunnel in the script with the first ssh instance and the second instance goes to the loopback IP) and you can then use the same script on any computer to go to any server.
Mar 17, 2011 at 16:51 history edited MaQleod CC BY-SA 2.5
edited body
Mar 17, 2011 at 16:50 comment added MaQleod When you create the tunnel, it makes 127.0.0.1 equal to the address you used when you set up the tunnel. So the first SSH will go to the gateway and will create the tunnel, you'd use the tunnel rule -L 22:xxx.xxx.xxx.xxx:22. The IP address you use there will be the IP of the destination SSH server. You will then open a new ssh session to 127.0.0.1:22 and it will use the tunnel you created.
Mar 17, 2011 at 16:28 comment added ghickman @MaQleod We're running *nix machines here but the config doesn't seem very different. How would I force the ssh connection to go over the tunnel, rather than it's normal route?
Mar 17, 2011 at 14:55 history answered MaQleod CC BY-SA 2.5