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

Feature Request: Allow multiple keys to be setup for a single remote host #200

Open
MiltiadisKoutsokeras opened this issue Jun 8, 2022 · 1 comment

Comments

@MiltiadisKoutsokeras
Copy link

Hi and thank you for your useful tool,

I have stumbled on a setup that maybe cannot be covered by your tool or any similar. GitHub does not allow to have a single SSH Deploy Key for all your projects, you are forced to create a pair per project. If you want now to use 2 projects on a GitHub Action, it is not possible to define more than one key on the same host (github.com in our case) like this:

name: Multiple SSH keys in one host
on:
  push:
    branches:
      - develop
jobs:
  test:
    runs-on: ubuntu-latest
    container:
      image: python:3.9-bullseye
    steps:
      - name: NodeJS installation
        shell: bash
        run: apt update && apt install --assume-yes nodejs
      - name: GitHub SSH Authentication for Project 1
        uses: shimataro/ssh-key-action@v2
        with:
          key: ${{ secrets.SSH_PRIVATE_KEY_PROJECT_1}}
          name: project_1
          # Required once per host
          known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
      - name: GitHub SSH Authentication for Project 2
        uses: shimataro/ssh-key-action@v2
        with:
          key: ${{ secrets.SSH_PRIVATE_KEY_PROJECT_2 }}
          name: project_2
      - name: Prepare the Python environment
        shell: bash
        run: bash ${GITHUB_WORKSPACE}/.github/scripts/create_python_venv.sh

where in .github/scripts/create_python_venv.sh there is pip install -r requirements.txt command which contains the following:

# requirements.txt
git+ssh://git@github.com/myuser/project_1.git@develop#egg=project_1
git+ssh://git@github.com/myuser/project_2.git@develop#egg=project_2

As both URLs in requirements file require a different SSH key pair to work even though the host is the same.

@Flowster
Copy link

Hi @MiltiadisKoutsokeras I just created this Github action https://github.com/Flowster/git-ssh-key-action that seems to achieve what you also want. It works in conjonction with @shimataro ssh-key-action.
I'm using it on my Organization private repositories and it's working like a charm!
Let me know if it works for you too.

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