リモートサーバー(Windows Server 2022 Standard)でリモートPSセッションを開くのに苦労しています。リモートサーバーはないドメインの一部。
コマンドを実行すると
Enter-PSSession -ComputerName server01 -Credential server01\administrator
「アクセスが拒否されました」というメッセージが表示されます。
私がしたこと:
- サーバ
Enable-PSRemoting
Enable-WSManCredSSP -Role server
- クライアント
Add-Content -Path C:\Windows\System32\drivers\etc\hosts -Value "`n192.168.1.250`tserver01"
winrm quickconfig
Set-Item WSMan:\localhost\Client\TrustedHosts -Value server01
クライアントで実行する場合
Enter-PSSession -ComputerName server01 -Credential server01\administrator
パスワードを入力すると次のメッセージが表示されます。
Enter-PSSession: リモート サーバー "server01" との接続は次のようになります。エラーが発生する: リダイレクトされる 詳細な情報は、ヘルプ「about_Remote_Troubleshooting」で見つかります。入力:Zeile:1 Zeichen:1 + Enter-PSSession -ComputerName server01 -Credential server01\administrator + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo: InvalidArgument: (server01:String) [Enter- PSSession]、PSRemotingTransportException + FullyQualifiedErrorId: CreateRemoteRunspaceFailed
クライアント上で実行する場合
winrm identify -r:http://server01:5985 -u:server01\Administrator -p:secret
私は受け取ります
WSManFault メッセージ = 戻る
エラー番号: -2147024891 0x80070005 拒否
何が足りないのでしょうか?
アップデート:
winrm configでAuth/Basic
とを(クライアントとサービスの両方)AllowUnencrypted
に設定しましたがtrue
、結果は同じでした。次に設定されたHTTPSアクセス自己署名証明書を使用した場合、結果は同じです。
サーバー側にエントリがないため、Microsoft-Windows-Windows Remote Management/Operational
クライアント側でリクエストがブロックされているように見えます。Test-NetConnection -ComputerName server01 -Port 5985
成功します (ポート 5986 の場合と同様)。
答え1
非ドメイン ユーザーを使用しているため、UAC
ブロックされている可能性があるというのが私の最初の推測です。
このエラーはクライアントによって発生したと思われるので、まずUAC
クライアント側で無効にしてみてください。それでも問題が解決しない場合は、UAC
サーバー側で無効にしてください。
関連がない場合、このローカル管理者アカウントはサーバー上のグループUAC
のメンバーである必要があると考えられます。Remote Management Users
少なくとも、私は次にそれを試してみようと思います。
答え2
winrm get winrm/config
サーバー上の出力を含める必要があります。HTTP経由の基本認証を使用する資格情報をネットワーク経由で暗号化せずにホストに送信するそのため、通常、サービスではデフォルトで無効になっています。
また、Windows リモート管理イベント ログ (Microsoft-Windows-Windows リモート管理/操作) も確認してください。
winrm get winrm/config
Config
MaxEnvelopeSizekb = 500
MaxTimeoutms = 60000
MaxBatchItems = 32000
MaxProviderRequests = 4294967295
Client
NetworkDelayms = 5000
URLPrefix = wsman
AllowUnencrypted = false
Auth
Basic = true
Digest = true
Kerberos = true
Negotiate = true
Certificate = true
CredSSP = false
DefaultPorts
HTTP = 5985
HTTPS = 5986
TrustedHosts
Service
RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)(A;;GR;;;IU)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD)
MaxConcurrentOperations = 4294967295
MaxConcurrentOperationsPerUser = 1500
EnumerationTimeoutms = 240000
MaxConnections = 300
MaxPacketRetrievalTimeSeconds = 120
AllowUnencrypted = false
Auth
Basic = false **
Kerberos = true
Negotiate = true
Certificate = false
CredSSP = false
CbtHardeningLevel = Relaxed
DefaultPorts
HTTP = 5985
HTTPS = 5986
IPv4Filter = *
IPv6Filter = *
EnableCompatibilityHttpListener = false
EnableCompatibilityHttpsListener = false
CertificateThumbprint
AllowRemoteAccess = true
Winrs
AllowRemoteShellAccess = true
IdleTimeout = 7200000
MaxConcurrentUsers = 2147483647
MaxShellRunTime = 2147483647
MaxProcessesPerShell = 2147483647
MaxMemoryPerShellMB = 2147483647
MaxShellsPerUser = 2147483647
答え3
解決策を見つけました。コマンド-Authentication Basic
に追加するだけで済みましたEnter-PSSession
。
フルコマンド:
Enter-PSSession -ComputerName server01 -Authentication Basic -Credential administrator
使用時にwinrm identify
以下を追加する必要がありました-auth:basic
:
winrm identify -r:http://server01:5985 -a:basic -u:Administrator -p:secret
それはとても簡単なことでした...