Step-by-Step Guide to Secure Your Windows Server 2019/2022
1. Change Windows Password
- Log in to your Windows Server 2019/2022 via RDP.
- Press
Ctrl + Alt + End
on your keyboard. This will bring up the security options on the remote server. - Select "Change a password" from the options.
- Enter your current password in the "Old password" field.
- Enter your new password in the "New password" field.
- Re-enter your new password in the "Confirm password" field.
- Click the arrow button or press
Enter
to confirm the change.
2. Change RDP Port and Restrict Access
Change RDP Port
- Open the Registry Editor:
- Press
Win + R
, typeregedit
, and pressEnter
.
- Press
- Navigate to the following registry subkey:
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
- Find the "PortNumber" key:
- Double-click on "PortNumber".
- Select "Decimal" and change the value to your desired port number.
- Suggested Port Range: Use a port number between 49152 and 65535 to avoid conflicts with well-known services.
- Click "OK" and close the Registry Editor.
- Restart the server to apply the changes.
Important Warning
- Record the New RDP Port:
- Ensure you make a note of the new RDP port number. If you forget it, you will not be able to access the server remotely using RDP.
Restrict RDP Access to a Specific IP
- Open Windows Defender Firewall with Advanced Security:
- Press
Win + R
, typewf.msc
, and pressEnter
.
- Press
- Create a New Inbound Rule:
- Click on "Inbound Rules" in the left pane.
- Click "New Rule..." in the right pane.
- Select "Port" and click "Next".
- Choose "TCP" and specify the port number you set in the registry (e.g., 3390).
- Select "Allow the connection" and click "Next".
- Apply the rule to the appropriate profiles (Domain, Private, Public) and click "Next".
- Name your rule (e.g., "RDP Custom Port") and click "Finish".
- Edit the Rule to Restrict IP:
- Find your newly created rule in the list and double-click it.
- Go to the "Scope" tab.
- Under "Remote IP address", select "These IP addresses" and click "Add".
- Enter the specific IP address you want to allow and click "OK".
Format for RDP Connection
- When connecting via RDP, use the format
IP:Port
(e.g.,192.168.1.100:3390
).