ssh portforwarding, running test client/server over tunnel

Cameron Simpson cs at zip.com.au
Sat Sep 14 08:26:41 UTC 2013


On 13Sep2013 19:58, bruce <badouglas at gmail.com> wrote:
| Trying to setup a quick test to create a ssh tunnel between A and B,
| and running a test nc server over the ssh connection on port 7100..
| 
| As far as I can tell, it should be a matter of setting up the port
| forwarding between A and B and then running the test server/client on
| the A and B machines..
| 
| now, the tricky part, the target "B" machine is being run on a VM, so
| the port isn't 22..
| 
| I used the following to setup the port forwarding:
| 
| ssh -L  7100:74.142.196.218:7100  user at 74.142.196.218 -p 50122
|
| so being on machine A, the local machine, I setup the ssh tunnel into
| machine B, where B is the VM, running ssh over port 50122

Please try to keep options to the _left_ of the non-options. I refer
here to your "-p 50122".

| this part appears to work.

Yes, but it forwards 127.0.0.1:7100 on machine A to 74.142.196.218:7100.

And...

| However, when I then run a test nc server on both machines using port
| 7100, I get the following:
| 
| machine B:
| nc -l 7100

Ok. On machine B (the VM?) run:

  netstat -an | grep 7100

What does it show? And what does:

  ifconfig -a

show machine B has as its interface addresses?

Remember that the port forward at the remote end is running on machine B.

| machine A
| nc localhost 7100
| 
| which causes the machine B to display a crash!!!!
| >>>channel 3: open failed: connect failed: Connection refused <<<

This is not a crash, just an error message. This just says that
machine B is not listening on 74.142.196.218:7100.

I think you have a machine C (the VM host) that runs the VM guest "B".
And that C's IP address is 74.142.196.218.

Machine B will not have the address 74.142.196.218.

Since "nc -l 7100" on a machine here listens on "*" (all interfaces,
no specific address), I would just connect to 127.0.0.1 on machine B:

  ssh -L  7100:127.0.0.1:7100  user at 74.142.196.218 -p 50122

Cheers,
-- 
Cameron Simpson <cs at zip.com.au>

I am a man of high calibre; that is to say, a large bore.
        - Jef Poskanzer <jef at netcom.com> <jef at well.sf.ca.us>


More information about the users mailing list