# 身份验证文档

使用密码、令牌、SSH 密钥和更多方式安全地在 GitHub 进行身份验证，并保护您的帐户。

## Recommended

* [关于 GitHub 的身份验证](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/about-authentication-to-github)

  可以通过对 GitHub 进行身份验证，从而安全地访问帐户的资源，并根据身份验证的位置使用不同的凭据。

* [使用 SSH 连接到GitHub](/zh/enterprise-server@3.21/authentication/connecting-to-github-with-ssh)

  可以使用安全外壳协议（SSH）连接到GitHub，该协议通过不安全的网络提供安全通道。

* [管理提交签名验证](/zh/enterprise-server@3.21/authentication/managing-commit-signature-verification)

  GitHub 将验证 GPG、SSH 或 S/MIME 签名，以便其他人知道提交来自受信任的源。

* [配置双重身份验证](/zh/enterprise-server@3.21/authentication/securing-your-account-with-two-factor-authentication-2fa/configuring-two-factor-authentication)

  您可以选择多个选项，以向帐户添加第二个身份验证源。

* [使用密钥登录](/zh/enterprise-server@3.21/authentication/authenticating-with-a-passkey/signing-in-with-a-passkey)

  你可以在浏览器中使用密钥安全轻松地登录到 GitHub，而无需密码和双因素身份验证。 还可以在附近的设备上使用密钥登录。

* [管理个人访问令牌](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)

  在命令行或 API 中验证身份时，可以使用personal access token来代替GitHub密码。

* [从存储库中删除敏感数据](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository)

  如果可以与已克隆存储库的所有人仔细协调，并愿意管理副作用，则可以从存储库的历史记录中移除敏感数据\_\_。

* [丢失 2FA 凭据时恢复帐户](/zh/enterprise-server@3.21/authentication/securing-your-account-with-two-factor-authentication-2fa/recovering-your-account-if-you-lose-your-2fa-credentials)

  如果无法访问双重身份验证凭据，您可以使用恢复代码或其他恢复选项重新获取对帐户的访问权限。

* [错误：权限被拒绝（公钥）](/zh/enterprise-server@3.21/authentication/troubleshooting-ssh/error-permission-denied-publickey)

  “权限被拒绝”错误表示服务器拒绝了您的连接。 可能有多个原因，最常见的如下所述。

## Links

### Getting started

* [关于 GitHub 的身份验证](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/about-authentication-to-github)

  可以通过对 GitHub 进行身份验证，从而安全地访问帐户的资源，并根据身份验证的位置使用不同的凭据。

## Articles

* [关于 GitHub 的身份验证](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/about-authentication-to-github)

  可以通过对 GitHub 进行身份验证，从而安全地访问帐户的资源，并根据身份验证的位置使用不同的凭据。

* [创建强密码](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/creating-a-strong-password)

  使用密码管理器创建高强度且唯一的密码，保护您在 GitHub 上的账户。

* [在帐户之间切换](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/switching-between-accounts)

  了解如何在多个 账户 之间切换

* [更新GitHub访问凭据](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/updating-your-github-access-credentials)

  GitHub 凭据包括您的密码、访问令牌、SSH 密钥，以及用于与 GitHub 通信的应用程序 API 令牌。 可以自行重置所有这些访问凭据。

* [管理个人访问令牌](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens)

  在命令行或 API 中验证身份时，可以使用personal access token来代替GitHub密码。

* [检查 SSH 密钥](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/reviewing-your-ssh-keys)

  为了保证凭据安全，应该定期审核 SSH 密钥、部署密钥并审查访问你帐户的授权应用程序。

* [审查您的部署密钥](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/reviewing-your-deploy-keys)

  您应审查部署密钥，以确保没有任何未经授权（或可能已受损）的密钥。 您还可以批准有效的现有部署密钥。

* [令牌过期和吊销](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/token-expiration-and-revocation)

  令牌可以过期，也可以由你、你授权的应用程序和 GitHub 本身吊销。

* [审查您的安全日志](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/reviewing-your-security-log)

  你可以查看个人帐户的安全日志，以更好地了解你执行的操作以及其他人执行的与你有关的操作。

* [安全日志事件](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/security-log-events)

  了解个人帐户中的安全日志事件记录。

* [从存储库中删除敏感数据](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository)

  如果可以与已克隆存储库的所有人仔细协调，并愿意管理副作用，则可以从存储库的历史记录中移除敏感数据\_\_。

* [Sudo 模式](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/sudo-mode)

  为了在你执行可能敏感的操作之前确认帐户的访问权限，GitHub.com 会提示进行身份验证。

* [防止未授权的访问](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/preventing-unauthorized-access)

  你可能会从媒体上获悉某起安全事件，例如发现 [Heartbleed bug](http://heartbleed.com/)，或者在你已登录 GitHub 时，你的计算机可能会被盗。 在这种情况下，更改密码可防止未来任何未经授权访问您的帐户和项目。

* [查看和管理您的会话](/zh/enterprise-server@3.21/authentication/keeping-your-account-and-data-secure/viewing-and-managing-your-sessions)

  可以在设置中查看和撤销您的登录会话。

* [关于双重身份验证](/zh/enterprise-server@3.21/authentication/securing-your-account-with-two-factor-authentication-2fa/about-two-factor-authentication)

  双重身份验证 (2FA) 是登录网站或应用时使用的额外保护层。启用 2FA 时，必须使用您的用户名和密码登录，并提供另一种只有您知道或可以访问的身份验证形式。

* [配置双重身份验证](/zh/enterprise-server@3.21/authentication/securing-your-account-with-two-factor-authentication-2fa/configuring-two-factor-authentication)

  您可以选择多个选项，以向帐户添加第二个身份验证源。

* [配置双重身份验证恢复方法](/zh/enterprise-server@3.21/authentication/securing-your-account-with-two-factor-authentication-2fa/configuring-two-factor-authentication-recovery-methods)

  你可以设置多种恢复方法，以便在丢失双重身份验证凭据的情况下访问你的帐户。

* [使用双重身份验证访问GitHub](/zh/enterprise-server@3.21/authentication/securing-your-account-with-two-factor-authentication-2fa/accessing-github-using-two-factor-authentication)

  启用 2FA 后，系统会要求你在登录 GitHub时提供 2FA 身份验证代码以及密码。

* [更改双因素身份验证方法](/zh/enterprise-server@3.21/authentication/securing-your-account-with-two-factor-authentication-2fa/changing-your-two-factor-authentication-method)

  无需完全禁用双因素身份验证 (2FA) 即可更改 2FA 方法。

* [双因素身份验证问题故障排除](/zh/enterprise-server@3.21/authentication/securing-your-account-with-two-factor-authentication-2fa/troubleshooting-two-factor-authentication-issues)

  如果在使用 2FA 验证身份时遇到问题，可以尝试对配置的身份验证方法进行故障排除。

* [丢失 2FA 凭据时恢复帐户](/zh/enterprise-server@3.21/authentication/securing-your-account-with-two-factor-authentication-2fa/recovering-your-account-if-you-lose-your-2fa-credentials)

  如果无法访问双重身份验证凭据，您可以使用恢复代码或其他恢复选项重新获取对帐户的访问权限。

* [禁用个人帐户的双重身份验证](/zh/enterprise-server@3.21/authentication/securing-your-account-with-two-factor-authentication-2fa/disabling-two-factor-authentication-for-your-personal-account)

  如果禁用个人帐户的双重身份验证，可能失去对所属组织的访问权限。

* [关于密钥](/zh/enterprise-server@3.21/authentication/authenticating-with-a-passkey/about-passkeys)

  使用密钥，无需密码和双因素身份验证，即可安全轻松地登录。

* [管理通行密钥](/zh/enterprise-server@3.21/authentication/authenticating-with-a-passkey/managing-your-passkeys)

  登录期间，系统可能会提示注册密钥，你也可以选择在帐户设置中注册新密钥。 对于使用双因素身份验证的用户，您可以将现有符合条件的安全密钥升级为通行密钥。

* [使用密钥登录](/zh/enterprise-server@3.21/authentication/authenticating-with-a-passkey/signing-in-with-a-passkey)

  你可以在浏览器中使用密钥安全轻松地登录到 GitHub，而无需密码和双因素身份验证。 还可以在附近的设备上使用密钥登录。

* [关于 SSH](/zh/enterprise-server@3.21/authentication/connecting-to-github-with-ssh/about-ssh)

  使用 SSH 协议可以连接远程服务器和服务并向它们验证。 使用 SSH 密钥后，您无需在每次访问时都提供用户名和 GitHub，即可连接到 personal access token。 还可以使用 SSH 密钥对提交进行签名。

* [检查现有 SSH 密钥](/zh/enterprise-server@3.21/authentication/connecting-to-github-with-ssh/checking-for-existing-ssh-keys)

  在生成 SSH 密钥之前，您可以检查是否有任何现有的 SSH 密钥。

* [生成新的 SSH 密钥并将其添加到 ssh-agent](/zh/enterprise-server@3.21/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent)

  检查现有 SSH 密钥后，您可以生成新 SSH 密钥以用于身份验证，然后将其添加到 ssh-agent。

* [将新的 SSH 密钥添加到GitHub帐户](/zh/enterprise-server@3.21/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account)

  若要将帐户 GitHub.com 配置为使用新的（或现有的）SSH 密钥，还需要将密钥添加到帐户。

* [测试 SSH 连接](/zh/enterprise-server@3.21/authentication/connecting-to-github-with-ssh/testing-your-ssh-connection)

  设置 SSH 密钥并将其添加到 GitHub 后，可以测试连接。

* [使用 SSH 密钥密码](/zh/enterprise-server@3.21/authentication/connecting-to-github-with-ssh/working-with-ssh-key-passphrases)

  您可以保护 SSH 密钥并配置身份验证代理，这样您就不必在每次使用 SSH 密钥时重新输入密码。

* [使用 SSH 代理转发](/zh/enterprise-server@3.21/authentication/connecting-to-github-with-ssh/using-ssh-agent-forwarding)

  为简化向服务器的部署，您可以设置 SSH 代理转发以安全地使用本地 SSH 密钥。

* [管理部署密钥](/zh/enterprise-server@3.21/authentication/connecting-to-github-with-ssh/managing-deploy-keys)

  了解在自动化部署脚本时管理服务器上的 SSH 密钥的不同方法，以及哪种方法最适合您。

* [恢复 SSH 密钥密码](/zh/enterprise-server@3.21/authentication/troubleshooting-ssh/recovering-your-ssh-key-passphrase)

  如果您丢失 SSH 密钥密码，则根据您使用的操作系统，您可能可以恢复它，也可能需要生成新的 SSH 密钥密码。

* [错误：权限被拒绝（公钥）](/zh/enterprise-server@3.21/authentication/troubleshooting-ssh/error-permission-denied-publickey)

  “权限被拒绝”错误表示服务器拒绝了您的连接。 可能有多个原因，最常见的如下所述。

* [错误：文件编号错误](/zh/enterprise-server@3.21/authentication/troubleshooting-ssh/error-bad-file-number)

  此错误通常表示您无法连接到服务器。 这通常由防火墙和代理服务器造成。

* [错误：密钥已被使用](/zh/enterprise-server@3.21/authentication/troubleshooting-ssh/error-key-already-in-use)

  尝试添加已添加到其他帐户或存储库的密钥时，会发生此错误。

* [错误：用户/仓库拒绝其他用户的权限](/zh/enterprise-server@3.21/authentication/troubleshooting-ssh/error-permission-to-userrepo-denied-to-other-user)

  此错误意味着您使用的密钥绑定到一个没有仓库访问权限的账户。

* [错误：用户/仓库拒绝用户/其他仓库的权限](/zh/enterprise-server@3.21/authentication/troubleshooting-ssh/error-permission-to-userrepo-denied-to-userother-repo)

  此错误意味着您正在推送的密钥作为 deploy key 附加到另一个仓库，并且对您尝试推送到的仓库的没有访问权限。

* [错误：代理承认没有签署](/zh/enterprise-server@3.21/authentication/troubleshooting-ssh/error-agent-admitted-failure-to-sign)

  在极少数情况下，通过 SSH 在 Linux 上连接到 GitHub 会产生错误 `"Agent admitted failure to sign using the key"`。 请遵循以下步骤解决此问题。

* [错误：ssh-add：非法选项 -- apple-use-keychain](/zh/enterprise-server@3.21/authentication/troubleshooting-ssh/error-ssh-add-illegal-option----apple-use-keychain)

  此错误意味着你的 `ssh-add` 版本不支持 macOS 密钥链集成，此集成允许你将密码存储在密钥链中。

* [错误：未知密钥类型](/zh/enterprise-server@3.21/authentication/troubleshooting-ssh/error-unknown-key-type)

  此错误表示您使用的 SSH 密钥类型无法识别或不受 SSH 客户端支持。

* [错误：我们正在进行 SSH 密钥审核](/zh/enterprise-server@3.21/authentication/troubleshooting-ssh/error-were-doing-an-ssh-key-audit)

  此错误意味着无法验证正在用于执行 Git 操作的 SSH 密钥。

* [关于提交签名验证](/zh/enterprise-server@3.21/authentication/managing-commit-signature-verification/about-commit-signature-verification)

  使用 GPG、SSH 或 S/MIME，可以在本地对标记和提交进行签名。 这些标签或提交在 GitHub 上被标记为已验证，这样其他人就可以确信这些更改来自可信来源。

* [检查现有 GPG 密钥](/zh/enterprise-server@3.21/authentication/managing-commit-signature-verification/checking-for-existing-gpg-keys)

  在生成 GPG 密钥之前，您可以检查是否有任何现有的 GPG 密钥。

* [生成新 GPG 密钥](/zh/enterprise-server@3.21/authentication/managing-commit-signature-verification/generating-a-new-gpg-key)

  如果没有现有的 GPG 密钥，您可以生成新的 GPG 密钥以用于签名提交和标记。

* [将 GPG 密钥添加到GitHub帐户](/zh/enterprise-server@3.21/authentication/managing-commit-signature-verification/adding-a-gpg-key-to-your-github-account)

  若要在 GitHub 上将您的账户配置为使用新的（或现有的）GPG 密钥，您还需要将该密钥添加到账户中。

* [将您的签名密钥告知 Git](/zh/enterprise-server@3.21/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key)

  要在本地对提交进行签名，需要向 Git 通知要使用的 GPG、SSH 或 X.509 密钥。

* [将电子邮件与 GPG 密钥关联](/zh/enterprise-server@3.21/authentication/managing-commit-signature-verification/associating-an-email-with-your-gpg-key)

  GPG 密钥必须与符合你的提交者身份的已验证电子邮件关联。

* [对提交签名](/zh/enterprise-server@3.21/authentication/managing-commit-signature-verification/signing-commits)

  使用 GPG、SSH 或 S/MIME，可以在本地对提交进行签名。

* [对标记签名](/zh/enterprise-server@3.21/authentication/managing-commit-signature-verification/signing-tags)

  使用 GPG、SSH 或 S/MIME，可以在本地对标记进行签名。

* [显示所有提交的验证状态](/zh/enterprise-server@3.21/authentication/managing-commit-signature-verification/displaying-verification-statuses-for-all-of-your-commits)

  您可以启用警戒模式进行提交签名验证，以使用签名验证状态标记所有提交和标记。

* [检查您的提交和标签签名验证状态](/zh/enterprise-server@3.21/authentication/troubleshooting-commit-signature-verification/checking-your-commit-and-tag-signature-verification-status)

  你可以在 GitHub 上检查提交和标记签名的验证状态。

* [在 GPG 密钥中使用经过验证的电子邮件地址](/zh/enterprise-server@3.21/authentication/troubleshooting-commit-signature-verification/using-a-verified-email-address-in-your-gpg-key)

  验证签名时， GitHub 检查提交者或标记者电子邮件地址是否与 GPG 密钥标识的电子邮件地址匹配，并且是用户帐户上已验证的电子邮件地址。 这确保密钥确实属于您，并且是由您创建了提交或标签。