R. Bogaveev
R. Bogaveev

Reputation: 301

Rundeck job fails with PermissionDenied UnauthorizedAccessException

I have a job in a rundeck that connects to windows machine by some domain network's user credentials and runs the script that copies some folder from another machine in the domain network. Connection to windows node done by WinRM.

When I run that script by rundeck job it fails with error

[ERROR  ]  Test-Path : Access is denied
10:43:56    At E:\scripts\site_backup.ps1:20 char:10
10:43:56    + if(-not (Test-Path $BackupDirectory)) {
10:43:56    +          ~~~~~~~~~~~~~~~~~~~~~~~~~~    

PermissionDenied: (\\some.path.local\dprr...rw-tests-pq:String) [Test-Path], UnauthorizedAccessException

However, if I run that script under the same user connecting by RDP to that machine it works fine.

I suspect WinRM service does not have enough privileges. Maybe I am wrong. How can I resolve that issue? Any help will be appreciated.

Upvotes: 1

Views: 1022

Answers (2)

R. Bogaveev
R. Bogaveev

Reputation: 301

As @MegaDriver68k said, it was "double hop" Powershell issue. In order to overcome that on Rundeck it was required:

  1. Set

winrm-authtype: credssp

on node yaml file (I added node to rundeck via adding yaml file)

  1. Install required pip package on Rundeck Machine

pip install pywinrm[credssp]

  1. Enable credSSP athentication Group Policy for "WinRM client" and "WinRM Service" on Windows Node. More details about it you may find out here

Upvotes: 1

MegaDrive68k
MegaDrive68k

Reputation: 4325

That's "double hop" PowerShell problem. You can check a full explanation here, and here a good approach. Also here a good wokaround.

Upvotes: 1

Related Questions