Development Tip

IP 주소를 대상으로하는 Powershell 원격

yourdevel 2020. 12. 12. 12:34
반응형

IP 주소를 대상으로하는 Powershell 원격


내 Server 2008 R2에서 PSRemoting을 성공적으로 활성화했습니다. 호스트 이름을 대상으로 사용하여 동일한 네트워크 내에서 원격 pssession을 수행 할 수 있습니다.

어떤 컴퓨터 (네트워크 내부 또는 다른 네트워크 (예 : VPN을 통해))에서 IP 주소를 대상으로 사용하려고하면 실패합니다. 호스트 이름을 확인할 수 없기 때문에 IP 주소를 사용해야하는 VPN 연결을 통해 원격 기능을 사용하고 싶습니다.

동일한 dns-name을 가진 클라이언트의 다른 서버가 몇 개 있고 name-ip-address-association을 다시 제거하고 삽입하고 싶지 않기 때문에 내 호스트 파일에 이름을 추가하고 싶지 않습니다. 다시 한번.

누군가가 psremoting-target이 IP를 통해 호출되도록 허용하는 방법을 알려주기를 바랍니다.

편집 : 좀 더 구체적으로 이것을 실행할 수 있기를 원합니다.

Enter-PSSession -Computername 192.168.123.123 -credentials $cred 

하지만 " -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.

Edit3 :
WSMan의 신뢰할 수있는 호스트 설정에 대해 알고 있지만 문제가되지 않는 것 같습니다. 이미 "*"로 설정되어 있지만 (원격을 활성화 한 직후에 수행했습니다.) 여전히 IP를 대상 컴퓨터 이름으로 사용하여 해당 서버에 연결할 수 없지만 호스트 이름을 대상 컴퓨터 이름으로 사용하여 연결할 수 있습니다. . 리스너가 호스트 이름 대신 IP 번호를 대상으로하는 요청을 수신하지 못하도록하는 IIS의 바인딩과 같은 것이있는 것 같습니다. 그러나 IIS는 설치되어 있지 않습니다. 그런 설정을 어디에서 찾아야할지 모르겠습니다.

업데이트 2011-07-12 :
좋습니다. 호스트 이름을 통해 DC에서 연결할 수 있기 때문에 trustedhosts-setting이 문제가 아니라고 생각하지만 computer-param에 대상의 ip-address를 사용하는 경우에는 그렇지 않습니다.
문제는 듣는 사람이 틀림 없다고 생각합니다. 리스너는 destination-hostname 대신 destination-ip를 대상으로하는 요청을받지 않을 수 있습니다. 그러나 나는 그것을 바꾸는 방법을 모른다.


오류 메시지는 필요한 대부분을 제공합니다. 이것은 TrustedHosts 목록에 관한 것이 아닙니다. 기본 인증 체계로 IP 주소를 사용하려면 HTTPS (기본적으로 구성되지 않음)를 사용하고 명시적인 자격 증명을 제공해야합니다. -UseSSL 스위치를 사용하지 않았기 때문에 적어도 SSL을 사용하고 있지 않다고 말할 수 있습니다.

SSL / HTTPS는 기본적으로 구성되어 있지 않습니다. 이는 수행해야 할 추가 단계입니다. -UseSSL을 추가 할 수는 없습니다.

기본 인증 메커니즘은 Kerberos이며 AD에 표시되는 실제 호스트 이름을 보려고합니다. DNS CNAME 별명이 아닌 IP 주소가 아닙니다. 일부 사람들은 덜 까다로운 기본 인증을 활성화하지만 그렇지 않으면 일반 텍스트로 자격 증명을 전달하므로 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.

이렇게 해보세요 :

Set-Item WSMan:\localhost\Client\TrustedHosts -Value "*" -Force

내 인프라에서 귀하의 주장을 테스트합니다. 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

VPN을 통해 작업하려면 서버로가는 도중에 방화벽 설정을 살펴 봐야합니다. Windows 원격 관리를위한 설치 및 구성 이 도움이 될 수 있습니다. WinRM이 대기중인 TCP 포트는 다음과 같습니다.

WinRM 1.1 이하 : 기본 HTTP 포트는 80입니다.

WinRM 2.0 : 기본 HTTP 포트는 5985입니다.


Edited : According to your error can you test this on youclient computer :

Set-Item WSMan:\localhost\Client\TrustedHosts *

The guys have given the simple solution, which will do be you should have a look at the help - it's good, looks like a lot in one go but it's actually quick to read:

get-help about_Remote_Troubleshooting | more

On your machine* run 'Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$ipaddress"

*Machine from where you are running PSSession


On Windows 10 it is important to make sure the WinRM Service is running to invoke the command

* Set-Item wsman:\localhost\Client\TrustedHosts -value '*' -Force *

참고URL : https://stackoverflow.com/questions/6587426/powershell-remoting-with-ip-address-as-target

반응형