# How To Manage Multiple GitHub account on Single Machine

Managing multiple Git accounts on a single Linux machine can be a common scenario, especially for developers who contribute to different projects or work with various organizations. Using SSH keys to authenticate with Git hosts is a secure and efficient way to manage these accounts. In this tutorial, we'll walk you through the steps to add multiple Git accounts in Linux using SSH keys.

- First locate the ssh directory

```bash
 cd ~/.ssh
```

- Generate SSH key pair(generate ssh for each acc you want)

```bash
ssh-keygen -t ed25519 -C "youremail@github"
```

This command generate the ssh key pair at `~/.ssh`

- Configure SSH for each github account by creating a `config` file.

```bash
touch ~/.ssh/config
```

- Inside the config file, add the following

```config
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/name_of_ssh_key_generated_earlier
```

- For each account you want to add, repeat the steps above and change the `IdentityFile` to the new ssh key generated for that account and change the host to your choice
- Go to [github.com/settins/new/ssh](https://github.com/settings/ssh/new) and add the ssh key from the file that have `.pub` extension generated for the desired account

- To test if the SSH is working, run the following command

- To test if the SSH is working clone a private repo using ssh

```bash
 git clone git@<custom_host_from_config>:<you_github_username>/<repo>.git
```
- Add alias to the cloned repo using the ssh to make it simple each time you want to push or pull
```bash
git remote add origin git@<custom_host_from_config>:<you_github_username>/<repo>.git
```
- Add some changes to the cloned repo and push it to the remote repo and check if the changes are reflected in the remote repo
