I have a github account, it is oanhnn, but when i join a private project in company, i have to use an other github account, eg suppermen. I want using two accounts without typing password each times, when git push or pull.
Using ssh keys and ssh configure file to alias host and using multiple github accounts
- Make key pair for each accounts and add it to github accounts.
- Make ssh configure file (
~/.ssh/config) like:# Default github account: oanhnn Host github.com HostName github.com IdentityFile ~/.ssh/oanhnn_key # Other github account: suppermen Host github-suppermen HostName github.com IdentityFile ~/.ssh/suppermen_key - Added ssh key to your agent by command:
$ ssh-add ~/.ssh/oanhnn_key $ ssh-add ~/.ssh/suppermen_key - Check that repo recognizes keys.
$ ssh -T git@github.com $ ssh -T git@github-suppermen - Clone projects
$ git clone git@github-suppermen:org2/project2.git /path/to/project2 $ cd /path/to/project2 $ git config user.email "suppermen@org2.com" $ git config user.name "Supper Men"
Done! Have goodluck!