

The account that you configured with the host will work as is without the need to change anything.įor other accounts you’ll need to edit the hostname in the clone command to match your configuration.# What problem does this feature solve? Then when cloning the repositories you need to use the SSH method instead of HTTPS to the configured keys. You also need to set the correct IdentityFile for each account. The HostName parameter should still always point to for all of them.

The others need to use something else such as github-work, github-customer1, github-robot, and so on. The host should be unique for each account so you can use for only one account, for example the one that you use the most. Configure a host setting for each account that you want to use, for example like this: Host This can be configured with the ~/.ssh/config file. Next, we’ll need a way for Git to know which key to use when interacting with a repository. You can get the contents of the file for example by opening it in a text editor or with the less command. Click “New SSH key” and copy the public key which is the file that has a. To add a SSH key log into your GitHub account and go to your account settings “SSH and GPG keys” section. If you have for example multiple customers with a separate GitHub account for each one then you should probably include the customer name in the key filename to keep things organized.Īfter you have created the keys they need to be associated with the corresponding GitHub accounts. When you get the “Enter a file in which to save the key” prompt, type in a custom location such as /Users/janne/.ssh/id_rsa_work. The comment argument with your email address is optional and can be omitted.

To create a key for your account you need to use the ssh-keygen command line tool: Similarly, the same key should naturally work for GitLab or Bitbucket too. Note that if you’re using a private GitHub Enterprise installation you won’t necessarily need a separate SSH key for the public GitHub because they don’t share authentication and are considered separate entities. This is a requirement from GitHub, and if you tried to add an existing key to a second account you’d get the “Key is already in use” error message. If you are using multiple GitHub accounts, for example one for private use and one for work, you need to configure SSH keys for each account separately.
GITBOX MULTIPLE ACCOUNTS PASSWORD
SSH requires that you configure authentication keys but it doesn’t store your username and password unencrypted on your computer like git-credential-store does if you want Git to remember your credentials. The first option uses your username and password and is generally simpler to set up. There are two ways you can connect to GitHub, HTTPS and SSH. Also if you’re new to Git and need a short introduction take a look at my post on Git essentials first. These instructions aren’t strictly specific to GitHub but I’m using that as an example.
GITBOX MULTIPLE ACCOUNTS HOW TO
In this post I’ll show how to make your multi-account work with Git a pleasant experience. You need to make sure that your name and email match the account you want to use for each repository and you may need to type different credentials depending on the repo. Having to use multiple accounts with Git can be cumbersome from time to time.
