Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
Created October 29, 2021 15:19
Show Gist options
  • Select an option

  • Save mttjohnson/a6cfa43bc567e227802edb0fee077078 to your computer and use it in GitHub Desktop.

Select an option

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 git@github.com
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 curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256
# PasswordAuthentication no
# ChallengeResponseAuthentication no
# PubkeyAuthentication yes
# HostKeyAlgorithms ssh-ed25519-cert-v01@openssh.com,ssh-rsa-cert-v01@openssh.com,ssh-ed25519,ssh-rsa
# Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr
# MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,umac-128@openssh.com
# UseRoaming no
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment