Skip to content

Instantly share code, notes, and snippets.

@antonga23
Created January 7, 2022 15:17
Show Gist options
  • Select an option

  • Save antonga23/c0fdfbdb934e4287c839ce1fc9e1bcad to your computer and use it in GitHub Desktop.

Select an option

Save antonga23/c0fdfbdb934e4287c839ce1fc9e1bcad to your computer and use it in GitHub Desktop.

Revisions

  1. antonga23 created this gist Jan 7, 2022.
    36 changes: 36 additions & 0 deletions git-ssh.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    1. Generate keys for github accounts

    eg.

    ssh-keygen -t ed25519 -C "[email protected]"

    ssh-keygen -t ed25519 -C "[email protected]"

    2. Start ssh-agent in background and add keys

    eval "$(ssh-agent -s)"

    ssh-add ~/.ssh/path_to_key1

    ssh-add ~/.ssh/path_to_key2

    3. Add ssh key to github, by pasting the *public* key to the browser

    4. Modify ssh config file: .ssh/config

    Host github.com
    User git
    Hostname github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/INSERT_PRIVATE_KEY1

    Host github-INSERT_NAME.com
    User git
    Hostname github.com
    PreferredAuthentications publickey
    IdentitiesOnly yes
    IdentityFile ~/.ssh/INSERT_PRIVATE_KEY2

    git clone [email protected]:username/repo.git

    git clone git@github-INSERT_NAME.com:username/repo.git