All Products
Search
Document Center

How do I view and modify the default port of a remote desktop for a Windows instance?

Last Updated: Sep 21, 2020

Disclaimer: This article may contain information about third-party products. Such information is for reference only. Alibaba Cloud does not make any guarantee, express or implied, with respect to the performance and reliability of third-party products, as well as potential impacts of operations on the products.

 

Overview

This topic describes how to view and modify the default port of the remote desktop of a Windows instance.

 

Description

The default port for the remote desktop of a Windows instance in the ECS instance is 3389. For security reasons, some users may need to modify the default port to reduce the number of malicious attacks and scans ECS instances through the remote desktop, this article describes how to view and modify the default port of the remote desktop of a Windows instance. Before performing this operation, read the following precautions.

  • Before modifying the registry, you must fully understand the operating mechanism of the Windows system to avoid incorrect operations.
  • To avoid data loss, see the following document to create snapshots of the system disk and data disk of the instance before modifying the registry.

 

For more information about how to view and modify the default remote desktop port of a Windows instance, see the following section.

 

View the remote desktop port of ECS Windows

You can use one of the following methods to view the remote desktop port of ECS Windows.

 

Method 1

  1. Refer to the following documents to remotely connect to and log on to the Windows instance.
  1. SelectStart > Run, InputCmdTo open the command line window.
  1. Run the following command to view the information:
    tasklist /svc | find "Ter"
    The command output is as follows. In this exampleTermServicePID is 1592.

  1. Run the following command to viewTermServiceThe port used.
    netstat -ano | find "1592"
    A similar output is displayed. In this example, the port number is 3389.

 

Method 2

  1. Refer to the following documents to remotely connect to and log on to the Windows instance.
  1. SelectStart > Run, InputRegeditTo open the registry editor.
  1. SearchHKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Terminal Server \ Wds \ rdpwd \ Tds \ tcp, And then searchPortNumberAs shown in the following figure.

  1. SearchHKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Terminal Server \ WinStations \ RDP-Tcp, Check and findPortnumberIs generally the samePortNumberThe two sub-key values are the same, that is, the remote service port.

 

Method 3

  1. Refer to the following documents to remotely connect to and log on to the Windows instance.
  1. SelectStart > Run, InputCmdOpen the command line window.
  2. Run the following command to return the items under the sub-item of the registry and the list of the sub-items at the next level.
    reg query "hklm\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds" /s
    The command output is as follows. In this examplePortNumberIs 0xd3d, which is equivalent to 3389 of the decimal system.

  3. Run the following command to viewPortNumberValue.
    reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v portnumber

 

Modify the remote desktop port of ECS Windows

You can modify the default port of a Windows instance on a remote desktop as follows.

  1. Refer to the following documents to remotely connect to and log on to the Windows instance.
  1. SelectStart > Run, InputRegeditTo open the registry editor.
  1. SearchHKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ TerminalServer \ Wds \ rdpwd \ Tds \ tcp, And then searchPortNumberThe sub-key value. Change the value to the port you need.

  1. SearchHKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ TerminalServer \ WinStations \ RDP-Tcp, And then searchPortNumberThe sub-key value. Change the value to the port you need.

 

The following describes how to modify the default remote desktop port of an ECS Windows instance.

  • Restart the ECS instance to apply the configurations.

 

Application scope

  • ECS