Ошибка PSRemoting с использованием сеанса и CredSSP

Я использую Windows 8.1 Enterprise 64 бит и Powershell 4.0.

Я хочу выполнить удаленное взаимодействие PowerShell и использовать аутентификацию CredSSP.

Я открываю консоль Powershell, запускаю ее от имени администратора и выполняю команду Enter-PSSession для подключения к удаленному компьютеру.

Но я получаю ошибку о подключении.

PS C:\Documents and Settings\kiquenet> Enter-PSSession -ComputerName DC -credential devrsg.com\Administrator

В любом случае, я тестирую команду из Windows XP и Windows 7, и соединение в порядке.

PS C:\Documents and Settings\kiquenet> Enter-PSSession -ComputerName DC -credential devrsg.com\Administrator
[dc]: PS C:\Users\Administrator\Documents> exit

Сейчас тестирую в Windows 8.1.

Я тестирую команду enable-psremoting и получаю сообщение об ошибке:

PS C:\Windows\system32> Enable-PSRemoting -force

WinRM ya está configurado para recibir solicitudes en este equipo.
WinRM has been updated to receive requests.
Set-WSManQuickConfig : <f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2"
Machine="localhost"><f:Message><f:ProviderFault provider="Config provider"
path="%systemroot%\system32\WsmSvc.dll"><f:WSManFault xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault"
Code="2" Machine="MYCOMPUTERW8.mycompany.net"><f:Message>Unable to check the status of the firewall.
</f:Message></f:WSManFault></f:ProviderFault></f:Message></f:WSManFault>
En línea: 69 Carácter: 17
+                 Set-WSManQuickConfig -force
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Set-WSManQuickConfig], InvalidOperationException
    + FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQuickConfigCommand

Та же ошибка при использовании команды Enable-PSRemoting -force -SkipNetworkProfileCheck.

Я тестирую команду winrm quickconfig и получаю сообщение об ошибке:

PS C:\Windows\system32> winrm quickconfig  -force
WinRM service is already running on this machine.
WSManFault
    Message
        ProviderFault
            WSManFault
                Message = Unable to check the status of the firewall.

Nº de error:  -2147024894 0x80070002
The system cannot find the file specified.

У меня отключен SmartScreen и брандмауэр в Windows 8.1. (У меня отключена защита Symantec Endpoint)

Какие-либо предложения?

Обновить:

Я проверяю эти команды:

PS C:\> Enable-PSRemoting -SkipNetworkProfileCheck -Force

PS C:\>Set-NetFirewallRule –Name "WINRM-HTTP-In-TCP-PUBLIC" –RemoteAddress Any

но я получаю сообщение об ошибке:

PS C:\Windows\system32> Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP-PUBLIC" -RemoteAddress Any
Set-NetFirewallRule : No se encontraron objetos MSFT_NetFirewallRule cuya propiedad 'InstanceID' sea igual a
'WINRM-HTTP-In-TCP-PUBLIC'. Compruebe el valor de la propiedad e inténtelo de nuevo.
En línea: 1 Carácter: 1
+ Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP-PUBLIC" -RemoteAddress Any
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (WINRM-HTTP-In-TCP-PUBLIC:String) [Set-NetFirewallRule], CimJobException
    + FullyQualifiedErrorId : CmdletizationQuery_NotFound_InstanceID,Set-NetFirewallRule

Ссылка: http://technet.microsoft.com/en-us/library/hh849694.aspx

Обновление 2

Теперь я запускаю Net stop MPSSVC (служба брандмауэра Windows) и получаю эту ошибку

Enter-PSSession -ComputerName DC -credential dersg.com\Administrator
Enter-PSSession : Connecting to remote server DC failed with the following error message : Access is denied. For more information, see the about_Remote_Troubleshooting Help topic.
En línea: 1 Carácter: 1
+ Enter-PSSession -ComputerName DC -credential devrsg.com\Administrator
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (DC:String) [Enter-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

Обновление 3.

Я выполняю эту команду (https://stackoverflow.com/a/22816386/206730)

Set-PSSessionConfiguration -ShowSecurityDescriptorUI -Name Microsoft.PowerShell

Теперь я выполняю команду, и все в порядке

PS C:\Documents and Settings\kiquenet> Enter-PSSession -ComputerName DC -credential devrsg.com\Administrator
[dc]: PS C:\Users\Administrator\Documents> exit

Теперь я включаю CredSSP на сервере и в клиенте:

Enable-WSManCredSSP -Role Server –Force

Enable-WSManCredSSP -Role Client -DelegateComputer * -Force

Теперь я тестирую команду с помощью CredSSP:

$serverName = "DC"
$username = "devrsg\Administrator"
$password = "xxxxxx"   

$adjPwd = $password | ConvertTo-SecureString -asPlainText -Force
$testCred = (New-Object System.Management.Automation.PSCredential($username,$adjPwd))   

$scriptBlock = {
  Write-Host ("hello, world: {0}, {1}" -f $env:USERNAME, (hostname))
}

Invoke-Command $scriptBlock -computername $serverName -credential $testCred  -Authentication Credssp

и я получаю ошибку:

PS C:\> .\testRemoteCredSSP.ps1
[DC] Error de conexión al servidor remoto DC. Mensaje de error: El cliente WinRM no puede procesar la solicitud. Una
directiva de equipo no permite delegar credenciales de usuario en el equipo de destino porque éste no es de confianza.
La identidad del equipo de destino se puede comprobar si configura el servicio WSMAN para usar un certificado válido
con el siguiente comando: winrm set winrm/config/service '@{CertificateThumbprint="<huellaDigital>"}'  O bien puede
comprobar en el Visor de eventos si hay un evento que especifique que no se pudo crear el siguiente SPN:
WSMAN/<FQDNdelEquipo>. Si encuentra este evento, puede crear manualmente el SPN con setspn.exe .  Si el SPN existe,
pero CredSSP no puede usar Kerberos para validar la identidad del equipo de destino y desea permitir la delegación de
credenciales de usuario en el equipo de destino, use gpedit.msc y mire la siguiente directiva: Configuración del
equipo -> Plantillas administrativas -> Sistema -> Delegación de credenciales -> Permitir credenciales nuevas con
autenticación solo NTLM de servidor.  Compruebe que esté habilitada esta opción y configurada con el correspondiente
SPN para el equipo de destino. Por ejemplo, para un nombre de equipo de destino "miservidor.dominio.com", el SPN puede
ser alguno de los siguientes: WSMAN/miservidor.dominio.com o WSMAN/*.dominio.com. Pruebe de nuevo la solicitud después
de realizar estos cambios. Para obtener más información, consulte el tema de la Ayuda about_Remote_Troubleshooting.
    + CategoryInfo          : OpenError: (DC:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : -2144108124,PSSessionStateBroken

английское сообщение:

Enter-PSSession : Connecting to remote server failed with the following error me
ssage : The WinRM client cannot process the request. 
A computer policy does not allow the delegation of the user credentials to the target computer because the computer is not trusted. The identity of the target computer can be verified if you configure the WSMAN service to use a valid certificate using the following command: winrm set winrm/config/service '@{CertificateThumbprint="<thumbprint>"}' 

Or you can check the Event Viewer for an event that specifies that the following SPN could not be created: WSMAN/<computerFQDN>. If you find this event, you can manually create the SPN using setspn.exe .  

If the SPN exists, but CredSSP can not use Kerberos to validate the identity of the target computer and you still want to allow the delegation of the user credentials to the target computer, use gpedit.msc and look at the following policy: Computer Configuration -> Administrative Templates -> System -> Credentials Delegation -> Allow Fresh Credentials with NTLM-only Server Authentication.  

Verify that it is enabled and configured with an SPN appropriate for the target computer. 
For example, for a target computer name "myserver.domain.com", the SPN can be one of the following: WSMAN/myserver.domain.com or WSMAN/*.domain.com. 

Try the request again after these changes. 
    For more information, see the about_Remote_Troubleshooting Help topic.

person Kiquenet    schedule 07.04.2014    source источник


Ответы (1)


CredSSP не будет отправлять ваши учетные данные на компьютер, которому он не доверяет, вы можете добавить доверие к удаленному серверу двумя способами.

  1. Установите параметр GPO в Шаблоны администратора/Система/Делегирование учетных данных/Разрешить делегирование новых учетных данных либо серверу (WSMAN/dc.domain.com), либо подстановочному знаку для всего в домене (WSMAN/*.domain.com).

  2. Получите отпечаток сертификата для этой машины и запустите winrm set winrm/config/service '@{CertificateThumbprint="<thumbprint>"}'. Вы можете получить отпечатки сертификатов сервера, запустив: Get-ChildItem "Cert:\LocalMachine\Remote Desktop\"

person Phil    schedule 29.04.2017