Main | The Origin of Henge Monuments »
Thursday
Feb132025

Multiple accounts with the same hosting provider over SSH

It is fairly common to want to set up two SSH connections from a given machine to the same remote host. For example you might have both a work and a personal account on Github and you might want to pull and push changes from work and personal repositories on your machine.

If you just follow the instructions for setting up a single SSH connection and repeat it twice, your scond connection will probably not work because SSH on your machine will use the first account name to try to connect to the second account.

The way to fix this is to set up a .ssh/config file in which you define aliases for your two accounts, for example: github.com_work and github.com_personal. Then you use these aliases in the git config remote.origin.url in the respective repositories, for example:

git config remote.origin.url git@github.com_work:account_name_work/project_name

git config remote.origin.url git@github.com_personal:account_name_personal/project_name

For an example of the .ssh/config file see the Git FAQ.

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
All HTML will be escaped. Hyperlinks will be created for URLs automatically.