4

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?

1
  • 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, 2011 at 22:10

4 Answers 4

5

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

It looks like this is what you have been doing:

ssh -L 8080:localhost:8080 [email protected]

The "-L 8080:" means that you're 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 you're 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 [email protected]

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)

0
1

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.

1

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.

0

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)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .