Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
Created October 29, 2021 15:19
Show Gist options
  • Save mttjohnson/a6cfa43bc567e227802edb0fee077078 to your computer and use it in GitHub Desktop.
Save mttjohnson/a6cfa43bc567e227802edb0fee077078 to your computer and use it in GitHub Desktop.
ssh config examples - multiple identity files
AddKeysToAgent ask
# Managing multiple github keys with host entries and defaults with exclusions
# Test with:
# ssh -T git@asdf
# ssh -T [email protected]
Host github.com
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
HostName github.com
User git
IdentitiesOnly yes
Host asdf
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/github-asdf
HostName github.com
User git
IdentitiesOnly yes
# Example default with exclusion for specific host entries
Host * !asdf
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
# Apparently you can define multiple match strings per Host separated by spaces and ! is the exclusionary
# https://stribika.github.io/2015/01/04/secure-secure-shell.html
# This should be last as a default
HOST *
USER my_default_username
# KexAlgorithms [email protected],diffie-hellman-group-exchange-sha256
# PasswordAuthentication no
# ChallengeResponseAuthentication no
# PubkeyAuthentication yes
# HostKeyAlgorithms [email protected],[email protected],ssh-ed25519,ssh-rsa
# Ciphers [email protected],[email protected],[email protected],aes256-ctr,aes192-ctr,aes128-ctr
# MACs [email protected],[email protected],[email protected],hmac-sha2-512,hmac-sha2-256,[email protected]
# UseRoaming no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment