> For the complete documentation index, see [llms.txt](https://docs.arkannis.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.arkannis.net/devops/github/how-to-use-multiple-accounts.md).

# How to use multiple accounts

1. Generate SSH Keys for both accounts

{% hint style="success" %}
Example:

```bash
ssh-keygen -t rsa -b 4096 -f ~/.ssh/KEY1
```

{% endhint %}

2\. Add the SSH Public Key into the respective accounts

![](/files/JPmeZfxpqXnkIbORbgVG)

3\. Set up configuration file <mark style="color:green;">`~/.ssh/config`</mark> with both accounts

```bash
# 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

```bash
git clone git@github.com:USER_NAME/GITHUB_REPO_NAME.git

or

git clone git@github.com-work:USER_NAME/GITHUB_REPO_NAME.git
```

{% hint style="info" %}
Note: You will have to change only <mark style="color:orange;">`github.com`</mark> to the alias you have set up
{% endhint %}

{% hint style="info" %}
Additionally, if you need to test which account connects where use the following commands:

```bash
ssh -T git@github.com # Note this is Account 1 from ~/.ssh/config

# or

ssh -T gith@github.com-work # Note this is Account 2
```

Note: If you have set a different <mark style="color:green;">`HOST`</mark> parameter, you will have to use that one
{% endhint %}

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:

```bash
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.
```

{% hint style="info" %}
Note: If you are still unable to clone the Repo this might be due to an account conflict due to an old account.

You might need to clear all accounts and not configure any of them

```bash
git config --global --unset user.name
git config --global --unset user.email

# To check use:
git config --list
```

Check again account connectivity with:

```bash
ssh -T git@github.com
ssh -T git@github.com-work
```

{% endhint %}

5\. After you have pulled the repository, you will need to add the following field to the <mark style="color:green;">`~/REPO_NAME/.git/config`</mark> file

```bash
[user]
        name = USER_NAME
        email = EMAIL@email.com
```

{% hint style="info" %}
Should look something like this:

```bash
[core]
        repositoryformatversion = 0
        filemode = false
        bare = false
        logallrefupdates = true
        symlinks = false
        ignorecase = true
[remote "origin"]
        url = git@ALIAS-1:USER_NAME/REPO_NAME.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[user]
        name = USER_NAME
        email = EMAIL@email.com

```

{% endhint %}
