Configuring Git to use Multiple Accounts (Win)

If you use multiple accounts with Git (for instance, a work or personal GitHub account in addition to your GA GitHub Enterprise account), you need to configure git a bit differently than the default instructions outlined on github.com. Use this page as your guide for finishing your GitHub Enterprise setup.

Generating a new SSH key

  1. Open PowerShell or Git Bash.
  2. Paste the text below, substituting in your GitHub Enterprise email address.

    ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

    This creates a new ssh key, using the provided email as a label.

  3. When you're prompted to "Enter a file in which to save the key," type

    /c/Users/[username]/.ssh/id_rsa_ga

    where [username] is your Windows username, and then press Enter.

  4. At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".

Adding your SSH key to the ssh-agent

  1. If you're NOT using Git Bash, paste the text below to start the ssh-agent in the background.

    eval "$(ssh-agent -s)"

    The output should be Agent pid followed by some numbers.

  2. In your editor, navigate to the c:\Program Files\Git\etc\ssh\ folder, then open the file named ssh_config (if this file doesn't exist, go to the terminal, run touch c:\Program Files\Git\etc\ssh\ssh_config, then open the file in your editor.)
  3. Add a second entry to your file using the following as a template:
    
        # my GitHub account 
        Host personal
          HostName github.com
          User git
          AddKeysToAgent yes
          UseKeychain yes
          IdentityFile ~/.ssh/id_rsa
          IdentitiesOnly yes
        
        # GA github Enterprise
        Host GA   
          HostName git.generalassemb.ly
          User git
          AddKeysToAgent yes
          UseKeychain yes
          IdentityFile ~/.ssh/id_rsa_ga
          IdentitiesOnly yes
        
        # wildcard
        Host *
          AddKeysToAgent yes
          UseKeychain yes
      
  4. Save your changes
  5. Paste the text below to add your SSH private key to the ssh-agent and store your passphrase in the keychain. (If you used a name other than id_rsa_ga in the steps above, be sure to use that name here as well.)

    ssh-add ~/.ssh/id_rsa_ga

  6. Add your new SSH Key to GitHub Enterprise following these instructions
  7. Verify your key works by running the following:

    ssh -T git@git.generalassemb.ly

    You should see output similar to:

    Hi <you>! You've successfully authenticated, but GitHub does not provide shell access. Connection to git.generalassemb.ly closed.