On 2011-08-03 00:23:16 -0400, Tony Gravagno
<tony_gravagno (AT) nospam (DOT) invalid> said:
I think you've got it, but I'll elaborate in case anyone else is
following along.
Quote:
Am I correct to understand that the SSH server automatically does the
port forwarding on that side? |
Yes, as long as the request was valid/allowed. Note that the
forwarding could even be to another box and not just "localhost (the
server)".
Quote:
So telnet into port 23 on the client
and the transaction is encrypted on the wire. The SSH service gets
it, then forwards to port 23 on the localhost/server. |
Yes, over the established tunnel. All data is actually sent over the
SSH connection (port 22), regardless of the forwarding destination.
Quote:
So the port
used to receive the data on the client is passed in the payload? |
I don't believe so. I think that the tunnel is preconfigured based on
the port forwarding request made by the client. If when logging on
with Tunnelier you watch the info messages scroll by during the
connection phase, you will see each port forward request being
established as a tunnel during that phase. Though, I could be mistaken
on this technical detail.
Quote:
Wow, that would be very simple indeed. |
The problem most people run into when dealing with port forwarding is
conceptualizing what's happening at both ends. The idea of listen on
localhost and forward to localhost does not seem to make sense because
the user tends to view everything from where they are, at the
client/localhost. They must think it of in terms of both sides of the
equation:
* SSH client should listen on my machine (localhost) for data going to
ports for which I have requested port forwarding from the SSH service.
Such port-specific data will be sent over the wire (port 22) to the SSH
server.
* At the server, the SSH service will forward that request as
previously requested/defined. In most cases this is to a port on
localhost, the server itself, but could even be to a different server.
So, the following is possible.
Client Listens on: SSH service forwards to:
1) localhost: 8023 localhost: 23
2) localhost: 80 192.168.1.115: 80
Example 1. - Client listens for local requests on port 8023. SSH
Server/service forwards that request to port 23 on the server itself.
One could assume this is telnet data.
Example 2. - Client listens for local requests on port 80. SSH
server/service forwards those requests to port 80 on a different
server. One could assume this is HTTP/web traffic.
Again, and saying it in another way, the SSH client listens for
requests on a specific interface (127.0.0.1 = Localhost) for specific
ports. It sends that data over the established SSH connection (port
22) to the SSH service. It is the SSH service that forwards the data
to a specific server & port. This is usually localhost, the server
where SSH is actually running, but can be another box.
HTH someone because the first time I ran into it, I found it confusing as well.
--
Kevin Powick