Last Updated: February 25, 2016
·
380
· ridermansb

Multiples git account in the same computer

Generate new SSH

*Go to .ssh folder *

cd ~/.ssh

Generate

ssh-keygen -t rsa -C "your-email-address"

Use a new file name like: id_rsa_OTHERUSER

Add new ssh

ssh-add ~/.ssh/id_rsa_OTHERUSER

*Open/create a config file *

vim ~/.ssh/config

Add a new Host configuration like

Host github-OTHERUSER
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_OTHERUSER

Update git URL

Update/clone your repository with this format

  • git remote **[add or set-url]** origin git@github-OTHERUSER:company/testing.git
  • git clone git@github-OTHERUSER:company/testing.git

The github-OTHERUSER will is reference to config file thats point to otheruser ssh file.

You can update the user name and email in your repository

  • git config user.name "OTHER_USERNAME"
  • git config user.email "OTHER@EMAIL"

To check changes

Execute: ssh -T git@github-OTHERUSER

This will display the username for ssh;

2 Responses
Add your response

Or you can use my github-keygen to automate all this and use very secure SSH settings.

over 1 year ago ·

Nice tool. I'll add it to my favorites.

over 1 year ago ·