edit-icon download-icon

Modify the default remote access port

Last Updated: Mar 06, 2018

Modify the default remote desktop port of a Windows instance

The default remote desktop port of a Windows instance is TCP Port 3389. You can follow these steps to modify the port:

  1. Connect to the Windows instance.

  2. Select Start > All Programs > Accessories > Run to open the Run dialog box, and run regedit.exe to open Registry Editor.

  3. On the left-side navigation pane of the Registry Editor, find HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp, and then double click PortNumber.

  4. In the Eidt DWORD (32-bit) Value dialog box, select Decimal as Base, and then type a number in the Value data field as the new remote port number, which is 3399 in this example. Click OK.

  5. If you have enabled firewall, open the new port on the firewall.

  6. Log on to the ECS console, find the instance, and then select More > Restart.

  7. After the instance is restarted, click the instance ID to go to the Instance Details page, and then click Security Groups.

  8. Add a new security group rule to allow access to the new remote port. For more information about adding security group rules, see Add a security group rule.

  9. Connect to the instance by accessing the IP address ending with the new port number. For example, 192.168.1.2:3399 in this example.

    Note: Only the default port 3389 can be used for access by Mac remote desktop users.

Modify the default SSH port of a Linux instance

For a Linux instance, the default SSH port is 22. This section describes how to modify the SSH port of a Linux instance running CentOS 6.8.

  1. Connect to the Linux instance.

  2. Run vim /etc/ssh/sshd_config to edit the file:

    1. Press the i key on the keyboard to enter the Edit mode.
    2. Add Port [new port number] (For example, Port 1022) under the line Port 22.
    3. Press the Esc key, and then type :wq to save and exit the file.
  3. Run the following command to restart the sshd.

    1. /etc/init.d/sshd restart
  4. Configure firewall to open the new port for Internet access.

  5. Log on to the ECS console, find the instance, and then select More > Restart.

  6. After the instance is restarted, click the instance ID to go to the Instance Details page, and then click Security Groups.

  7. Add a new security group rule to allow access to the new remote port. For more information about adding security group rules, see Add a security group rule.

  8. Connect to the instance by accessing the IP address ending with the new port number. For example, 192.168.1.2:1022 in this example.

  9. Run vim /etc/ssh/sshd_config again to delete the Port 22 line.

  10. Run /etc/init.d/sshd restart to restart sshd.

    Note: We recommend that you do not modify the Port 22 line directly. Then if you cannot connect to the Linux instance on the new port, you can use Port 22 for debugging.

Thank you! We've received your feedback.