./scripts/setup-ssh.sh <email> [host-alias] [key-name]The script generates an ed25519 key, adds it to ssh-agent, updates ~/.ssh/config, and prints the public key to paste into GitHub.
ssh-keygen -t ed25519 -C "you@example.com" -f ~/.ssh/id_ed25519_githubeval "$(ssh-agent -s)"
ssh-add --apple-use-keychain ~/.ssh/id_ed25519_githubHost github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_github
IdentitiesOnly yes
cat ~/.ssh/id_ed25519_github.pub | pbcopyGo to GitHub → Settings → SSH and GPG keys → New SSH key, paste, save.
ssh -T git@github.com
# Hi 0x48core! You've successfully authenticated...Use a different Host alias per account so SSH picks the right key.
# Personal
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_github
IdentitiesOnly yes
# Work / GHEC
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
IdentitiesOnly yes
./scripts/setup-ssh.sh you@work.com github.com-work id_ed25519_work# Personal
git clone git@github.com:0x48core/myrepo.git
# Work account — swap host to the alias
git clone git@github.com-work:yourorg/myrepo.gitgit remote set-url origin git@github.com-work:yourorg/myrepo.gitssh -T git@github.com # → Hi 0x48core!
ssh -T git@github.com-work # → Hi workuser!Add to ~/.ssh/config once:
Host *
IgnoreUnknown UseKeychain
AddKeysToAgent yes
UseKeychain yes
Keys added with --apple-use-keychain survive restarts without needing ssh-add again. IgnoreUnknown keeps the same ~/.ssh/config valid on Linux/WSL, whose OpenSSH has no UseKeychain option.
On Linux/WSL, AddKeysToAgent yes loads the key on first use; start an agent per login with keychain or your desktop's agent.
# Verbose connection debug
ssh -vT git@github.com
# List keys loaded in agent
ssh-add -l
# Re-add a key manually
ssh-add --apple-use-keychain ~/.ssh/id_ed25519_github
# Verify which key is being used for a host
ssh -vT git@github.com 2>&1 | grep "Offering"