Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no such identity on self-hosted Linux Github runner #204

Open
Robert-DEMCON opened this issue Feb 1, 2024 · 2 comments
Open

no such identity on self-hosted Linux Github runner #204

Robert-DEMCON opened this issue Feb 1, 2024 · 2 comments

Comments

@Robert-DEMCON
Copy link

Robert-DEMCON commented Feb 1, 2024

I have setup a self hosted runner on Linux for my Github workflow and I am using ssh-agent to provide access to private repos dependencies.

On git clone ... I get an error:

Cloning into 'repo 2'...
no such identity: /home/github/.ssh/key-fffb0082e1157c90572...: No such file or directory

But in the webfactory/ssh-agent step before the clone I see the following output:

Adding private key(s) to agent
Identity added: (stdin) (git@github.com:repo1.git)
Identity added: (stdin) (git@github.com:repo2.git)
Key(s) added:
3072 SHA256:hAs1tUrOBaHbagBJZ... git@github.com:repo1.git (RSA)
3072 SHA256:Q77jCBXY8ISwrfJBp... git@github.com:repo2.git (RSA)
Configuring deployment key(s)
Added deploy-key mapping: Use identity '/home/github/.ssh/key-1f819af0a2d0117f7a1c4...' for GitHub repository repo1
Added deploy-key mapping: Use identity '/home/github/.ssh/key-7c10775661e565cd952033acf519154...' for GitHub repository repo2

Both keys have a different identity than mentioned on the error. Is this maybe a caching problem?


Relevant workflow job:

jobs:
  tests:
    runs-on: self-hosted
    steps:
      - name: Place SSH private key to grant access to other repos
        uses: webfactory/ssh-agent@v0.8.0
        with:
          ssh-private-key: |
            ${{ secrets.PRIVATE_KEY_FOR_REPO1 }}
            ${{ secrets.PRIVATE_KEY_FOR_REPO2 }}
      - run: |
          rm -rf tmp && mkdir -p tmp && cd tmp
          git clone git@github.com:repo1.git
          git clone git@github.com:repo2.git

I already use the same runner another repository's CI with ssh-agent with success.

@Robert-DEMCON
Copy link
Author

Robert-DEMCON commented Feb 1, 2024

Doing a grep on the faulty key (fffb0082e1157c90572...) I saw an entry in /home/github/.gitconfig, in the system user that does the runner. It looks like data persists from the other workflow that conflicts with this one.

After removing the file the job succeeds.

Can I use a local and temporary folder specific to each workflow instead of the system user home directory?

@Robert-DEMCON
Copy link
Author

I ended up working around this by adding a step to change the home directory first for the rest of the actions:

      - run: echo "HOME=$RUNNER_TEMP/github" >> "$GITHUB_ENV"

However, this does not change the location of the key files, they will still end up in /home/github/.ssh.
But the .gitconfig file will now be placed under the job temp directory. And this seems to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant