actions / checkout

Action for checking out a repo
https://github.com/features/actions
MIT License
5.94k stars 1.76k forks source link

Error loading SSH key on self-hosted Windows runner #1397

Open ivy-tru opened 1 year ago

ivy-tru commented 1 year ago

Hello I have an issue on checkout via SSH on a Windows self-hosted runner (Windows 2012 R2).

My action code looks like this:

      - name: Checkout
        uses: actions/checkout@v3
        with:
          repository: ***/script
          ssh-key: ${{ secrets.SSH_*** }}
          path: 'script'
          ref: ${{ inputs.script-branch }}     

I get these logs

2023-06-30T15:42:22.1865438Z ::group::Fetching the repository
2023-06-30T15:42:22.1866093Z ##[group]Fetching the repository
2023-06-30T15:42:22.1883054Z [command]"C:\Program Files\Git\cmd\git.exe" -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/develop*:refs/remotes/origin/develop* +refs/tags/develop*:refs/tags/develop*
2023-06-30T15:42:24.2119758Z Load key "C:\\github-actions-runner\\_work\\_temp/690271f6-12fc-44c5-8fc9-8049f21ed1b3": Permission denied
2023-06-30T15:42:24.2122709Z git@github.com: Permission denied (publickey).
2023-06-30T15:42:24.2136724Z ##[error]fatal: Could not read from remote repository.
2023-06-30T15:42:24.2138176Z 
2023-06-30T15:42:24.2138734Z Please make sure you have the correct access rights
2023-06-30T15:42:24.2139578Z and the repository exists.
2023-06-30T15:42:24.2187116Z The process 'C:\Program Files\Git\cmd\git.exe' failed with exit code 128

... and in post phase ...

2023-06-30T15:43:01.2873574Z ##[debug]File was unable to be removed Error: EPERM: operation not permitted, stat 'C:\github-actions-runner\_work\_temp\690271f6-12fc-44c5-8fc9-8049f21ed1b3'
2023-06-30T15:43:01.2876077Z ##[warning]Failed to remove SSH key 'C:\github-actions-runner\_work\_temp\690271f6-12fc-44c5-8fc9-8049f21ed1b3'
2023-06-30T15:43:01.2903495Z [command]"C:\Program Files\Git\cmd\git.exe" config --local --name-only --get-regexp core\.sshCommand

Same code works works without issues on:

So I think my action configuration and my SSH configuration is good. It happens on two different Windows machines...

radoslaw-wielonski-nc commented 5 months ago

I have similiar problem on self hosted windows runner. Have you solved it @ivy-tru?

ivy-tru commented 5 months ago

Hi @radoslaw-wielonski-nc There are no news on this topic. We just configured the Actions Runner service to run as a privileged user account. This way it works fine. Maybe not best practice about security but only way we see so far.