Seamlessly Manage Multiple GitHub Accounts with SSH Keys
Developers frequently juggle multiple GitHub accounts for organizational, client, and personal projects, which can lead to authentication conflicts, commit misattributions, and deployment issues. This comprehensive guide outlines a step-by-step process to configure a single computer to manage these accounts seamlessly, ensuring a smooth and error-free workflow. The core solution revolves around leveraging SSH keys and Git’s configuration capabilities.
The process begins by generating unique SSH key pairs (public and private) for each GitHub account—for instance, `id_rsa_personal`, `id_rsa_office`, and `id_rsa_client`. These private keys are then added to the SSH agent for secure and persistent access. Subsequently, the corresponding public keys are uploaded to their respective GitHub accounts through the platform’s settings. A crucial step involves configuring the `~/.ssh/config` file, where custom hosts like `github.com-personal` are mapped to the specific SSH identity files for each account.
When cloning repositories, developers must use the custom host defined in their SSH configuration, such as `git clone [email protected]:username/project.git`, to ensure the correct account’s SSH key is used for authentication. Finally, for each cloned repository, the local Git user’s name and email are configured using `git config user.name “personal”` and `git config user.email “[email protected]”`. This ensures that all commits from that specific repository are correctly attributed to the intended GitHub account, effectively mitigating the risks of misattribution and authentication hassles.
(Source: https://dev.to/jahid02/how-to-use-multiple-github-accounts-on-one-computer-step-by-step-guide-ln3)


