How to Manage Multiple GitHub Accounts

How to Manage Multiple GitHub Accounts
Palina Zabela's Profile Image
Palina Zabela

Content Manager, Octo Browser

Developers often need to manage multiple GitHub accounts to avoid confusion with different projects and commits. If you work with repositories that belong to different accounts, manually switching between them can be inconvenient. Using the SSH protocol can solve this problem. Here's how to do it.

Developers often need to manage multiple GitHub accounts to avoid confusion with different projects and commits. If you work with repositories that belong to different accounts, manually switching between them can be inconvenient. Using the SSH protocol can solve this problem. Here's how to do it.

Contents

Generate and add SSH keys

To ensure secure access to multiple GitHub repositories, you need to generate a unique SSH key for each account. To do this, open a terminal or command line and use the command:

ssh-keygen -t ed25519 -C "your_email@example.com"

We recommend using the ed25519 algorithm, as it's more modern and secure. Include an email address to make it easier to identify which key is which. Leave the default key path settings so it's saved in the .ssh folder in the directory.

After the process completes, two files will appear in the .ssh folder: your_email (the private key) and your_email.pub (the public key). Make sure you have the SSH agent running and add the private key to it.

Add the public key to GitHub

Now that you have a public key, you need to add it to your GitHub account. This step will allow GitHub to authenticate you when working with multiple repositories.

  1. Open the public key file your_email.pub in any text editor, e.g., Notepad.

  2. Copy the contents of the file.

  3. Go to GitHub, log in, and go to Settings.

  4. Open the "SSH and GPG keys" section.

  5. Click the "New SSH key" button.

  6. In the "Title" field, enter a descriptive name for the key, such as "My personal laptop" or "Work PC."

  7. In the "Key" field, paste the copied contents of your public key.

  8. Click "Add SSH key."

You should complete this procedure for each GitHub account using a separate public key. This will allow you to work with multiple accounts on a single device.

Access GitHub repo using SSH

After you've added the public key to your GitHub account settings, create a .config file in the .ssh folder and add the accounts. Here's an example:

# Account your_email

Host your_email

HostName github.com

User git

IdentityFile C:\Users\User\your_email@example.com

# Account your_email2

Host your_email2

HostName github.com

User git

IdentityFile C:\Users\User\your_email2@example.com

# Account your_email3

Host your_email3

HostName github.com

User git

IdentityFile C:\Users\User\your_email3@example.com

After that, you can start working with multiple repositories.

  1. Open the desired repository's page on GitHub.

  2. Click the green "Code" button.

  3. Go to the "SSH" tab.

  4. Copy the repository's SSH URL.

  5. Replace github.com in the SSH URL with your_email from the Host line in the .config file.

  6. Using a terminal or command line, type the command:

git clone <ssh-url>

Depending on the key used for authentication in your system, GitHub will automatically connect to the correct account. To specify different names and email addresses for commits in different repositories, you need to customize the configuration file. To do this, add the following lines to the global .gitconfig file:

[includeIf "gitdir:<absolute_path_to_work_directory>"]

path = <absolute_path_to_work_directory>/.gitconfig

Create a .gitconfig file in the repository you cloned. Paste your username and email address into this file using the command:

#.gitconfig file inside the work folder

[user]

name = <your_name>

email = <work_email_id>

This ensures that each GitHub project uses the correct email and name.

Conclusion

Setting up multiple GitHub accounts using SSH keys is an efficient and secure way to manage your projects. This approach will help you avoid confusion and errors.

Generate and add SSH keys

To ensure secure access to multiple GitHub repositories, you need to generate a unique SSH key for each account. To do this, open a terminal or command line and use the command:

ssh-keygen -t ed25519 -C "your_email@example.com"

We recommend using the ed25519 algorithm, as it's more modern and secure. Include an email address to make it easier to identify which key is which. Leave the default key path settings so it's saved in the .ssh folder in the directory.

After the process completes, two files will appear in the .ssh folder: your_email (the private key) and your_email.pub (the public key). Make sure you have the SSH agent running and add the private key to it.

Add the public key to GitHub

Now that you have a public key, you need to add it to your GitHub account. This step will allow GitHub to authenticate you when working with multiple repositories.

  1. Open the public key file your_email.pub in any text editor, e.g., Notepad.

  2. Copy the contents of the file.

  3. Go to GitHub, log in, and go to Settings.

  4. Open the "SSH and GPG keys" section.

  5. Click the "New SSH key" button.

  6. In the "Title" field, enter a descriptive name for the key, such as "My personal laptop" or "Work PC."

  7. In the "Key" field, paste the copied contents of your public key.

  8. Click "Add SSH key."

You should complete this procedure for each GitHub account using a separate public key. This will allow you to work with multiple accounts on a single device.

Access GitHub repo using SSH

After you've added the public key to your GitHub account settings, create a .config file in the .ssh folder and add the accounts. Here's an example:

# Account your_email

Host your_email

HostName github.com

User git

IdentityFile C:\Users\User\your_email@example.com

# Account your_email2

Host your_email2

HostName github.com

User git

IdentityFile C:\Users\User\your_email2@example.com

# Account your_email3

Host your_email3

HostName github.com

User git

IdentityFile C:\Users\User\your_email3@example.com

After that, you can start working with multiple repositories.

  1. Open the desired repository's page on GitHub.

  2. Click the green "Code" button.

  3. Go to the "SSH" tab.

  4. Copy the repository's SSH URL.

  5. Replace github.com in the SSH URL with your_email from the Host line in the .config file.

  6. Using a terminal or command line, type the command:

git clone <ssh-url>

Depending on the key used for authentication in your system, GitHub will automatically connect to the correct account. To specify different names and email addresses for commits in different repositories, you need to customize the configuration file. To do this, add the following lines to the global .gitconfig file:

[includeIf "gitdir:<absolute_path_to_work_directory>"]

path = <absolute_path_to_work_directory>/.gitconfig

Create a .gitconfig file in the repository you cloned. Paste your username and email address into this file using the command:

#.gitconfig file inside the work folder

[user]

name = <your_name>

email = <work_email_id>

This ensures that each GitHub project uses the correct email and name.

Conclusion

Setting up multiple GitHub accounts using SSH keys is an efficient and secure way to manage your projects. This approach will help you avoid confusion and errors.

Stay up to date with the latest Octo Browser news

By clicking the button you agree to our Privacy Policy.

Stay up to date with the latest Octo Browser news

By clicking the button you agree to our Privacy Policy.

Stay up to date with the latest Octo Browser news

By clicking the button you agree to our Privacy Policy.

Join Octo Browser now

Or contact Customer Service at any time with any questions you might have.

Join Octo Browser now

Or contact Customer Service at any time with any questions you might have.

Join Octo Browser now

Or contact Customer Service at any time with any questions you might have.

©

2025

Octo Browser

©

2025

Octo Browser

©

2025

Octo Browser