My RDP was locked

0

While I was building a defense system against brute force attacks and DDoS, I accidentally excluded RDP from the firewall while changing the RDP port, so I am unable to access RDP. You will need to allow RDP again in your firewall. What should I do.. It's Lightsail

asked 9 days ago109 views
2 Answers
6

*** To regain access to RDP on Lightsail after accidentally excluding it from the firewall while changing the port, follow these steps:***

1.Access Lightsail Console: Log in to the AWS Management Console and navigate to the Lightsail service.

2.Select Instance: Choose the Lightsail instance associated with the RDP access issue.

3.Connect via RDP: Access the instance via Remote Desktop Protocol (RDP) using the RDP client available on your local machine.

4.Edit Firewall Rules: Once connected to the instance via SSH, modify the firewall settings to allow RDP traffic. Use a text editor (such as nano or vi) to edit the firewall rules configuration file. Ensure that the rule allowing RDP traffic is correctly configured and enabled.

5.Restart Firewall Service: After saving the changes to the firewall rules configuration file, restart the firewall service to apply the new settings.

6.Verify Access: Confirm that RDP access has been restored by attempting to connect to the instance using the RDP client and the configured port.

7.Test Connectivity: Ensure that the instance is accessible via RDP from your local machine without any issues.

8.Review Security Configuration: Review the security configuration to prevent similar incidents in the future. Consider implementing best practices for managing firewall rules and changing port configurations securely. refer this document for PowerShell commands: - https://learn.microsoft.com/en-us/windows/security/operating-system-security/network-security/windows-firewall/configure-with-command-line?tabs=powershell

By following these steps, you should be able to restore RDP access to your Lightsail instance after accidentally excluding it from the firewall.

profile picture
answered 9 days ago
  • When RDP's been blocked, this step Connect via SSH: Access the instance via SSH using the browser-based SSH client available in the Lightsail console. won't work.

    Also that step should say RDP in place of SSH for a Windows instance.

1
Accepted Answer

Hi,

I am assuming you mean windows firewall and not Lightsail instance firewall (open ports on the instance's networking tab in Lightsail console)?

If so, you can create a new instance from a snapshot of your current instance while injecting some powershell commands into the new instance's launch script to re-open the RDP port in the Windows firewall.

For inspiration please refer this post - https://repost.aws/questions/QUytlu4EZgTjuiKhWPF_IE4w/change-rdp-port-in-lightsail-server-and-now-no-connection#ANQeMAvGfPS429t30QkT5RqQ

Powershell commands for windows firewall here - https://learn.microsoft.com/en-us/windows/security/operating-system-security/network-security/windows-firewall/configure-with-command-line?tabs=powershell

Thanks.

profile pictureAWS
EXPERT
AWS-SUM
answered 9 days ago
profile picture
EXPERT
reviewed 9 days ago
  • I think I change port from 3389 to 3712, how can i change this again orignal?

  • To change the port value to default 3389, there are example commands in that same post here - https://repost.aws/questions/QUytlu4EZgTjuiKhWPF_IE4w/change-rdp-port-in-lightsail-server-and-now-no-connection#ANfPxI0oWDT3eJaEh3lUKuzw

    <powershell>
    Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\" -Name PortNumber -Value 3389
    </powershell>
    <persist>true</persist>
    
  • Can you help me with discord..?

  • No Sorry, I am not on discord. I see your third post here https://repost.aws/questions/QUsrFkHi7YQbCz4vZRiZctUg/my-rdp-was-locked-by-firewall, but will need some time to test out your steps and exact commands needed. If I manage to figure them out, I will post back.

  • This should be it.


    <powershell>
    $portvalue = 3389
    
    Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue
    
    Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0
    
    Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
    </powershell>
    <persist>true</persist>
    

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions