Remote Desktop On A Non-Standard Port

For a project I’m working on, we have an automated build server running CruiseControl.NET hosted in a virtual machine.  We do the same thing for Subtext

Some of you may have multiple virtual servers running on the same machine.  Typically in such a setup (at least typically for me), each virtual server won’t have its own public IP Address, instead sharing the public IP of the host computer.

This makes it a tad bit difficult to manage the virtual servers since using Remote Desktop to connect to the public IP will connect to the host computer and not the virtual machine.  The same thing applies to multiple real computers behind a firewall.

One solution (and the one I use) is set up each virtual server to run Terminal Services, but each one listens on a different port.  Then set up port-forwarding on your firewall to forward requests for the respective ports to the correct virtual machine.

Configuring the Server

The setting for the Terminal Services port lives in the following registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TerminalServer\WinStations\RDP-Tcp

Open up Regedit, find this key, and look for the the PortNumber value.

PortNumber Setting

Double click on the PortNumber setting and enter in the port number you wish to use. Unless you think in hex (pat yourself on the back if you do), you might want to click on decimal before entering your new port number.

Port Number Value Dialog

Or, you can use my creatively named VelocIT Terminal Services Port Changer application, which is available with source.  This is a simple five minute application that does one thing and one thing only. It allows you to change the port number that Terminal Services listens on.

VelocIT Terminal Services Port Changer

Remember, all the usual caveats apply about tinkering with the registry. You do so at your own risk.

Connecting via Remote Desktop to the non-standard Port

Now that you have the server all set up, you need to connect to it.  This is pretty easy.  Suppose you change the port for the virtual machine to listen in on port 3900.  You simply append 3900 to the server name (or IP) when connecting via Remote Desktop.

Remote Desktop

Keep In Mind

Keep in mind that the user you attempt to connect with must have the logon interactively right as well as permissions to logon to the terminal services session.  For more on that, check out this extremely helpful article with its trouble shooting section.

That’s pretty easy, no?  Now you should have no problem managing your legions of virtual servers.

Related Posts:

What others have said

Requesting Gravatar... Robb Allen Oct 17, 2006 2:30 PM
# Re: Remote Desktop On A Non-Standard Port
That's pretty much what I do. Then again, I'm a non-standard port freak. Mostly so work has a harder time blocking me from goofing off...
Requesting Gravatar... Christopher Steen Oct 19, 2006 2:45 AM
# Link Listing - October 18, 2006
Remote Desktop On A Non-Standard Port [Via: Haacked ] Why Oh Why Couldn't WebPermission Be Part Of Medium...
Requesting Gravatar... Community Blogs Oct 23, 2006 3:01 AM
# Mapping Drives Via Remote Desktop
Here’s a little trick that I didn't know about till Steve told me about it. So that’s what those other
Requesting Gravatar... DotNetKicks.com Oct 23, 2006 10:19 PM
# Remote Desktop On A Non-Standard Port
You've been kicked (a good thing) - Trackback from DotNetKicks.com
# Remote Desktop auf einen anderen Port laufen lassen
Requesting Gravatar... Kevin Castle .Net Nov 03, 2006 8:33 AM
# Setting a different Remote Desktop Port Number
Requesting Gravatar... David Jones May 08, 2007 11:02 AM
# re: Remote Desktop On A Non-Standard Port
How can you use remote desktop over a non-standard port with TSWEB?
Surely the ActiveX control will always want to push traffic over 3389?
thanks.
Requesting Gravatar... Haacked May 08, 2007 11:10 AM
# re: Remote Desktop On A Non-Standard Port
Good question. Never tried it.
Requesting Gravatar... Scott May 21, 2007 6:01 PM
# re: Remote Desktop On A Non-Standard Port
For all of those TSWeb users here is how you modify TS web HTML to use a different port.

Remember you must have already configured remote desktop to listen on the port you want.

http://support.microsoft.com/kb/326945

Requesting Gravatar... Brett Aug 14, 2007 2:27 PM
# re: Remote Desktop On A Non-Standard Port
Very good - now I can access my desktop from my educational institute. Needed to work out what port to open on my router, and now I know.

Keep up the good work!
Requesting Gravatar... Jon Sep 19, 2007 5:33 AM
# re: Remote Desktop On A Non-Standard Port
Or you could just assign differnt ports in your firewall to the IP of the computer with Remote Desktop that you want to access and leave port 3389 at that computer. Works great for me, because I have multiple computers to access via RD, so I assign different ports in my firewall routing to 3389 on the computers IP I want to access. That way I can still access the RD from my main computer at home to all machines normally, and never have to touch the registry.

IE:
ExternalIP:5900 > 192.138.0.5:3389
ExternalIP:5901 > 192.138.0.6:3389
ExternalIP:5902 > 192.138.0.7:3389
etc.

Providing Your firewall is capable of this task, which I think most are.

I tried the other way at frist, and it worked aswell, but this just makes more sense and is alot easier ;)
Requesting Gravatar... Ketan Patel Mar 31, 2008 6:52 AM
# re: Remote Desktop On A Non-Standard Port
I use a Dlink ADSL Router GLB 502T, this router has options to specify the port from, port to and port map, but it doesnt work.

When i specify router port xxxx (not 3389) to be mapped to Termianl server port 3389, the router accepts the values, but rejects the incoming traffic.

So i guess my only option is to change the RDP port on the Terminal server and then work it out. I havent tried this yet, but this should atleast work.
Requesting Gravatar... victorantos Jul 26, 2008 12:07 AM
# re: Remote Desktop On A Non-Standard Port
How to configure Routing and remote access from win 2003 to use my new port?
Requesting Gravatar... south of france holiday villa Oct 29, 2008 11:12 AM
# re: Remote Desktop On A Non-Standard Port
doesnt work on windows 2server 008 !!even though registry settings are present etc
Requesting Gravatar... Robert Parker Oct 30, 2008 6:33 AM
# re: Remote Desktop On A Non-Standard Port
i tried to d/l your program "VelocIT Terminal Services Port Changer" but your server asks for a log in... Is there another plase to get it???

Thanx
Requesting Gravatar... international removals Nov 06, 2008 6:30 AM
# re: Remote Desktop On A Non-Standard Port
excellent now I can access my desktop from my workplace as they ban the default port.

Keep up the good work
Requesting Gravatar... Guy Jan 28, 2009 4:41 AM
# re: Remote Desktop On A Non-Standard Port
Desperately lookinf for VelocIT Terminal Services Port Changer,
can some bail me out.....thanx
Requesting Gravatar... MOHAMMED ANWAR Mar 19, 2009 12:44 AM
# re: Remote Desktop On A Non-Standard Port
I had done through terminal service .Dydns service.is there any other method to access remotely through windows service.
Requesting Gravatar... MOHAMMED ANWAR Mar 19, 2009 12:45 AM
# re: Remote Desktop On A Non-Standard Port
I have normal adsl router
Requesting Gravatar... Sandi Jul 01, 2009 3:04 PM
# re: Remote Desktop On A Non-Standard Port
net to change the RDP port on several thousand pcs. Do you have instructions for using Group Policy to change the registry entry?

What do you have to say?

(will show your gravatar)
Please add 2 and 5 and type the answer here: