webfactory / ssh-agent

GitHub Action to setup `ssh-agent` with a private key
MIT License
1.23k stars 256 forks source link

Clone Private Repo failed #25

Closed zhulinpinyu closed 4 years ago

zhulinpinyu commented 4 years ago

actions config

runs-on: ubuntu-latest
container:
      image: elixir:1.9.1-slim
      env:
        MIX_ENV: test
steps:
  - name: Checkout
    uses: actions/checkout@v1
  - name: create SSH key
    uses: webfactory/ssh-agent@v0.2.0
    with:
      ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
  - name: Install Dependencies
    run: |
        git clone git@github.com:zhulinpinyu/sf.git

error log:

Run git clone git@github.com:zhulinpinyu/sf.git
  git clone git@github.com:zhulinpinyu/sf.git
  shell: sh -e {0}
  env:
    SSH_AUTH_SOCK: /tmp/ssh-auth.sock
Cloning into 'sf'...
ssh_askpass: exec(/usr/lib/ssh/ssh-askpass): No such file or directory
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
##[error]Process completed with exit code 128.

Solution: https://github.com/webfactory/ssh-agent/issues/25#issuecomment-626529851

Thanks @stevie-

manivel-nagarajan commented 4 years ago

I'm also facing the same issue.

I'm trying to do 'pod install' which clones from private repo.

Ventals commented 4 years ago

Not working yet

stevie- commented 4 years ago

To work around the host-key verification problem you could add

ssh -T -oStrictHostKeyChecking=accept-new git@github.com || true
git clone git@github.com:zhulinpinyu/sf.git

to your run code.

manivel-nagarajan commented 4 years ago

I had the same problem then I've found the cause and fixed it.

  1. Have you added SSH_PRIVATE_KEY into your GitHub secrets? Remember, SSH_PRIVATE_KEY is not a default available key in GitHub secrets. You have to manually create one.
  2. If you haven't created one, please add a secret with the name SSH_PRIVATE_KEY and with your private key as value - Learn how to create Secrets in GitHub.
  3. If you don't have the private key, you have to create one using ssh-keygen. It is recommended to use a separate git account(machine user) for the remote usages. - Learn How to generate SSH Key.
  4. You have to authorize the SSH key in the GitHub SSH page using the public key you generated.

Once you're done with the mentioned steps, your script should work as expected.

I hope this helps!

mpdude commented 4 years ago

Please follow @manivel-nagarajan's good advice above.

Also, could you provide the full output from the action run so we can see if the action indeed tried to start the ssh-agent and set up the keys?

zhulinpinyu commented 4 years ago

@stevie- Great, Thank you very much ❤️