一、什么是 WinRM
WinRM 是很早之前微软推出的一种新式的方便远程管理的服务。WinRM 是 Windows Remote Management 的简写,相比 RDP(远程桌面协议),WinRM 这种服务更具备轻量、低带宽的特性,WinRM 与 WinRS(Windows Remote Shell)一起使用可以让远程连接的运维人员拥有 CMD Shell 环境,通过执行命令对服务器与服务器上的数据进行管理。
在开启该服务时,防火墙默认放行 5985 端口。WinRM 服务默认端口:5985(HTTP)与 5986(HTTPS)。
二、WinRM 远程连接操作
在受控端主机(192.168.64.132)上配置:
winrm quickconfig # 快速配置 WinRM 服务
winrm s[et] winrm/config/client @{TrustedHosts="192.168.64.131[,ip_address]..."} # 信任操控端主机
在操控端主机(192.168.64.131)上配置:
winrm quickconfig # 快速配置 WinRM 服务
winrm s[et] winrm/config/client @{TrustedHosts="192.168.64.132"} # 信任受控端主机
测试是否可以使用命令操作(在操控主机下进行):
winrs -r:http://192.168.64.132 -u:[username] -p:[password] [command] # 执行命令
获取信息:
winrm get winrm/config/client
三、WinRM 端口复用
winrm e[numerate] winrm/config/listener # 查看 WinRM 服务监听端口的信息
winrm s[et] winrm/config/service @{EnableCompatibilityHttpListener="true"} # 新增监听 80 端口(端口复用)
winrm s[et] winrm/config/listener?Address=*+Transport=HTTP @{Port="80"} # 修改 WinRM 服务默认端口为 80 端口
四、在公用网络使用 WinRM
在控制面板的 Windows 防火墙中点击左侧的高级设置,然后新建入站规则,然后选择预定义,在下拉列表中选择 Windows 远程管理,在下一页中勾选所有的配置文件为公用的项,然后选择允许连接。
参考资料:
https://forum.butian.net/index.php/share/2080
https://www.php1.cn/detail/YiWenDaJin_Linux_0c15feb5.html
https://support.huawei.com/enterprise/zh/doc/EDOC1100296027/734f2c0
本文由 oaoa 发表,最后编辑时间为:2023-09-17 01:50