我正在尝试使用 Windows 7 客户端尝试远程控制附加了弹性 IP 的 Windows Server 2012 EC2 实例。这是默认配置,因此 WinRM 服务应该已启动并运行,但为了更好地衡量,我还在服务器上运行了以下命令:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
set-item WSMan:\localhost\Client\TrustedHosts -Value * -Force
set-item WSMan:\localhost\Shell\MaxMemoryPerShellMB -Value 0 -Force
Enable-PSRemoting
在客户端上,我然后运行
$remoteUsername = "##########"
$remotePassword = "#######"
$remoteHostname = "00.000.000.00" #this is my elastic IP
$securePassword = ConvertTo-SecureString -AsPlainText -Force $remotePassword
$cred = New-Object System.Management.Automation.PSCredential $remoteUsername, $securePassword
test-WSman -computername "54.252.195.14"
但我回来的结果是
Connect-WSMan : The WinRM client cannot complete the operation within the time specified. Check if the machine name is valid and is reachable over the network and firewall exception for Windows Remote Management service is enabled.
At ***************.ps1:14 char:14
+ Connect-WSMan <<<< -Credential $cred $remoteHostname
+ CategoryInfo : InvalidOperation: (*********) [Connect-WSMan], InvalidOperationException
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.ConnectWSManCommand
然后我也尝试在客户端上运行以下代码,但这也没有帮助:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force
set-item WSMan:\localhost\Client\TrustedHosts -Value * -Force
set-item WSMan:\localhost\Shell\MaxMemoryPerShellMB -Value 0 -Force
Enable-PSRemoting
关于如何让 Windows AMI 在 EC2 上运行和自动化的信息并不多,有人能帮我找出这里的错误吗?客户端和服务器不在同一个域中,但我认为更改trustedhosts 可以远程连接吗?
更新
在遵循 Barak 的以下建议后,我能够在正确的端口上建立从服务器到自身的 telnet 连接,但仅在使用私有 IP 时,而不是在使用弹性 IP 时。
安全规则如下:
-1 icmp 0.0.0.0/0
22 tcp 0.0.0.0/0
443 tcp 0.0.0.0/0
3389 tcp 0.0.0.0/0
5985 tcp 0.0.0.0/0
5986 tcp 0.0.0.0/0
8888 tcp 0.0.0.0/0