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

Trouble with multiple SSH keys #156

Closed
TrevorGibson-SR opened this issue Jan 12, 2023 · 3 comments
Closed

Trouble with multiple SSH keys #156

TrevorGibson-SR opened this issue Jan 12, 2023 · 3 comments

Comments

@TrevorGibson-SR
Copy link

Hi there,

I'm currently having trouble with a GitHub Actions workflow where I want to clone multiple private repositories (either hosted in Github or BitBucket). The main issue I'm facing is that I can't successfully clone more than one private GitHub repository. When running the action, the second repo always fails with error:

fatal: Could not read from remote repository.
  
Please make sure you have the correct access rights
and the repository exists.

The repository that's able to be successfully cloned corresponds to the first SSH key listed in my action .yml file... if I switch the order of the keys, the successfully cloned repo changes as well.

I've made a more detailed issue on a different, related repo, but I was hoping some additional eyes here might be able to help. Here's a link to the full issue:

ros-industrial/industrial_ci#807

Thanks in advance

@mpdude
Copy link
Member

mpdude commented Jan 13, 2023

@TrevorGibson-SR
Copy link
Author

@mpdude Thanks for the link. I have tried both with and without deploy key mapping but it doesn't seem to make a difference. When attempting to use deploy key mapping, the output from the ssh-agent step indicates that I have deploy keys mapped to the correct repos so I'm assuming that's "working", at least in the ssh-agent action:

...
Added deploy-key mapping: Use identity '/home/runner/.ssh/<key1>' for GitHub repository <repo1>
Added deploy-key mapping: Use identity '/home/runner/.ssh/<key2>' for GitHub repository <repo2>
...

@TrevorGibson-SR
Copy link
Author

TrevorGibson-SR commented Feb 20, 2023

Update

(see original post for details about each specific issue)

Issue 1

The root cause is due to the configuration created by webfactory/ssh-agent with the deploy key mapping feature. The custom .gitconfig settings are not copied into the docker automatically, therefore not allowing more than one private GitHub repo to be cloned.

This can be resolved by passing both the ~/.gitconfig file and ~/.ssh directory as mapped locations into the docker container. Specifically for ros-industrial/industrial_ci, use the DOCKER_RUN_OPTS parameter to specify the locations to map.

A more permanent fix has been submitted as a PR to the ros-industrial repo, to incorporate mapping these locations as part of the standard codebase.

Issue 2

This is resolved by adding non-GitHub servers to the known_hosts file. Sample code is provided in this post from the original issue report.

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

2 participants