2016-09-09 2 views
1

PowerShell을 사용하여 인증서를 설치하려고합니다. 내 컴퓨터에서 원격 세션을 만들어 설치를 테스트하고 있습니다. 원격 세션 외부에서 인증서를 성공적으로 설치 했으므로 명령이 정확하다는 것을 알고 있습니다. 나는 원격 세션없이이 명령을 실행하면PowerShell을 사용하여 원격 컴퓨터에 인증서를 설치하려면 어떻게해야합니까?

Access is denied. 0x80070005 (WIN32: 5 ERROR_ACCESS_DENIED). This may be the result of user credentials being required on the remote machine. See Enable-WSManCredSSP Cmdlet help on how to enable and use CredSSP for delegation with PowerShell remoting.

작동 : 난 내 자신의 컴퓨터에 원격 세션을 수행 할 때 나는 오류가 나타납니다

Import-PfxCertificate -FilePath "\\network\storage\site.com.pfx" -CertStoreLocation "Cert:\\LocalMachine\\WebHosting" -Password (ConvertTo-SecureString -String "foobar" -AsPlainText -Force) 

내가 (Invoke-Command 통해) 명령을 실행 원격 세션에서 위에서 언급 한 오류가 발생합니다 :

$session = New-PSSession $Env:ComputerName 
Invoke-Command -Session $session -ScriptBlock { Import-PfxCertificate -FilePath "\\network\storage\site.com.pfx" -CertStoreLocation "Cert:\\LocalMachine\\WebHosting" -Password (ConvertTo-SecureString -String "foobar" -AsPlainText -Force) } 

이 사용 권한 문제를 해결하려면 어떻게합니까?

답변

2

이중 홉 인증 문제가 발생했습니다. 일반 인증을 사용하는 경우 명령을 호출하는 시스템에서 두 번째 컴퓨터로 인증 할 수 없습니다.

이 문제를 해결하려면 CredSSP를 사용할 수 있습니다.

가 호출되는 시스템에서의 CredSSP을 사용하려면 다음
Enable-WSManCredSSP -Role Server -force 

클라이언트에서의 CredSSP를 사용하려면 :

Enable-WSManCredSSP -Role Client -DelegateComputer server.domain.com -force 

-delegateComputer 매개 변수는 FQDN 기대뿐만 아니라 와일드 카드를합니다.

의 CredSSP 당신이 매개 변수 -authentication CredSSP

+0

이 답변에 덧붙여서, 어떻게 그리고 왜 이것이 효과가 있는지 알고 싶다면 여기의 "Powershell remoting의 비밀"을 확인하십시오. https://devopscollective.gitbooks.io/secrets-of-powershell-remoting/ content/manuscript/accessible-remote-computers.html, 특히 마지막 두 섹션. – Astrotrain

+0

응답 Paul을 보내 주셔서 감사합니다. 내가 원격 세션 (닭고기와 계란 문제 내가 추정)을 통해 해당 명령을 실행할 수없는 가정? 우리는 서버 및 응용 프로그램 설정을 완벽하게 자동화하기 위해 그룹 정책이나 다른 방법을 통해 다르게 접근해야 할 수도 있습니다. –

+0

@JustinHelgerson은 100 % 확신 할 수 없지만 올바르게 추측하고 있다고 생각합니다.) 그룹 정책은 다음과 같은 방식으로 진행됩니다. https://msdn.microsoft.com/en-us/library/windows/desktop/bb204773(v= vs.85) .aspx – Paul

0

로 명령을 호출하는 데 사용할 수 있도록 한 후 나는 권한 문제를 해결하기 위해 노력 darnist 시간이 있었고, 결국 다른 방향 만나러 갔다. 권한 수정에는 결함이 있습니다. 모든 세부 정보는 기억할 수 없지만 ACL 속성은 변경하려는 키의 소유권에 액세스하려고 시도합니다. 모든 사용자에게 이상적인 것은 아니지만 NLA RDP 용 모든 시스템에 인증서를 배포하는 데 효과적입니다.

Set-Location "c:\windows\system32" 
#if certificate is missing, will install wild card certificate into the store 
icacls 'C:\ProgramData\Microsoft\Crypto\Keys' /save C:\ProgramData\Microsoft\Crypto\Keys\ACLfile_for_Keys_Dir /T 
takeown /f C:\ProgramData\Microsoft\Crypto\Keys\*.* 
icacls 'C:\ProgramData\Microsoft\Crypto\Keys\*.*' /grant 'Network Service:(R)' 
#icacls C:\ProgramData\Microsoft\Crypto /restore C:\ProgramData\Microsoft\Crypto\Keys\ACLfile_for_Keys_Dir #(restores original ACL for recovery) 
icacls 'C:\ProgramData\Microsoft\Crypto\keys' /setowner system 
icacls 'C:\ProgramData\Microsoft\Crypto\keys\*.*' /setowner system 

주석 처리 된 두 줄은 무언가가 잘못되었을 경우를 대비 한 백엔드 계획입니다.

관련 문제