我想远程访问EC2机器来获取一些使用C#的信息。 我写了如下代码:
ConnectionOptions options = new ConnectionOptions { Username = serverspace.ServerIP + @"\xxxxxx", Password = "xxxxxxx", Impersonation = ImpersonationLevel.Impersonate, EnablePrivileges = true }; ManagementScope scope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", serverspace.ServerIP), options); scope.Connect();
但是引发了一个RPCexception,如下所示: – RPC服务器不可用。 System.Management.ManagementScope.Initialize()System.Management.ManagementScope.InitializeGuts(Object o)System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode,IntPtr errorInfo)上的(从HRESULTexception:0x800706BA)
1-代码中的问题? 2-我需要调整所有机器防火墙中的任何东西吗?
RPC防火墙端口logging在这里:
Windows的服务概述和networking端口要求
– 远程过程调用(RPC):
http://support.microsoft.com/kb/832017#method39
System service name: RpcSs Application protocol Protocol Ports RPC TCP 135 RPC over HTTPS TCP 593 NetBIOS Datagram Service UDP 138 NetBIOS Name Resolution UDP 137 NetBIOS Session Service TCP 139 SMB TCP 445
此外,您需要“高端口”范围49152到65535。