[ macOS Sierra ] switch 2 github account on sourceTree

This is how to use a particular IdentityFile on macOS sourcetree.

  1. add “IdentitiesOnly yes” to ~/.ssh/config, so the result will be below.
Host dsin-GitHub
HostName github.com
User dsin
PreferredAuthentications publickey
IdentitiesOnly yes
IdentityFile /Users/dsin/.ssh/dsin-GitHub

2) test it

$ ssh -T git@dsin-GitHub


$ ssh -vT git@dsin-GitHub

3) change your remote repo address to git@dsin-GitHub, instead of git@github.com

NOTE : you can try force SSH private key using -i

$ ssh -i /Users/dsin/.ssh/dsin-GitHub git@github.com

or simply go with ~/.ssh/config

host *.compute-1.amazonaws.com
  IdentifyFile ~/.ssh/Whatever-Key

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s