webfactory / ssh-agent

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

Comment for key does not match Github URL pattern #76

Closed smofe closed 3 years ago

smofe commented 3 years ago

I want to access two different private repositories that contain packages for an App. I have created one ssh key for each of the two repos, added the private key to the secrets of the App-Repository and the public keys as deploy keys in the private package repositories.

My workflow looks as follow:

- uses: webfactory/ssh-agent@v0.5.2
      with:
          ssh-private-key: |
              ${{ secrets.SSH_PRIVATE_KEY_APISERVICE }}
              ${{ secrets.SSH_PRIVATE_KEY_WIDGETS }}

    - run: git clone git@github.com:[organization-name]/[repository-name1]

    - run: git clone git@github.com:[organization-name]/[repository-name2]

The public keys look like the following:

ssh-rsa AA[...]Gj 
git@github.com:[organization-name]/[repository-name1]

Running the workflow produces the following log:

Adding GitHub.com keys to /home/runner/.ssh/known_hosts
Starting ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-To1irqpM9o5v/agent.1571
SSH_AGENT_PID=1572
Adding private key(s) to agent
Identity added: (stdin) ((stdin))
Identity added: (stdin) ((stdin))
Key(s) added:
2048 SHA256:lF6[...]JsM (stdin) (RSA)
2048 SHA256:Wqc[...]FMbA8 (stdin) (RSA)
Configuring deployment key(s)
Comment for key 'ssh-rsa AA[...]Gj (stdin)' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.
Comment for key 'ssh-rsa AA[...]Gb (stdin)' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.
Comment for key '' does not match GitHub URL pattern. Not treating it as a GitHub deploy key.

Afterwards, the first git clone command works as excpected, the second one fails with the error:

ERROR: Repository not found.
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.

It's always the second clone command that fails, even if I swap the order in which the repositories are cloned.

I'm stuck and don't know if I am doing something wrong, or if this is some Bug with this Action. Any help is very appreciated!

mpdude commented 3 years ago

Key(s) added: 2048 SHA256:lF6[...]JsM (stdin) (RSA) 2048 SHA256:Wqc[...]FMbA8 (stdin) (RSA)

I think that we should see the key comments in the place where (stdin) is shown. Are you sure that the key comment is set correctly also in the private key?

With which command did you create the keys?

mpdude commented 3 years ago

Closing for now; feel free to reopen/comment when you verified the key comment is correct.

maxyousif15 commented 3 years ago

Experiencing the same issue here. The command used to create the SSH key is ssh-keygen -t rsa -b 4096 -C "git@github.com:some_owner/some_repo.git" -m PEM. Any ideas why this causes a failure? I can see the comments when I cat the public key, so not sure why it is not recognised by the ssh-agent as valid