Ssh port forwarding from remote location to computers on server’s network

port-forwardingsshunix

I've been hunting all over the inter webs and I cannot find a simple example of the form of port forwarding that I am looking for. Well, the truth is, I may have just simply not understood the jargon used and then overlooked a valid solution.

Here is the proposed setup. I have a computer at home (homeC) and I typically connect to a server at work (workServer.com), but whenever I connect to the server, I am generally (90%+ of the time) simply hopping over to another computer on the network (localC 192.168.x.y). I would love to setup workServer.com to port forward over to the other local computers ip addresses if I use a non-standard port (e.g. 12345).

Assume all computers involved are running some variant to unix, but that the user only has root access on some computers (not workServer.com). In fact, the username user is the same on all computers. I am trying to find ways to solve the following problems:

  1. a command to use in workingServer.com which will forward a port to a given local computer (I also need to know which ports are available, I suppose)
  2. the command to run on homeC to connect to localC

On a side note, it would be interesting if it were possible to limit the mac-addresses of computers that can connect to user@workingServer.com because I see this as greatly increasing my security.

If you have any other ideas or useful suggestions, I would greatly appreciate them.

Best Answer

Tunneling would be the appropriate term if you are connecting with SSH.

putty.exe -ssh username@publicip -pw password -L localport:privateip:destinationport

so as an example, if I were to tunnel through SSH to port 80 on a computer with address 192.168.1.15 behind a public IP address of xxx.xxx.xxx.xxx, on which the SSH server resides, I would do the following:

putty.exe -ssh username@xxx.xxx.xxx.xxx -pw password -L 8080:192.168.1.15:80

I could then open up a web browser to 127.0.0.1:8080 and up would pop whatever is being served on port 80 on the remote machine.

Related Question