我正尝试使用Windows 7客户端尝试远程控制附加弹性IP的Windows Server 2012 EC2实例。这是默认的配置,所以WinRM的服务应该是启动和运行,但良好的措施,我也在服务器上运行以下命令:Powershell远程处理:无法连接到Windows 2012 EC2实例
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上运行和自动化,没有太多的信息,任何人都可以帮我找出错误吗?客户端和服务器不在同一个域中,但我认为更改受信任主机可以使远程连接成为可能吗?
UPDATE
低于以下巴拉克的意见后,我能够建立一个从服务器的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
我按照这里的说明,如果这是任何帮助:http://stackoverflow.com/questions/10237083/how-to-programmatically-remotely-execute-a-program-in-ec2-windows-instance/13284313 – analystic
您确定WinRM端口(5985)在您的EC2安全组和Windows防火墙规则中是否已打开? –
我确定它是在EC2安全组上打开的,因为它是5986(对于HTTPS)。我已经在服务器上运行了Enable-PSRemoting命令,并且我记得它说明已经创建了防火墙异常。即使我完全禁用了我的客户端上的所有防火墙,我仍然遇到同样的问题。 – analystic