Skip to content

Instantly share code, notes, and snippets.

@FerrielMelarpis
Last active August 15, 2018 15:46
Show Gist options
  • Save FerrielMelarpis/5a461e0d570bd8088645141d74b62733 to your computer and use it in GitHub Desktop.
Save FerrielMelarpis/5a461e0d570bd8088645141d74b62733 to your computer and use it in GitHub Desktop.
Configuring multiple ssh accounts for multiple git accounts (GitHub,GitLab,etc.)
# ~/.ssh/config
# Account 1
Host host1
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_host1
# Account 2
Host host2
HostName gitlab.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_host2
# Usages:
# git clone host1:<username/organization>/repo.git
# git clone host2:<username/organization>/repo.git
# Notes:
# You can also use this approach for logging in to other machines using ssh
# e.g. ssh host1
# Just be sure to configure the `User` option or specify it on cmd `ssh user@host1`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment