Github and SSH setup

Github recently moved to support only ssh access via public/private keys. As I use github to host this blog, I was impacted.

The setup on Linux is not very complicated, and relatively well documented on Github itself but all the steps are not listed in a simplistic manner, and some Google search is still required to find out how to setup multiple private keys for various different servers or different repos.

Here is my short guide. In bash, do the following:

ssh-keygen -t ed25519 -C "your_email@example.com"

Make sure to give a specific name, e.g. /home/you/.ssh/id_customrepo_ed25519

eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_customrepo_ed25519

Create ~/.ssh/config with

Host github-as-customrepo
        HostName github.com
        User git
        IdentityFile ~/.ssh/id_customrepo_ed25519
        IdentitiesOnly yes

Eventually follow the official doc to test the connection, e.g. ssh -T git@github-as-customrepo. Update the git URL via

git remote set-url origin git@github-as-customrepo:customrepo/customrepo.github.io.git

Comments

comments powered by Disqus