How to use multiple accounts
Generate SSH Keys for both accounts
Example:
ssh-keygen -t rsa -b 4096 -f ~/.ssh/KEY1
2. Add the SSH Public Key into the respective accounts

3. Set up configuration file ~/.ssh/config
with both accounts
# ACCOUNT 1, - the default config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/KEY1
# ACCOUNT 2
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/KEY2
4. Clone using the alias for the Github Link
git clone [email protected]:USER_NAME/GITHUB_REPO_NAME.git
or
git clone [email protected]:USER_NAME/GITHUB_REPO_NAME.git
As long as you have set up the SSH Keys correctly and the configuration file you should be able to clone the repositories successfully and the output should look like this:
Cloning into 'REPO_NAME'...
remote: Enumerating objects: 1138, done.
remote: Counting objects: 100% (1138/1138), done.
remote: Compressing objects: 100% (886/886), done.
remote: Total 1138 (delta 198), reused 1124 (delta 187), pack-reused 0
Receiving objects: 100% (1138/1138), 9.09 MiB | 1.26 MiB/s, done.
Resolving deltas: 100% (198/198), done.
5. After you have pulled the repository, you will need to add the following field to the ~/REPO_NAME/.git/config
file
[user]
name = USER_NAME
email = [email protected]
Last updated