The default port for Remote Desktop Protocol (RDP), TCP 3389, is a frequent target for automated attacks. To enhance the security of your Windows instance, you can change this default port to a non-standard one. This reduces the risk of discovery by malicious scanning tools.
Procedure
Step 1: Configure the new port in the security group
Go to ECS console - Instances. Click the target instance's ID.
On the instance details page, select the Security Groups tab and click the security group ID.
Add an inbound rule to allow traffic on the new port. Allow both TCP and UDP to support the UDP acceleration feature in recent RDP versions.
Keep the existing rule for port 3389 for now. After you verify the connection on the new port, you can delete the rule for port 3389.
Using Workbench to connect to port 13389 as an example.
Protocol
Destination
Authorization Object
TCP13389/1338947.96.60.0/24
118.31.243.0/24
8.139.112.0/24
8.139.99.192/26
UDP13389/13389
Step 2: Modify the registry to change the RDP port
Log on to the ECS instance.
Go to ECS console - Instance. In the top navigation bar, select the target region and resource group.
Go to the details page of the target instance, click Connect, and select Workbench. Set the connection method to Terminal, enter the username and password, and then log on to the graphical terminal page.
Choose a new port.
Choose an unused port in the
10000-65535range. In PowerShell, run the commandnetstat -ano | findstr :<port_number>to verify that the port is available.Modify the registry.
In the taskbar search box, type
regeditand open the Registry Editor.In the left navigation pane, expand . In the right pane, locate and double-click PortNumber.
Select Decimal under Base, and enter the new port number in the Value data field.
Step 3: Apply the configuration and verify the connection
Go to the details page of the target instance and click Restart. After the instance restarts, click Connect and select Workbench.
In the Instance Login window, select Terminal. Click More Options and enter the new port number in the Port field.
ImportantAfter changing the default RDP port, you must specify the new port each time you connect.