Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 581 Bytes

use-correct-ssh-key.md

File metadata and controls

20 lines (16 loc) · 581 Bytes

Automatically use correct SSH key for remote Git repo

  1. In ~/.ssh/ create a file called config with contents based on this:
#user1 account
Host github.aaakk.us.kg-user1
    HostName github.com
    User git
    IdentityFile ~/.ssh/github-user1

#user2 account
Host github.aaakk.us.kg-user2
    HostName github.com
    User git
    IdentityFile ~/.ssh/github-user2
  1. git remote set-url origin [email protected]:user1/your-repo-name.git

Automatically use correct SSH key for remote Git repo