wul*_*lxz 59 powershell remoting powershell-remoting
我在Server 2008 R2上成功启用了PSRemoting.我可以使用主机名作为目标在同一网络中进行远程pssession.
当我尝试从任何计算机(在网络内或从其他网络(例如通过VPN))使用IP地址作为目标时,我失败了.我希望能够通过我的VPN连接使用远程处理,因为无法解析主机名,因此我必须使用IP地址.
我不想在我的hosts文件中添加名称,因为我们的客户端上有一些其他服务器具有相同的dns-name,我不想删除并再次插入name-ip-address-association然后再次.
我希望有人能告诉我如何通过IP调用psremoting-target.
编辑:更具体地说,我希望能够运行:
Enter-PSSession -Computername 192.168.123.123 -credentials $cred
Run Code Online (Sandbox Code Playgroud)
但是,如果我将主机名传递给" -Computername" ,我只能运行该命令
Edit2:
当我尝试使用ip而不是主机名(来自内部网络)登录时,我收到了错误消息:
Enter-PSSession : Connecting to remote server failed with the following error message : The WinRM client cannot process
the request. Default authentication may be used with an IP address under the following conditions: the transport is HT
TPS or the destination is in the TrustedHosts list, and explicit credentials are provided. Use winrm.cmd to configure T
rustedHosts. Note that computers in the TrustedHosts list might not be authenticated. For more information on how to se
t TrustedHosts run the following command: winrm help config. For more information, see the about_Remote_Troubleshooting
Help topic.
Run Code Online (Sandbox Code Playgroud)
Edit3:
我知道WSMan的可信主机设置,但这似乎不是问题.它已设置为"*"(我在启用远程处理后立即执行了此操作),但我仍然无法使用ip作为target-computername连接到该服务器,但我可以使用主机名作为target-computername进行连接.似乎有类似IIS中的绑定,阻止侦听器侦听针对ip-number而不是主机名的请求.但是没有安装IIS.我不知道在哪里寻找这样的设置.
更新2011-07-12:
好的,我认为可信任主机设置不是问题,因为我可以通过主机名从我们的DC连接,但如果我使用计算机参数的目的地的IP地址则不能.
我想,问题一定是听众.也许侦听器不会接受针对destination-ip而不是destination-hostname的请求.但我不知道如何改变这一点.
Don*_*nes 47
错误消息为您提供了所需的大部分内容.这不仅仅是关于TrustedHosts列表; 它说,为了使用具有默认身份验证方案的IP地址,您还必须使用HTTPS(默认情况下未配置)并提供显式凭据.我可以告诉你至少不使用SSL,因为你没有使用-UseSSL开关.
请注意,默认情况下未配置SSL/HTTPS - 这是您必须采取的额外步骤.你不能只添加-UseSSL.
默认的身份验证机制是Kerberos,它希望看到AD中出现的真实主机名.不是IP地址,不是DNS CNAME昵称.有些人会启用基本身份验证,这不那么挑剔 - 但您也应该设置HTTPS,因为否则会以明文形式传递凭据.Enable-PSRemoting仅设置HTTP.
向主机文件添加名称将不起作用.这不是名称解析的问题; 它是关于如何执行计算机之间的相互身份验证.
此外,如果此连接中涉及的两台计算机不在同一个AD域中,则默认的身份验证机制将不起作用.有关配置非域和跨域身份验证的信息,请阅读"help about_remote_troubleshooting".
来自http://technet.microsoft.com/en-us/library/dd347642.aspx上的文档
HOW TO USE AN IP ADDRESS IN A REMOTE COMMAND
-----------------------------------------------------
ERROR: The WinRM client cannot process the request. If the
authentication scheme is different from Kerberos, or if the client
computer is not joined to a domain, then HTTPS transport must be used
or the destination machine must be added to the TrustedHosts
configuration setting.
The ComputerName parameters of the New-PSSession, Enter-PSSession and
Invoke-Command cmdlets accept an IP address as a valid value. However,
because Kerberos authentication does not support IP addresses, NTLM
authentication is used by default whenever you specify an IP address.
When using NTLM authentication, the following procedure is required
for remoting.
1. Configure the computer for HTTPS transport or add the IP addresses
of the remote computers to the TrustedHosts list on the local
computer.
For instructions, see "How to Add a Computer to the TrustedHosts
List" below.
2. Use the Credential parameter in all remote commands.
This is required even when you are submitting the credentials
of the current user.
Run Code Online (Sandbox Code Playgroud)
man*_*lds 24
试着这样做:
Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force
Run Code Online (Sandbox Code Playgroud)
我在我的基础设施中测试了您的断言 IP 地址不是问题,以下对我有用:
PS C:\Users\JPB> hostname
JPBCOMPUTER
PS C:\Users\JPB> Enter-PSSession -ComputerName 192.168.183.100 -Credential $cred
[192.168.183.100]: PS C:\Users\jpb\Documents>
[192.168.183.100]: PS C:\Users\jpb\Documents> hostname
WM2008R2ENT
Run Code Online (Sandbox Code Playgroud)
如果您尝试跨 VPN 工作,则最好在通往服务器的途中查看防火墙设置。Windows 远程管理的安装和配置可以为您提供帮助。WinRM 正在等待的 TCP 端口是:
WinRM 1.1 及更早版本:默认 HTTP 端口为 80。
WinRM 2.0:默认 HTTP 端口为 5985。
编辑:根据您的错误,您可以在您的客户端计算机上进行测试吗:
Set-Item WSMan:\localhost\Client\TrustedHosts *
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
136646 次 |
| 最近记录: |