ssh tunneling to a terminal services

Posted on 2003-12-11
Last Modified: 2013-11-15

I've been trying to ssh tunnel to connect to a machine via terminal services without success.

This is my setup,

From home i'm able to ssh tunnel to a machine at my work network and forward port 80 to my machine at home with no problem.  But now i need to do this for terminal services.

I use cygwin to ssh to a linux server in my network then when i try to forward port 3389 to the terminal service machine and it fails.

on the Linux server i use the following command   ssh -L 3389:localhost:3389  user@linuxserver

Another thing is also that i would have to somehow use a gui so that i can launch the terminal services screen so i've compiled cygwin with xfree86.

Basically i just want to get some suggestions on what would be the correct path for me to do this.


Question by:m3m0
  • 3
  • 2
  • 2
  • +2
LVL 40

Expert Comment

ID: 9920564
Whew!  You might want to put this into the Linux area if you don't get help here.  Certainly out of my boundary.  Just a thought in case you don't get help, but there are some real good experts here who might join in.


Author Comment

ID: 9920660
Great thank you.
LVL 38

Expert Comment

ID: 9925434
"i would have to somehow use a gui so that i can launch the terminal services screen so i've compiled cygwin with xfree86."

All you need to do is to enable X forward at both client and server for your secure

have a look at the following pages about how:

LVL 40

Expert Comment

ID: 9925592
That is what we needed, a Unix Master!  :)


Accepted Solution

marko020397 earned 125 total points
ID: 9926394
I am using this ssh tunneling for a long time now for terminal services and it works great.

You are not specific in your question how exactly you would like to connect. Let's
asume you are running ssh on some Windows machine in network "one". You want
to connect to another Windows machin in network "two" where you also have a Linux

1. I think the ssh command you are using is wrong. It should be:
   ssh -L 3386:win_server_on_nwetork_two:3389  user@linuxserver
  That way you are connecting to Linux server and make a tunnel to Windows machine.
  As you can see I have changed the first port number. We'll get to that later.

2. Now you have the tunnel from your Windows machine on network one to Linux server.
  That tunnel opens (ends) on Linux server and goes on port 3389 to Windows machine.

3. Now you have to run your Terminal Services Client and connect to localhost on port 3386.
   You may have your own Terminal Services Server on the machine you are connecting
   from. If you use 3389 on both sides of ssh it will conflict with the Terminal Server running
   on machine when ssh is running.

Now a few tricks. How can you connect to localhost:3386.

Windows 2000 and older:
You have to set your terminal services connection to connect to localhost. Then save it and
open the saved file with notepad and change the port to 3386.

Windows XP, 2003:
Windows XP and 2003 do not allow connections to localhost. You need to copy two files
from \Windows\System32 directory to another location. The files are mstsc.exe and
mstscax.dll. Open properties for mstsc.exe on new location and set Windows 98 compatibility
mode. Now you can connect to localhost:3386. You don't have to save the connection in
XP and 2003 you can just specify port along with location. (localhost:3386).

I hope this will help you. If you have any more questions just ask.
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

LVL 38

Expert Comment

ID: 9927936
X tunneling also works between *nix and secure shell client for Windows,
(please remember to enable X11 tunneling in your windows ssh client).

If you setup X tunneling properly, the ssh can automatically setup the DISPLAY
value for you. and you can run you GUI app (including your terminal services,
inside the ssh connetion).
LVL 20

Expert Comment

ID: 9929539
Yes, I think Greg(yuzh) is on to an alternative to markos suggestion here. Instead of going through the hassle of setting up RDP forwarding via the linux box, be sure to install rdesktop on the linux machine, start XWin (at home), ssh -X (to work/linux), rdesktop terminal server....:-)

Slightly cumbersome any way you turn it:-).

-- Glenn
LVL 20

Expert Comment

ID: 9929554
rdesktop homepage:

-- Glenn

Author Comment

ID: 9957673
Damm all you guys Rock!  I wish i could you all points for just looking at my question :-)  

In any case I was more confortable with Markos suggestion which worked.  BUt i''ll try the rest as well.  So I'll be awarding points to Markos.

Again, I aprecieate all the help and comments.


LVL 40

Expert Comment

ID: 9957714
Speaking for everyone here, am glad we could be of service.  BTW:  your company hiring?  :)  Just kidding.

Have a Happy Holiday Season.


Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Remove a folder in Linux 9 89
mcrypt_create_iv() is deprecated 4 67
Setting up static IP - Ubuntu server 16.04 12 16
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
Skype is a P2P (Peer to Peer) instant messaging and VOIP (Voice over IP) service – as well as a whole lot more.
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

1 Experts available now in Live!

Get 1:1 Help Now