본문 바로가기
security

원격데스크톱 포트 변경

by IT트레이서 2023. 8. 8.

상황

원격 데스크톱 포트 번호를 변경 해야 할 때

해결

파워쉘을 이용해서 기존 디폴트 포트인 3389에서 새로운 포트 9989로 변경한다.

# Set the new RDP port number
$NewPortNumber = 9989

# Update the RDP port in the Windows Registry
$RegPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp"
Set-ItemProperty -Path $RegPath -Name "PortNumber" -Value $NewPortNumber

# https://lifesoon.tistory.com/23
# Restart Remote Desktop Services
Restart-Service TermService -Force

# Configure Windows Firewall for the new port
New-NetFirewallRule -DisplayName "RDP Custom Port" -Direction Inbound -Protocol TCP -LocalPort $NewPortNumber -Action Allow