Skip to content
VDS · Windows Server

RDP protection: port, passwords, restrictions

How to protect remote desktop from brute-force: an allowlist of addresses, changing the port, account lockout, and checking the login log.

Updated August 23, 2026

Automated scanners find port 3389 exposed to the internet within hours. Then comes password brute-forcing against the Administrator account — the most common way to lose a Windows machine. Protection is built from several simple layers.

Layer one: who can connect

The most effective approach is to allow only your own addresses to RDP. In Windows Firewall, the default rule allows 3389 for everyone; replace it.

Set-NetFirewallRule -DisplayGroup "Remote Desktop" -RemoteAddress 203.0.113.5,198.51.100.0/24

To check the result:

Get-NetFirewallRule -DisplayGroup "Remote Desktop" | Get-NetFirewallAddressFilter

If you have a dynamic home address, an option is to leave access from a single auxiliary node or set up a VPN and close RDP completely. There is always an emergency way in if you make a mistake in the rule: the “Console” tab in the panel /hosting/vds/m/<id>, “Screen” mode.

Layer two: accounts and passwords

  • Change the password issued at creation and make it long — at least 16 characters.
  • Create a separate account for yourself in the “Remote Desktop Users” group, and rename the built-in Administrator: Rename-LocalUser -Name Administrator -NewName adm-local. Half of all brute-force attempts target the Administrator name.
  • Enable lockout after failed attempts:
net accounts /lockoutthreshold:5 /lockoutduration:30 /lockoutwindow:30
  • Check that NLA is enabled — authentication before session creation:
Set-ItemProperty "HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name UserAuthentication -Value 1

Layer three: port and monitoring

Changing the port is not protection, but it cuts off mass scanners and cleans up the log:

Set-ItemProperty "HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name PortNumber -Value 34567
New-NetFirewallRule -DisplayName "RDP custom" -Direction Inbound -Protocol TCP -LocalPort 34567 -Action Allow -RemoteAddress 203.0.113.5
Restart-Service TermService -Force

After that, connect to ADDRESS:34567. Disable the old rule for 3389.

Watch who is knocking at your door:

Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625} -MaxEvents 20 |
  Select-Object TimeCreated, @{n='User';e={$_.Properties[5].Value}}, @{n='IP';e={$_.Properties[19].Value}}

Event 4625 is a failed login, 4624 is a successful one. A steady stream of 4625 events from foreign addresses means you never enabled the address filter.

Common mistakes

  • Relying only on changing the port. A scanner will find RDP on any port within a day; the allowlist is what actually helps.
  • Disabling NLA for compatibility with an old client. Then anyone can reach the login screen and load the machine.
  • Forgetting about other users. Check who is allowed to log in: Get-LocalGroupMember "Remote Desktop Users".
  • Locking yourself out and panicking. The console in the panel always works, and if the rule broke everything, the recovery disk will help.

Accounts, rights and groups are covered in more detail in the article Users and rights in Windows Server, and general filter setup is in Windows Firewall.