VS Code Multi-GitHub Setup Guide
vscode github ssh windows development
Cleanly separate Personal GitHub (github.com) and GitHub Enterprise on Windows 11, using SSH keys and VS Code profiles.
Overview
| Component | Personal | Work |
|---|---|---|
| VS Code Profile | Settings Sync ON (GitHub.com) | Settings Sync OFF (Enterprise) |
| SSH Key | id_ed25519_personal | id_ed25519_work |
| Git Identity | ~/.gitconfig-personal | ~/.gitconfig-work |
| Folder | C:\dev\personal | C:\dev\work |
Prerequisites
- Windows 11
- Git for Windows installed (includes OpenSSH)
- VS Code installed
- GitHub.com account (personal) + GitHub Enterprise account
Create Folder Layout
mkdir C:\dev\work
mkdir C:\dev\personalCreate SSH Keys
ssh-keygen -t ed25519 -C "you@company.com" -f $env:USERPROFILE\.ssh\id_ed25519_work
ssh-keygen -t ed25519 -C "you@gmail.com" -f $env:USERPROFILE\.ssh\id_ed25519_personalUpload public keys:
id_ed25519_work.pubto Enterprise GitHubid_ed25519_personal.pubto GitHub.com
Start SSH Agent
Start-Service ssh-agent
# (Optional admin-only)
# Set-Service ssh-agent -StartupType AutomaticSSH Config
Edit C:\Users\<you>\.ssh\config:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_personal
IdentitiesOnly yes
Host github.mycompanyname.com
HostName github.mycompanyname.com
User git
IdentityFile ~/.ssh/id_ed25519_work
IdentitiesOnly yesTest Connection
ssh -T git@github.com
ssh -T git@github.mycompanyname.comFix known_hosts Permission Errors
$me = (cmd /c whoami)
$ssh = "$env:USERPROFILE\.ssh"
$kh = "$ssh\known_hosts"
icacls $ssh /grant:r ("{0}:(F)" -f $me) "SYSTEM:(F)"
cmd /c takeown /F "$kh"
icacls $kh /grant:r ("{0}:(F)" -f $me) "SYSTEM:(R)"
attrib -R "$kh"Git Identity Per Directory
Edit C:\Users\<you>\.gitconfig:
[user]
name = Default User
email = default@example.com
[includeIf "gitdir:C:/dev/work/"]
path = ~/.gitconfig-work
[includeIf "gitdir:C:/dev/personal/"]
path = ~/.gitconfig-personalCreate separate config files:
# ~/.gitconfig-work
[user]
name = Work Name
email = you@company.com
# ~/.gitconfig-personal
[user]
name = Personal Name
email = you@gmail.comClone Repos
# Work
cd C:\dev\work
git clone git@github.mycompanyname.com:Org/repo.git
# Personal
cd C:\dev\personal
git clone git@github.com:user/repo.gitVS Code Profiles
| Profile | Settings Sync | Sign In To |
|---|---|---|
| Personal | ON | GitHub.com |
| Work | OFF | Enterprise |
Assign profiles to workspaces in VS Code.
Validate
git remote -v
git config user.emailTroubleshooting
| Issue | Solution |
|---|---|
| Unprotected key warnings | Fix key ACLs - only you + SYSTEM Read |
| known_hosts permission errors | Make known_hosts writable |
| ssh-agent auto-start denied | Run Set-Service line in admin shell only |