How make a SSH tunnel from one computer to another and forward its traffic

jbossport-forwardingssh-tunnel

I have two computers both running Linux. Let's call them computer A and computer B. Computer A has IP 192.168.1.10 and B has 192.168.1.11.

On computer B there is a JBoss 7 AS installed and its admin interface is just accessable locally (on http://127.0.0.1:9990) and I would like to access it from computer A.

Therfor I would like to SSH tunnel to computer B from computer A and forward all traffic to another port that is open on B, let's say I would forward incomming HTTP requests on port 8081 on B to 127.0.0.1:9990.

How can I establish such a tunnel from computer A to computer B?

I followed this guide but failed: http://www.revsys.com/writings/quicktips/ssh-tunnel.html

Best Answer

On computer A:

ssh -fCNL 8081:localhost:9990 username@192.168.1.11

Or reverse port forward from computer B (don't use both simultaneously):

ssh -fCNR 9990:localhost:8081 username@192.168.1.10

For understanding the options see man ssh