
How to Use Multiple GitHub Accounts on Windows 11 Using SSH
If you're a freelancer or a developer working with multiple clients, you might need to manage different GitHub accounts on your Windows 11 system. But how do you switch between them easily without getting into a login/logout mess?
The solution is SSH keys! 🎉 This guide will walk you through the process of setting up multiple GitHub accounts on Windows 11 using SSH in a simple and easy way.
Let’s get started! 🔥
Table of Contents
Configuring SSH for Multiple GitHub Accounts on Windows 11
Managing multiple GitHub accounts on a single machine can get tricky, especially when pushing or pulling code from different repositories.
In this section, you'll learn how to configure SSH keys to securely connect and switch between multiple GitHub accounts on your Windows 11 system.
This setup ensures smooth workflow management without repeated login issues or permission conflicts.
Prerequisites
Required Software
- Git for Windows
- Windows Terminal (recommended)
- Text editor (VS Code, Notepad++)
GitHub Accounts
- Personal GitHub account
- Work/Organization account
- Access to both accounts
Step 1:Generate SSH Keys for Each Account
We'll create separate SSH keys for each GitHub account to maintain security and organization.
For Your Personal Account:
Run the following command (replace your-personal-email@example.com
with your GitHub email):
ssh-keygen -t rsa -b 4096 -C "your-personal-email@gmail.com"
For Your Work Account:
ssh-keygen -t rsa -b 4096 -C "your-work-email@company.com"
After entering the passphrase, the key is stored in the designated location, generating two files as shown below.
Now, you have two SSH keys:
📌 id_rsa
(for your main GitHub account)
📌 id_rsa_client
(for the new client’s GitHub account)
Make sure not to overwrite the existing key for your default personal account. When prompted, save the file with a unique name, such as id_rsa_COMPANY
.
One file is the public key, and the other is the private key. You'll need this key to connect with your GitHub account. To view its contents, use the following command.
cat .ssh/id_rsa_work.pub
Make sure to copy and save the key in a text file on your computer, as it will be required for adding it to your second GitHub account.
Step 2: Add SSH Keys to GitHub Accounts
Copy Your Public Keys
# For personal account
cat ~/.ssh/id_rsa_personal.pub
# For work account
cat ~/.ssh/id_rsa_work.pub
Add Keys to GitHub:
- Copy the output.
- Go to GitHub → Settings → SSH and GPG keys.
- Click New SSH Key, paste the key, and save.
Step 3: Configure SSH Config File
Create or edit the SSH config file to manage multiple accounts seamlessly.
Create/Edit SSH Config:
nano ~/.ssh/config
Add the Following Configuration:
# Default GitHub Account
Host github.com-main
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
# Client GitHub Account
Host github.com-client
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_client
Step 4: Clone Repositories Using Different Accounts
Now, when cloning repositories, use the appropriate Host name.
Personal Repository:
git clone git@github.com-main:your-username/repo-name.git
Work Repository:
git clone git@github.com-client:client-username/repo-name.git
For pushing code, Git will automatically use the correct SSH key
Configure Local Git Settings:
For Personal Projects:
cd personal-repo
git config user.name "Your Personal Name"
git config user.email "personal@email.com"
For Work Projects:
cd work-repo
git config user.name "Your Work Name"
git config user.email "work@company.com"
Conclusion
You've successfully set up multiple GitHub accounts on Windows 11 using SSH keys. You can now seamlessly switch between personal and work projects without authentication hassles.
If you found this guide helpful, don’t forget to share it with your developer friends!
Happy coding!
- Generated separate SSH keys for each account
- Configured SSH to handle multiple GitHub accounts
- Set up proper Git configuration for different projects
- Learned troubleshooting techniques for common issues