# How to reverse tunnel?

## dE_logics

Suppose the SSH server (the box in which I want log into) has name serve, having IP 192.168.1.1 and the host's name is client with ip 192.168.1.2

From the tutorials I got - 

ssh -R <the host's open port>localhost:22 <username>@192.168.1

In the server to set up a reverse tunnel.

My question is what is this localhost?...and why port 22?

Is all this possible without a third 'middle' computer?

----------

## jordanwb

 *dE_logics wrote:*   

> My question is what is this localhost?...and why port 22?

 

localhost resolves to 127.0.0.1 which is the ip address that the ssh server listens on. Port 22 is the port that ssh listens on.

Btw you spelled "sense" in your signature incorrectly.

----------

## dE_logics

Thanks for telling me that.

So 127.0.0.1 (or localhost) is assumed to be the server? So wont it be wrong to use localhost in case the server's address (in this example 192.168.1.1 and external, through NAT) which is not 127.0.0.1?

----------

## Mad Merlin

127.0.0.1 always points to the local machine, that's what the loopback (lo) interface is for.

I'm not entirely sure what you're asking in the initial question, but the ports involved in the forwarding are arbitrary (although if you're a regular user, you'll need to use ports >1024). The localhost is what you'd normally use, the only case you wouldn't is if you were trying to reach a third machine which was only reachable via the machine you're sshing to (or from, in the case of a reverse forwarding).

----------

## dE_logics

Ok, now I understand. Thanks!

We do not have to use the external IP for this setting in the server.

----------

