
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.
Step 1: Generate SSH Keys for new Account
Run the following command (replace your_email@example.com
with your GitHub email):
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
- When prompted, enter a unique filename like id_rsa_client.
- Leave the passphrase empty (or set one if you want extra security).
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 4: Add SSH Keys to GitHub Accounts
Copy the SSH key:
cat ~/.ssh/id_rsa_client.pub
- Copy the output.
- Go to GitHub → Settings → SSH and GPG keys.
- Click New SSH Key, paste the key, and save.
Step 5: Configure SSH Config File
Now, let’s set up an SSH config file to manage the accounts smoothly.
Open Git Bash and run:
nano ~/.ssh/config
Add the following lines:
# 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 6: Clone Repositories Using Different Accounts
Now, when cloning repositories, use the appropriate Host name.
✅ Clone a Repo Using Your Main Account:
git clone git@github.com-main:your-username/repo-name.git
✅ Clone a Repo Using the Client Account:
git clone git@github.com-client:client-username/repo-name.git
For pushing code, Git will automatically use the correct SSH key.
Conclusion
That’s it! You have successfully set up multiple GitHub accounts on Windows 11 using SSH. Now, you can seamlessly switch between accounts without logging in and out all the time.
If you found this guide helpful, don’t forget to share it with your developer friends! Happy coding!