Setting Up Multiple GitHub Accounts on the Same Computer Using SSH
Steps:
got to C:/User/.ssh and run gitbash in it
ssh-keygen -t ed25519 -C "[email protected]"
- It gives option to rename id, you should start renaming from drive path (i.e C:/User/.ssh/id_company).
eval “$(ssh-agent -s)”
- It gives output as
Agent pid 1673
- Add ssh key:
ssh-add id_company
- Make a config file inside .ssh folder. It doesnot have extension
- The file looks like this. just change host and identity file.
# Account 1Host github.com-account1 HostName github.com User git IdentityFile ~/.ssh/id_rsa_account1
# Account 2Host github.com-account2 HostName github.com User git IdentityFile ~/.ssh/id_rsa_account2
Add your remote:
git remote add origin git@github-doe-company:username/repo.git
or change using
git remote set-url origin git@github-doe-company:username/repo.git
Note: While setting the url , you have to change github.com to host that is mentioned in config file
i.e. [email protected]:romanpoudel /neo.git to git@github-company:romanpoudel /neo.git
Change origin
Personal
HostName github.comUser gitIdentityFile ~/.ssh/.id_personal
Work
Host github-company.comHostName github.comUser gitIdentityFile ~/.ssh/id_company