shimataro / ssh-key-action

GitHub Action that installs SSH key to .ssh
https://github.com/marketplace/actions/install-ssh-key
MIT License
581 stars 87 forks source link

Permission denied (publickey) for git clone #201

Closed yermukhanbet closed 1 year ago

yermukhanbet commented 2 years ago

First of all, thank you for great job by developing this GitHub action.

I am trying to access multiple private repositories from GitHub Actions, which are linked to my main project as dependencies(SPM).

I successfully fetch SSH keys for both private repos. However, when I try to git clone them, output shows the following message:

git@github.com: Permission denied (publickey).
[8](https://github.com/eazel/iOSNetwork/runs/6806557664?check_suite_focus=true#step:7:9)
fatal: Could not read from remote repository.
[9](https://github.com/eazel/iOSNetwork/runs/6806557664?check_suite_focus=true#step:7:10)
[10](https://github.com/eazel/iOSNetwork/runs/6806557664?check_suite_focus=true#step:7:11)
Please make sure you have the correct access rights
[11](https://github.com/eazel/iOSNetwork/runs/6806557664?check_suite_focus=true#step:7:12)
and the repository exists.
[12](https://github.com/eazel/iOSNetwork/runs/6806557664?check_suite_focus=true#step:7:13)
Error: Process completed with exit code 128.

Here is my workflow:

- name: Install SSH key for first kit
      uses: shimataro/ssh-key-action@v2
      with:
        key: ${{ secrets.SSH_KEY_FIRST }}
        name: id_rsa-first
        known_hosts: unnecessary

    - name: Install SSH key for second kit
      uses: shimataro/ssh-key-action@v2
      with:
        key: ${{ secrets.SSH_KEY_SECOND }}
        name: id_rsa-second
        known_hosts: unnecessary

    - name: print created files
      run: ls -l ~/.ssh

    - name: git clone first
      run: git clone git@github.com:link

    - name: git clone second
      run: get clone git@github.com:link
codeflorist commented 2 years ago

i'm assuming your ssh key is encrypted - e.g. begins with:

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED

as stated in the Q&A section of readme you have to use a decrypted private key, so either create an unencrypted one without a passphrase or decrypt it like so:


openssl rsa -in ~/.ssh/id_rsa```