💾 Archived View for chirale.org › 2021-01-10_6598.gmi captured on 2024-08-31 at 12:07:01. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-05-12)

-=-=-=-=-=-=-

Private repo on github: how to push using a SSH deploy key

On github you can use a deploy key at a time for user associating github.com to a private key configured in .ssh/config file.

Create a new user on system (e.g. userperrepo) Generate a public / private pair following github howto (e.g. /home/userperrepo/.ssh/id_ecdsa_github) Associate the key with the repo on github Add or change config file on the system to associate git@github.com with this private key

public / private pair

github howto

key with the repo on github

git@github.com

For example create a file named /home/userperrepo/.ssh/id_ecdsa_github with this content:

Host github.com Hostname github.com User git IdentityFile /home/userperrepo/.ssh/id_ecdsa_github

Since for a github constraint a single deploy key cannot be used more than one time, you have to create a different user per repo to use git pull / push on private repo via ssh without any other configuration or command.

For any user created for deploy, specify git essentials:

 git config --global user.name "yourgithubname" git config --global user.email "youremail@example.com" 

In theory, you can chain multiple Host github.com sections with different keys and the first working will be used. Practically, this is slow and error-prone so it’s better to use a different user per repo or try a different method.

Then you can pull and push from a private repo with a deploy key without any other commands.

If you want a single user to use multiple keys, you can follow this howto. But keep in mind that you can use this method using a docker container or a similar technology for a smoother deploy.

this howto

https://web.archive.org/web/20210110000000*/https://www.ssh.com/ssh/keygen/

https://web.archive.org/web/20210110000000*/https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent#generating-a-new-ssh-key

https://web.archive.org/web/20210110000000*/https://docs.github.com/en/free-pro-team@latest/developers/overview/managing-deploy-keys

https://web.archive.org/web/20210110000000*/https://chirale.org/2019/04/20/using-multiple-deploy-keys-on-github-using-ssh-config/