{"meta":{"title":"在 GHE.com 上将 GitHub Copilot 与帐户配合使用","intro":"更新你的开发环境，以访问 Copilot 数据驻留站点帐户上的 GHE.com 套餐。","product":"GitHub Copilot","breadcrumbs":[{"href":"/zh/enterprise-cloud@latest/copilot","title":"GitHub Copilot"},{"href":"/zh/enterprise-cloud@latest/copilot/how-tos","title":"操作方法"},{"href":"/zh/enterprise-cloud@latest/copilot/how-tos/configure-personal-settings","title":"配置个人设置"},{"href":"/zh/enterprise-cloud@latest/copilot/how-tos/configure-personal-settings/authenticate-to-ghecom","title":"向 GHE.com 进行身份验证"}],"documentType":"article"},"body":"# 在 GHE.com 上将 GitHub Copilot 与帐户配合使用\n\n更新你的开发环境，以访问 Copilot 数据驻留站点帐户上的 GHE.com 套餐。\n\n若要在 IDE 或命令行中使用GitHub Copilot，必须向具有GitHub许可证的Copilot帐户进行身份验证。\n\n如果你通过企业拥有的 Copilot（位于 托管用户帐户 上）获得了 GHE.com 访问权限，你可能需要先调整 IDE 中的某些设置，才能通过帐户进行身份验证。\n\n使用本文顶部的标签查看适用于你的环境的说明\\*\\*\\*\\*。\n\n<div class=\"ghd-tool vscode\">\n\n## 在 VS Code 进行身份验证\n\n1. 若要打开设置 VS Code ，请按 <kbd>Command</kbd>+<kbd>、</kbd> （Mac）或 <kbd>Ctrl</kbd>+<kbd>（Windows</kbd> ）。\n\n2. 在搜索栏中搜索 `enterprise`。\n\n3. 设置`Github-enterprise: Uri`时，请输入您访问GitHub的URL。 例如：`https://octocorp.ghe.com`。\n\n4. 在VS Code 设置中，搜索`copilot`。\n\n5. 在“GitHub > Copilot: Advanced”中单击**Edit in settings.json**。\n\n6. 在 `github.copilot.advanced` 属性内，添加 `\"authProvider\": \"github-enterprise\"`。 例如：\n\n   ```json copy\n   \"github.copilot.advanced\": {\n        \"authProvider\": \"github-enterprise\"\n   },\n   ```\n\n7. 保存 `settings.json` 文件。\n\n8. 将显示一个提示，要求你登录以使用 GitHub Copilot。 单击“ **登录” GitHub**，然后按照提示授权帐户。\n\n   如果未 **看到提示**，请尝试重启 VS Code。\n\n如果你需要切换到 GitHub.com 上的一个帐户，请从 `authProvider` 中删除 `settings.json` 设置。\n\n</div>\n\n<div class=\"ghd-tool jetbrains\">\n\n## 从 JetBrains IDE 进行身份验证\n\n若要在 JetBrains 编辑器中进行身份验证 GHE.com ，必须安装 1.4.11 或更高版本的 Copilot 扩展。 然后，您必须将扩展配置，以便与 GHE.com 配合使用。\n\n1. 要打开编辑器首选项或设置对话框，请按 <kbd>Command</kbd>+<kbd>,</kbd> (Mac) 或 <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>S</kbd> (Windows)。\n2. 在左侧栏中，展开“工具”部分，然后单击 **GitHub Copilot**。\n3. 在“常规”部分中，查找“身份验证提供程序”字段，并输入你访问 GitHub的主机名。 例如：`octocorp.ghe.com`。\n4. 单击“OK”以保存更改\\*\\*\\*\\*。\n5. 按照提示登录以使用 GitHub Copilot。\n\n若要随时登录和注销GitHub，请单击状态栏中的**Copilot Chat** 图标（<svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-copilot\" aria-label=\"copilot\" role=\"img\"><path d=\"M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z\"></path><path d=\"M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z\"></path></svg>），然后单击“**登录”。GitHub** 按提示登录。\n\n如果需要切换到 GitHub.com 上的帐户，请删除在“身份验证提供商”字段中输入的值。\n\n</div>\n\n<div class=\"ghd-tool xcode\">\n\n## 从 Xcode 进行身份验证\n\n1. 打开“GitHub Copilot for Xcode”应用程序。\n2. 单击“高级”  选项卡。\n3. 在“身份验证提供程序 URL”字段中，输入访问 GitHub的 URL。 例如：`https://octocorp.ghe.com`。\n4. 请按照[登录到 GitHub Copilot](/zh/enterprise-cloud@latest/copilot/how-tos/set-up/install-copilot-extension?tool=xcode#signing-in-to-github-copilot)中的说明来授权扩展程序。\n\n</div>\n\n<div class=\"ghd-tool copilotcli\">\n\n## 从命令行进行身份验证\n\n若要使用 Copilot CLI，必须：\n\n1. 下载并安装 Copilot CLI。 请参阅 [安装 GitHub Copilot CLI](/zh/enterprise-cloud@latest/copilot/how-tos/copilot-cli/set-up-copilot-cli/install-copilot-cli)。\n2. 使用 GHE.com，向你获得 Copilot 许可证时所在的 `copilot login --host SUBDOMAIN.ghe.com` 上的帐户进行身份验证。\n\n有关 Copilot CLI 的常规信息，请参阅 [GitHub Copilot CLI](/zh/enterprise-cloud@latest/copilot/how-tos/copilot-cli)。\n\n</div>\n\n<div class=\"ghd-tool visualstudio\">\n\n## 在Visual Studio中进行身份验证\n\n若要从Visual Studio进行身份验证，请按照 [将GitHub帐户添加到 Visual Studio 密钥链](https://learn.microsoft.com/en-us/visualstudio/ide/work-with-github-accounts?view=vs-2022\\&ref_product=copilot\\&ref_type=engagement\\&ref_style=text\\&ref_plan=enterprise#enabling-github-enterprise-accounts)Microsoft Learn 中的步骤。\n\n对于“GitHub Enterprise URL”字段，输入您访问 GitHub 时使用的 URL。 例如：`https://octocorp.ghe.com`。\n\n</div>\n\n<div class=\"ghd-tool eclipse\">\n\n## 从 Eclipse 进行身份验证\n\n1. 在 IDE 中，单击 **<svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-copilot\" aria-label=\"copilot\" role=\"img\"><path d=\"M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z\"></path><path d=\"M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z\"></path></svg>Copilot** 以打开菜单。\n2. \\*\\*\n   \\*\\*单击“编辑首选项...”。\n3. 在 **GitHub Enterprise “身份验证终结点** ”字段中，输入访问 GitHub的 URL。 例如：`https://octocorp.ghe.com`。\n4. 单击“应用”。\n5. 再次打开\\*\\*<svg version=\"1.1\" width=\"16\" height=\"16\" viewBox=\"0 0 16 16\" class=\"octicon octicon-copilot\" aria-label=\"copilot\" role=\"img\"><path d=\"M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z\"></path><path d=\"M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z\"></path></svg>Copilot\\*\\* 菜单，然后单击“**登录到GitHub**”。\n\n</div>"}