技术支持

为您提供7*24小时在线技术支持、安全技术专家、行业资深安全顾问服务。400-888-1688

系统安全相关

您当前位置首页 > 技术支持 > 系统安全相关

Windows Server 2012R2远程桌面(RDP)安全配置与加固

远程桌面(RDP)是Windows服务器最常用的远程管理方式,但默认的3389端口也使其成为攻击者的主要目标。本文介绍Windows Server 2012R2下RDP的安全配置。

一、修改默认RDP端口

code
code
code
# 修改注册表
# HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
# 修改 PortNumber 为十进制新端口号(如33389)

# PowerShell修改
$port = 33389
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "PortNumber" -Value $port

# 防火墙放行
New-NetFirewallRule -DisplayName "RDP Custom Port" -Direction Inbound -Protocol TCP -LocalPort $port -Action Allow

# 重启生效
Restart-Computer

二、启用网络级认证(NLA)

code
code
code
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -Value 1

三、IP白名单限制

code
code
code
Remove-NetFirewallRule -DisplayName "RDP Custom Port"
New-NetFirewallRule -DisplayName "RDP - Office" -Direction Inbound -Protocol TCP -LocalPort 33389 -RemoteAddress "203.0.113.0/24" -Action Allow

四、推荐配置清单

  • 修改默认3389端口为自定义端口
  • 启用网络级认证(NLA)
  • 限制远程登录用户
  • 配置IP白名单
  • 设置空闲会话超时15分钟
  • 启用登录事件审核

五、RDP会话管理

code
code
code
# 配置RDP会话超时策略
# 组策略 > 计算机配置 > 管理模板 > Windows组件 >
# 远程桌面服务 > 远程桌面会话主机 > 会话时间限制

# 活动但空闲的会话限制:15分钟
# 活动但空闲的会话限制间隔:15分钟
# 达到会话限制或连接时结束会话:已启用
# 结束已断开的会话:5分钟

# 通过PowerShell设置
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "MaxIdleTime" -Value 900000

# 设置断开连接的会话自动注销
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "fResetBroken" -Value 1

六、RDP网关和跳板机

code
code
code
# 使用RD Gateway作为跳板
# 安装RD网关角色
Install-WindowsFeature -Name RDS-Gateway -IncludeManagementTools

# 配置RD网关策略,要求用户通过网关连接
# 这样RDP流量不会直接暴露在公网

# 或使用SSH隧道转发RDP
# Linux/Mac客户端:
# ssh -L 33389:内部服务器IP:33389 跳板机IP
# 然后连接 localhost:33389

七、RDP登录审计

code
code
code
# 查看RDP登录历史
Get-WinEvent -FilterHashtable @{LogName='Security'; ID=4624,4625} | 
    Where-Object { $_.Message -match "Remote" } |
    Select-Object TimeCreated, 
        @{N='User';E={$_.Properties[5].Value}},
        @{N='IP';E={$_.Properties[18].Value}},
        @{N='Status';E={if($_.Id -eq 4624){"Success"}else{"Failed"}}} |
    Format-Table -AutoSize

# 创建计划任务,每日发送RDP登录报告
$Action = New-ScheduledTaskAction -Execute "PowerShell.exe" -Argument "Get-WinEvent ... | Export-CSV rdp_report.csv"
$Trigger = New-ScheduledTaskTrigger -Daily -At 09:00
Register-ScheduledTask -TaskName "RDP Audit Report" -Action $Action -Trigger $Trigger
这条帮助是否解决了您的问题? 已解决 未解决

安全合格的云服务,让您的业务轻松上云!

立即选购
https://affim.baidu.com/unique_50626027/chat?siteId=21806899&userId=50626027&siteToken=f4b13c0dda3b403b51fd8811d5a360c7