SSH trickery using -R

Dan Trainor info at
Wed Jun 29 22:27:56 UTC 2005

Hello, all -

Reading through ssh's man page, I found the -L and -R switches.  I've
used -L before, but not -R.  -R looks... very interesting.

So what I'd like to be able to establish is a connection to a machine
which is behind a NAT and, well, a whole bunch of network goodies, which
makes it not possible to connect directly to this machine from the

>From what I understand by reading the man page, is that I can make an
ssh connection to a remote machine, using the -R switch, which opens a
port on the remote machine, which is then redirected to the local
machine, on a port of my choosing.

So naturally, I'd like to do something like this - from the client:

ssh -l username -R 22:localhost:10002 remotehost

I am able to log in to remotehost.  I've even used root as the username
just for kicks, but I am then presented with the following error regardless:

Warning:  remote port forwarding failed for listen on port 22

What I can make of this is, I believe, a conflict with sshd.  I would
want the connection to be made TO the local port 22.

Am I understanding the manpage wrong?  Is my syntax wrong?  What's the deal?


More information about the users mailing list