Last Updated: February 25, 2016
·
397
· klang

Reverse SSH Tunneling

Old tricks are the best tricks.

We have the situation, where a cvs server is not available from a development host, but the development host
is available from the cvs server:

       .-----.
       | PC  |
       .-----.
     /         \
    v           v
.-----.       .-----.
| cvs |------>| dev |
.-----.       .-----.

On the cvs machine, we start a cvs tunnel on localhost like this:

[CVSUSER@CVS wrk]$ ssh -nNT -R 2222:127.0.0.1:22 DEVUSER@DEVELOPMENT

and leave the tunnel running.

On the development system we add the following lines to ~/.ssh/config

Host CVS.full.domain
Hostname localhost
Port 2222
User CVSUSER

then we add the following line to ~/.bash_config

export CVSROOT=CVSUSER.full.domain:/cvsroot

and after that, we can interact with cvs as usual (as long as the tunnel is running)