Skip to main content

Multiple Private Repositories



  • Matthew Cowgur

    Did you ever solve this? I ran into a very similar issue; except it was working for one project, and it wasn’t after creating a second project. I needed to copy the project deploy key as an “SSH Key” on the machine user GitHub account Settings > SSH and GPG keys page.

  • Avi Deitcher

    Well, this is over 2 years old.

    @mango-chutney I couldn’t even figure out how to do it. I can set up a machine user on GitHub, and give the machine user access to a few repos, but then I need to make the private key available to my project so it can use it when running git clone in a build pipeline, or even just getting submodules.

    How did you make the machine user ssh private key available to the project?

  • Avi Deitcher

    FWIW, I ended up solving this; wish it were documented. I created a machine user, created an ssh keypair, affiliated the public key with the machine user, saved the private key as a base64-encoded sensitive project-level variable, and then used it in my build steps. This does not work for git submodules, so I had to do some manual git clone steps:

          export CUSTOM_SSH_KEYFILE=$HOME/.ssh/id_ed25519
          if [ ! -f "${CUSTOM_SSH_KEYFILE}" ]; then
            mkdir -p ~/.ssh
            chmod 0700 ~/.ssh
            echo -n ${GITHUB_PRIVATE_KEY} | base64 -d > ${CUSTOM_SSH_KEYFILE}
            chmod 0600 ${CUSTOM_SSH_KEYFILE}
          GIT_SSH_COMMAND="ssh -i ${CUSTOM_SSH_KEYFILE}" git clone targetdir

Please sign in to leave a comment.