Permission denied using Github deployment keys

So, I have a project (private repo) that has several submodules (also private). I have a server hosted on Amazon EC2 where the project will be hosted, and I want to use our private Github repository.

I created an ssh key for the main project and added it to the project deployment keys. I also created additional ssh keys for each submodule and added it to my deployment keys.

When I try to clone a project (using git @github), it does not work:

Access denied (publication). fatal: the far end unexpectedly hung up

I double-checked every repo and their deployment keys, and everything seems to be correct. Is there any other small step that I am missing?

+6
source share
1 answer

Short answer: There is no easy way to use deployment keys with private submodules. In my experience, you have two options:

  • Continue to use submodules, but stop using deployment keys and instead use a single account level SSH key that provides access to all your private repositories (easier, less secure).
  • Stop using submodules, continue to use deployment keys and manually git clone each repository passing in the SSH private key that corresponds to the deployment key (more complex, more secure)

The reason for this is that git clone starts an SSH connection that can only use one SSH private key at a time (e.g. ~ / .ssh / id_rsa). The SSH private key used must match the repository deployment key — and the deployment keys must be unique for each project. In the case of a clone submodule, you use only one private key. This key may correspond to your high-level project, but, of course, it will fail in child projects with the error you provided.

Hope this will be helpful.

+6
source

Source: https://habr.com/ru/post/915850/


All Articles