github

Automatic log-in for git on github

Set-up

Generate a private/public key pair. When prompted, leave the passphrase empty:

ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_github -C "your_email@example.com"

Go to https://github.com/settings/keys and click New SSH key:

  1. Set Key type to Authentication Key
  2. Paste the text of ~/.ssh/id_ed25519_github.pub into the Key text field
  3. Click Add SSH key

Put the following text in ~/.ssh/config:

Host github
        User git
        Hostname github.com
        IdentityFile ~/.ssh/id_ed25519_github
        ForwardX11 no
        Compression no
        ClearAllForwardings yes

If you have more than one Host defined in this file, make sure to insert a blank line between them.

Usage

Configure your repository to use the ssh alias you just defined in ~/.ssh/config. For a new repository:

git remote add origin github:your_account/your_repo.git

(For a repo in a group account, use the group account as path, not your personal account.)

NOTE: no slash right after the semicolon.

For an existing repository, or if you get an error remote origin already exists, run this first and try again:

git remote remove origin

Or you can clone one of your own repositories from github, using the alias:

git clone github:your_account/your_repo.git
github