You need to enable JavaScript to run this app. 如何在电脑配置多GitHub账户?企业与个人账户配置疑问
优惠活动
大模型
产品
解决方案
定价
更多

如何在电脑配置多GitHub账户?企业与个人账户配置疑问

Hey there! Let's sort out your multi-GitHub account config questions clearly:

1. What should I put for HostName?

You'll need separate entries in your ~/.ssh/config file for each account:

  • For your work GitHub Enterprise account, set HostName to github.company.com (that's the actual domain of your work's GitHub instance).
  • For your personal GitHub account, set HostName to github.com (the public GitHub domain).

2. Can Host be any meaningful name?

Absolutely! The Host field is just a local alias you make up to easily distinguish between the two accounts. Pick names that make sense to you—like github-work for your work account and github-personal for your personal one. When you clone repos or interact with remote servers later, you'll use this alias instead of the full domain (e.g., git clone git@github-personal:your-username/your-repo.git).

Quick bonus: Don't forget the User and IdentityFile fields

Even though you cut off your question about Us..., I'm guessing you're wondering about the User field. For both GitHub Enterprise and public GitHub, this should always be git (that's the user account GitHub uses for SSH connections). You'll also want to specify separate SSH keys for each account using IdentityFile to avoid authentication conflicts.

Here's a complete example of what your config file might look like:

# Work GitHub Enterprise configuration
Host github-work
  HostName github.company.com
  User git
  IdentityFile ~/.ssh/id_rsa_work  # Path to your work SSH key

# Personal GitHub configuration
Host github-personal
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_rsa_personal  # Path to your personal SSH key

This setup ensures Git uses the right key and connects to the correct GitHub instance depending on which alias you use.

内容的提问来源于stack exchange,提问作者Saturnian

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:40:44