web-dev-qa-db-ja.com

ターゲットとしてIPアドレスを使用したPowershellリモート処理

Server 2008 R2でPSRemotingを正常に有効にしました。ホスト名をターゲットとして使用して、同じネットワーク内からremote-pssessionを実行できます。

IPアドレスを任意のコンピューター(ネットワーク内または別のネットワーク(たとえばVPN経由))からターゲットとして使用しようとすると失敗します。ホスト名を解決できないため、IPアドレスを使用する必要があるVPN接続を介してリモート処理を使用できるようにしたい。

クライアントに同じDNS名を持つ他のサーバーがいくつかあり、name-ip-address-associationを再度削除して挿入したくないため、hostsファイルに名前を追加したくありません。そしてまた。

誰かが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を使用してそのサーバーに接続することはできませんが、ターゲットコンピューター名としてホスト名を使用して接続できます。 。 IISには、ホスト名ではなくip-numberをターゲットとするリクエストをリスナーがリッスンできないようにするバインディングのようなものがあるようです。ただし、IISはインストールされません。そのような設定を探す場所がわかりません。

2011-07-12更新:
さて、trustedhosts-settingは、DCからホスト名経由で接続できますが、computer-paramの宛先のIPアドレスを使用している場合は接続できないため、問題ではないと思います。
問題はリスナーにあるに違いないと思います。リスナーは、destination-hostnameではなく、destination-ipをターゲットとしたリクエストを受け取らない場合があります。しかし、それを変更する方法がわかりません。

58
wullxz

エラーメッセージは、必要なもののほとんどを提供しています。これはTrustedHostsリストだけではありません。デフォルトの認証スキームでIPアドレスを使用するには、HTTPS(デフォルトでは設定されていない)を使用し、明示的な資格情報を提供する必要があるとも言われています。 -UseSSLスイッチを使用しなかったため、少なくともSSLを使用していないことがわかります。

SSL/HTTPSはデフォルトでは設定されていないことに注意してください-これは追加の手順です。 -UseSSLを追加することはできません。

デフォルトの認証メカニズムはKerberosであり、ADに表示される実際のホスト名を確認する必要があります。 IPアドレスではなく、DNS CNAMEニックネームでもありません。一部のユーザーは基本認証を有効にしますが、これはあまり選り好みしませんが、資格情報をクリアテキストで渡すため、HTTPSも設定する必要があります。 Enable-PSRemotingはHTTPのみをセットアップします。

ホストファイルに名前を追加しても機能しません。これは名前解決の問題ではありません。コンピューター間の相互認証がどのように実行されるかについてです。

さらに、この接続に関係する2台のコンピューターが同じ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.
46
Don Jones

これを試してください:

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

私のインフラストラクチャであなたの主張をテストします。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です。


編集済み:エラーに応じて、これをyouclientコンピューターでテストできますか?

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

みんなが簡単な解決策を与えてくれました。それはあなたが助けを見る必要があるでしょう-それは良いことで、一度にたくさんのように見えますが、実際にはすぐに読むことができます:

get-help about_Remote_Troubleshooting | more
3
Matt

マシン上で'Set-Item WSMan:\localhost\Client\TrustedHosts -Value "$ipaddress"を実行します

* PSSessionを実行しているマシン

1
Sambhav Pandey

Windows 10では、コマンドを呼び出すためにWinRMサービスが実行されていることを確認することが重要です

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

0