Multiple SSH Keys

Managing multiple SSH keys for Github and Visual Studio Online

After generating a new key for my Visual Studio Online code repository I have to tell git which key to use for each connection.

Create a file in ~/.ssh/config

Add the following content

# Uncomment to enable debugging.
# Levels are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
# LogLevel DEBUG

Host ssh.dev.azure.com
    IdentityFile ~/.ssh/id_rsa_visualstudio

Host vs-ssh.visualstudio.com
    IdentityFile ~/.ssh/id_rsa_visualstudio

Host github.com
    IdentityFile ~/.ssh/id_rsa_github

# tell ssh-agent to not try keys
Host *
    IdentitiesOnly yes