I want to connection from local computer to another local computer. I have 3 machine. for example

A: -> in local windows machine
B:  -> linux server
C: -> in another local windows machine

(Machines A and B are not on same local network.)

I would like to connect using RDP or VNC from machine A to machine C. I wanted to find out whether I can connect from A to C over B. How can I do this?

I tried connecting with netcat, but without success.


Using ssh would be the easiest, enable the GatewayPorts and Forwarding features on the Linux ssh server, on host C run:(plink also works with the same command line)

ssh -R user@linux -N

And rdp to the Linux ip.

| improve this answer | |

This can be done - it requires running two netcat processes, one to connect B to C, the other to wait for a connection from A on B.

It's somewhat insecure - nc on B will accept a connection from anyone, but you'll still need your user credentials on B to connect, and you might need to supply them as C\username or DOMAIN\username rather than just username.

(Where A, B, C are the ip addresses or hostnames that will resolve)

ssh into B and then:

mkfifo fb
nc -4v C 3389 0<fb | nc -lk4v 3389 1>fb

I'm currently trying to do this where B and C are on a separate, non-routed private lan, but B is also accessible remotely via VPN from A. (ie, VPN puts me into a separate LAN that B is also on, via a second NIC).

Then, when this is sitting there running, it will probably say something like:

Connection to C 3389 port [tcp/udp] succeeded!

From A, you then run remote desktop connection, but point it at B (with credentials for C). When you connect, you'll see another line in your terminal:

Connection from A <some big port number> received!

At this point you will likely see a certificate error complaining that "The identity of the remote computer cannot be verified..." because the host names don't match -- proceed anyway.

This method seems to have issues -- after you disconnect, you have to go kill the nc process with a CTRL-C and restart it for a new connection, and this seems to take a couple of restarts before it works again -- if you get stuck waiting for 'configuring remote session' then you need to kill it and restart it again. This seems to always happen after you restart it after a session.

For some reason, this seemed to be working better when i was running it with a tmux on B -- this is good practise, as if the ssh connection from A to B gets broken, tmux will keep the two netcats running. Recall you can get back into the same tmux session by ssh back in, then running tmux a.

| improve this answer | |
  • Note you may need to VPN first from A into B's network, but this answer will work specifically if C is not accessible from A and vice-versa. It just requires you can somehow ssh and rdp to B from A, and that B can reach C, perhaps over a separate private / isolated LAN or VLAN connection. I am using this myself to work from home, in my case A and C are windows machines, and B is actually a freeBSD box, (which doesn't come with socat, but does have nc). C doesn't actually have an internet connection, but its on a separate LAN with B, which I can ssh into (it's a freeNAS fileserver). – RGD2 May 22 at 1:12

You need to somehow port forward your connection from B to C, in a way that you can access it from A (depending on how you are doing it, it can have negative security implications).

  • Assuming you can SSH into B, the easiest way I can think of to do this is by using an SSH remote port forward:

ssh -R<port>: <user>@ ( is arbitrary, ideally above 1024) (You can achieve the same with PuTTY)

Then aim mstsc to localhost: and you'll have your RDP connection to C via that port forward.

  • If you have the privileges on B, you could create a permanent port forward exposed to the Internet in such a way that connecting to B: would end up in C:3389. This could be done using iptables or nftables and setting up DNAT rules towards C. Mind you exposing RDP to the Internet is a bad idea, so I would recommend against this method;

  • If you don't have the privileges on B or you would prefer the tunnel to be temporary, you can use socat for the same purpose as above, whereby on B you setup a listening service exposed to the Internet (again a bad idea) and connect the other end to C:3389;

socat -v tcp-listen:<port>,reuseaddr,fork tcp4: ( is arbitrary) (you'll need to upen B's firewall to let in traffic into )

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.