Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Ok, here is the setup. I'm outside the local network and connecting to my home network using iSSH (on iPad), so far so good, I used to redirect my home mediacenter to localhost by creating a tunnel . So I can enter localhost:8080 in my address bar and browse my mediacenter at home, it was:

local port : 8080
destination host : localhost
destination port 8080

That worked well.

Now I would like to go a step further and tell the mediacenter I'm connecting to, to redirect 192.168.1.112:8800, that's the machine I'd like to access from the mediacenter and basically use the mediacenter as a gateway. I assume I'd have to use ssh -L but I`m not too sure if it's the right way to go about it.

How do I create this tunnel?

share|improve this question
    
could anybody follow up on how to do ssh tunneling with iSsh? The answers are perfectly clear if I'm working on my Mac/pc from a terminal, but I'm not sure how you actually do this on the iPad. I should add that I don't have an iSsh yet, and I would be glad to install it if I can use it to make a ssh tunnel to open a vnc session on a machine that is on my university private network. Thanks, Maurizio –  user88612 Jul 2 '11 at 22:10

4 Answers 4

up vote 4 down vote accepted

I'm using bold to differentiate between the local port your connecting to on your ipad (in bold) and the remote port your accessing on your mediacenter (not bold).

It looks like this is what you have been doing:

ssh -L 8080:localhost:8080 username@YourMediaCenterPublicAddress.com

The "-L 8080:" means that your going to be taking a remote resource and binding it to a local port (in this case 8080) which means you can connect to this remote resource by typing in localhost:8080 on your ipad. the next part "localhost:8080" (from the perspective of the media center) is the hostname and port who's resources your binding to port 8080 on your ipad. You can change this to any hostname or ip-address and port that your media center can see on its network.

Now that you want to connect to 192.168.1.112:8800 it will look like this:

ssh -L [aLocalPort]:192.168.1.112:8800 username@YourMediaCenterPublicAddress.com

then you can connect to 192.168.1.112:8800 by typing in localhost:[aLocalPort] into whatever program you want to use to connect to it on your ipad. (where [aLocalPort] is some un-used local port like 9000. You can use the same port that is used on the destination (8800) for convenience if you like)

share|improve this answer
    
it worked perfectly, thanks –  Julz May 25 '11 at 10:32

Yes you can add -L 192.168.1.112:8800, it will bind a port on your local machine (the client I mean) to the tunnel and will be forwarded by the remote server to the specified address and port.

share|improve this answer

Not really an answer, but using autossh instead of plain ssh is a good idea for tunnels, it reestablishes the tunnel automatically if there is a timeout etc (provided you have setup your ssh keys)

share|improve this answer

I have drawn some sketches

The machine, where the ssh tunnel command is typed is called »your host«.

ssh tunnel starting from local


ssh tunnel starting from remote

Introduction

  1. local: -L Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.

    ssh -L sourcePort:forwardToHost:onPort connectToHost means: connect with ssh to connectToHost, and forward all connection attempts to the local sourcePort to port onPort on the machine called forwardToHost, which can be reached from the connectToHost machine.

  2. remote: -R Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side.

    ssh -R sourcePort:forwardToHost:onPort connectToHost means: connect with ssh to connectToHost, and forward all connection attempts to the remote sourcePort to port onPort on the machine called forwardToHost, which can be reached from your local machine.

Your example

The second image represents this tunnel. The remotehost is your mediacenter. The farawayhost is your 192.168.1.112 machine with its pink port of interest (in the drawing port 456, but in your case port 8800). So the command has to look like this:

ssh -L 123:192.168.1.112:8800 mediacenter

Of course you can change the green port’s number 123 to whatever you want and then access it via

localhost:123

where again 123 is an arbitrary (choosen by your tunneling command) port number of the green port.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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