π οΈ Managing Multiple GitHub Accounts in VS Code (Windows Guide)
It’s common for developers to juggle work, personal, and client projects, each requiring a different Git identity. Instead of manually signing in and out, this guide shows you how to use SSH Keys and the ~/.ssh/config file to handle multiple GitHub accounts seamlessly on Windows, especially when using Git Bash and VS Code.
Prerequisites
- Git for Windows (with Git Bash) installed.
Download Link: Git-SCM - Visual Studio Code installed.
Download Link: VS Code
π Why We Choose ED25519 Keys
While you may see guides recommending RSA keys, we choose ED25519 because it is the current standard for SSH key security and performance.
| Feature | ED25519 (Recommended) | RSA (Older Standard) |
|---|---|---|
| Security | Equivalent to 3072-bit RSA | Secure at 4096-bit, but slower |
| Key Size | Very small (256-bit) | Large (often 4096-bit) |
| Performance | Faster for key generation and verification | Slower, requiring more computational overhead |
| Security Bonus | Resistant to timing attacks | More susceptible if not implemented carefully |
By choosing ED25519, we get smaller key files, faster performance, and modern cryptographic guarantees.
Step 0: Git Global Setup & VS Code PATH
Before generating keys, perform these two tasks in Git Bash:
-
Set Your Global Git Identity:
bash git config –global user.name “Your Default Full Name” git config –global user.email “your_default_email@example.com” -
Enable the
codeCommand (VS Code Shortcut):- Open VS Code
- Press Ctrl+Shift+P
- Type
shell command - Select “Shell Command: Install ‘code’ command in PATH”
- Restart Git Bash if needed
Step 1: Generate Unique SSH Keys π
We create a separate ED25519 key pair for each account.
| Account | Key File Name | Alias | |
|---|---|---|---|
| Work A | work-a@provolve-ai.com | id_ed25519_provolve-ai | github.com-provolve-ai |
| Work B | work-b@otheraccount.com | id_ed25519_otheraccount | github.com-otheraccount |
Commands:
ssh-keygen -t ed25519 -C "work-a@provolve-ai.com" -f ~/.ssh/id_ed25519_provolve-ai
ssh-keygen -t ed25519 -C "work-b@otheraccount.com" -f ~/.ssh/id_ed25519_otheraccount
π Gotcha: Custom Key Naming
Using descriptive names prevents confusion when managing many keys.
Step 2: Start the SSH Agent and Add Keys πΎ
Start the agent:
eval "$(ssh-agent -s)"
Add your keys:
ssh-add ~/.ssh/id_ed25519_provolve-ai
ssh-add ~/.ssh/id_ed25519_otheraccount
Step 3: Configure the SSH Config File βοΈ
Open:
code ~/.ssh/config
### OR
nano ~/.ssh/config
Add:
Provolve-AI Account
Host github.com-provolve-ai HostName github.com User git IdentityFile ~/.ssh/id_ed25519_provolve-ai
Other Account
Host github.com-otheraccount HostName github.com User git IdentityFile ~/.ssh/id_ed25519_otheraccount
Step 4: Upload Public Keys to GitHub β¬οΈ
Copy key:
cat ~/.ssh/id_ed25519_provolve-ai.pub | clip
Add it at:
GitHub β Settings β SSH and GPG keys β New SSH key
Select Authentication Key.
Repeat for Other Account.
π¨ Gotcha: Private Key Error
If GitHub rejects the key, you’re likely pasting the private key instead of .pub.
Step 5: Test the Connections β
ssh -T git@github.com-provolve-ai
ssh -T git@github.com-otheraccount
Expected response:
“You’ve successfully authenticatedβ¦"
π‘ The username is always git; the alias determines which key is used.
Step 6: Clone and Configure a Repository π
A. Clone Using Alias
git clone git@github.com-provolve-ai:Provolve-AI/provolve-ai.git /c/dev/provolve-ai
B. Set Local Git Identity
cd /c/dev/provolve-ai
git config user.name "Your Provolve-AI Full Name"
git config user.email "work-a@provolve-ai.com"
These settings apply ONLY to this repo.
π VS Code Sync
VS Code automatically respects your SSH configuration and repo-specific Git identity.
You can now securely clone, commit, and push using the correct GitHub account.