How to Use Multiple GitHub Accounts on MacOS

Photo by Yancy Min on Unsplash

How to Use Multiple GitHub Accounts on MacOS


GitHub is a powerful platform for collaboration and version control, widely used by developers worldwide. However, managing multiple GitHub accounts on the same machine can be tricky. In this guide, we'll walk you through the steps to set up and use two GitHub accounts on your Mac, allowing you to seamlessly switch between personal and work projects.

Step 1: Generate Separate SSH Keys

SSH keys are used for secure authentication when interacting with GitHub repositories. To use multiple GitHub accounts, you'll need to generate separate SSH keys for each account.

  1. Open Terminal on your Mac.

  2. Run the following command to generate an SSH key for the first account, replacing "" with your actual email address:

     ssh-keygen -t ed25519 -C ""
     #For legacy systems use
     ssh-keygen -t rsa -b 4096 -C ""
  3. When prompted, save the key with a unique filename, such as "id_rsa_your_name".

Repeat the process for the second account, using a different filename like "id_rsa_company_name".

Step 2: Configure SSH Config File

Next, you'll need to configure your SSH config file to use the correct SSH key for each GitHub account.

  1. Open or create the SSH config file by running:

     nano ~/.ssh/config
  2. Add the following configuration for each GitHub account:

     # Personal GitHub account
       User git
       IdentityFile ~/.ssh/id_rsa_john
     # Work GitHub account
       User git
       IdentityFile ~/.ssh/id_rsa_google

Step 3: Add Public Keys to GitHub Accounts

Now, you'll need to add the public keys to the corresponding GitHub accounts.

  1. Log in to your personal GitHub account and go to the "SSH and GPG keys" section of your Settings page.

  2. Click "New SSH key" and paste the contents of "~/.ssh/".

     pbcopy < ~/.ssh/
  3. Repeat this process for your work GitHub account, using the "" key.

Step 4: Test Connections

To ensure everything is set up correctly, test the connections for both accounts.

  1. Run the following commands in Terminal:

     ssh -T
     ssh -T

Step 5: Working with Repositories

When cloning or working with repositories, use the appropriate hostname:

git clone
git clone

Step 6: Set Git User Configuration

Lastly, set the Git and for each repository:

git config ""
git config "Your Personal Name"
git config ""
git config "Your Work Name"


By following these steps, you can seamlessly use two GitHub accounts on your Mac, switching between them as needed for your personal and work projects. Properly configured SSH keys and Git configurations ensure smooth interactions with GitHub repositories, enhancing your productivity and organization.

Thank you for joining me on this technical journey. Your support and interest mean the world to me. I look forward to sharing more insightful content with you in the future. Until then, stay curious and keep exploring!