actions / runner-images

GitHub Actions runner images
MIT License
10.19k stars 3.06k forks source link

Recent windows update broke `ssh-agent` #297

Closed Raynos closed 4 years ago

Raynos commented 4 years ago

I used to be able to install my dependencies by cloning my private github repositories

I suspect this is the change that broke me,

https://github.com/actions/virtual-environments/commit/8185a8bc0c66ddfde68b807cf4bc77a6d30fcba0

More information here https://github.com/webfactory/ssh-agent/issues/15

MaksimZhukov commented 4 years ago

Hello @Raynos, thanks for the your report! We’ve tried to configure SSH and clone a private repository and the following code works for us:

jobs:
  build:
    name: Configure SSH
    runs-on: windows-latest
    steps:
      - name: Start ssh-agent
        run: |
          Set-Service ssh-agent -StartupType Manual
          Start-Service ssh-agent
          git config --global core.sshCommand "'C:\Windows\System32\OpenSSH\ssh.exe'"
      - name: Add SSH key
        run: |
          echo $env:SSH_PRIVATE_KEY | ssh-add -
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
      - name: Add github.com to known_hosts
        run: |          
          mkdir ~/.ssh
          ssh-keyscan github.com >> ~/.ssh/known_hosts
      - name: Clone repo
        run: git clone git@github.com:username/reponame.git

Could you please check if it fixes your issue?

NOTE: Please pay attention that OPENSSH format key may not work so try to use PEM format key (begins with -----BEGIN RSA PRIVATE KEY-----). You can use the following guide to convert RSA key to PEM key.

Also you can try to use Install SSH Key action. It works for us too.

I hope it helps, if not, please let us know!

Raynos commented 4 years ago

Thanks maxim. I can confirm your code works.

MaksimZhukov commented 4 years ago

Great! I am closing the issue, feel free to reopen if you have any questions