Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


ssh tunneling to a terminal services

Posted on 2003-12-11
Medium Priority
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
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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:

Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

LVL 40

Expert Comment

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


Accepted Solution

marko020397 earned 500 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.
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: http://www.rdesktop.org/

-- 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Curious about the latest ransomware attack? Check out our timeline of events surrounding the spread of this new virus along with tips on how to mitigate the damage.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
Video by: Tony
This video teaches viewers how to export a project from Adobe Premiere Pro and the various file types involved.
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

730 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