Add additional SSH troubleshooting while managing multiple GitHub accounts on a Single workstation #36207
Closed
1 task done
Labels
content
This issue or pull request belongs to the Docs Content team
ssh
Content related to SSH
waiting for review
Issue/PR is waiting for a writer's review
Code of Conduct
What article on docs.github.com is affected?
https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-your-personal-account/managing-multiple-accounts
What part(s) of the article would you like to see updated?
What is the problem?
Currently, GitHub Docs do not provide a detailed guide on configuring SSH for multiple GitHub accounts on a single workstation. Many developers face issues such as:
github.com
).~/.ssh/config
.What is the proposed solution?
I’d like to contribute a troubleshooting section that:
~/.ssh/config
.💡 Step-by-Step Guide to Fix This Issue
When managing multiple GitHub accounts on a single workstation using SSH, users may encounter authentication conflicts. Here’s how to set up SSH properly:
1️⃣ Generate Separate SSH Keys for Each Account
You cannot use the same SSH key for multiple GitHub accounts. Generate two different SSH keys:
Add the generated public keys
id_rsa_github_personal.pub
andid_rsa_github_work.pub
on the respective accounts.2️⃣ Configure
~/.ssh/config
with Unique Host AliasesSince GitHub only recognizes
github.com
as the host, you must define aliases to specify different SSH keys:3️⃣ Handling Networks that Block SSH on Port 22
Some networks block SSH connections on port 22. To use GitHub’s SSH over port 443 instead, modify your config:
4️⃣ Update the Git Remote URL
To ensure Git uses the correct SSH key, update the remote repository URL:
Check the Current Remote URL
Output:
Update the Remote URL
Change
github.com
to:github-personal
for personal repositoriesgithub-work
for work repositories# For Personal Repos git remote set-url origin git@github-personal:username/repository-name.git
# For Work Repos git remote set-url origin git@github-work:orgname/repository-name.git
5️⃣ Test the SSH Connection
Run the following commands to verify that SSH authentication works correctly:
Output:
Why is this useful?
This guide will help developers who frequently switch between personal and work GitHub accounts. By following these troubleshooting steps, users can correctly configure SSH without running into authentication conflicts.
I’d love to contribute this section to the official GitHub Docs. Let me know if this would be valuable, and I can submit a pull request with the content. 🚀
Additional information
No response
The text was updated successfully, but these errors were encountered: