> For the complete documentation index, see [llms.txt](https://docs.verge.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.verge.io/run-the-platform/zh/shen-fen-yan-zheng/multifactor-auth.md).

# 双因素认证（MFA）

双因素认证（也称为多因素认证或 MFA）是一个强烈推荐的选项，可为用户登录提供显著的额外安全层。启用双因素认证后，登录除了需要用户名和密码外，还需要通过用户的电子邮件地址或 TOTP 认证程序进行授权。

## 使用 TOTP 应用程序的双因素认证

用户使用 TOTP 认证应用程序，通常安装在其移动设备上，例如 Google Authenticator 或 Microsoft Authenticator。用户将在其认证应用中将 VergeIO 配置为一个账户；这可以通过在 VergeOS 用户界面中扫描提供的 QR 码轻松完成。随后，认证应用将持续生成一个新代码，供用户在登录时输入。TOTP 应用生成的每个代码通常仅在 30 秒或更短时间内有效。

## 使用电子邮件的双因素认证

用户首次从新设备发起登录时，安全代码会发送到用户的电子邮件地址。随后必须输入该代码才能完成登录过程。或者，用户可以选择将安全代码存储在本地设备上，以便在同一本地设备后续登录时自动检索。（此功能适用于个人设备，例如用户的家用电脑、个人笔记本电脑、手机等。）

{% hint style="info" %}
**首选 TOTP 方法**

* TOTP 提供更高的安全性，因为它不依赖可能被攻破的电子邮件账户。TOTP 在单独的设备上生成，例如手机，因此更难被攻击者截获。
* 一旦完成设置，基于 TOTP 的 MFA 即使没有互联网连接也能工作，而电子邮件则需要互联网访问才能接收验证码。
* 基于电子邮件（而非基于 TOTP）的 MFA 通常只应考虑用于低权限、非关键账户。
  {% endhint %}

## 双因素认证的系统设置

要访问这些设置，请导航至 **系统 > 设置 > 高级设置**.

1. **双因素认证：**
   * ***默认禁用（关闭）*** - 新用户创建时双因素认证处于禁用状态；可按用户单独启用。
   * ***默认启用*** - 新用户创建时双因素认证选项处于启用状态；可按用户单独禁用。
   * ***必需*** - 所有用户都会自动设置为使用双因素认证；任何用户都无法禁用该选项。
2. **临时代码的双因素认证过期时间（秒）：**\
   **默认 = 300 秒（5 分钟）** - 此设置决定安全代码的有效时长。例如，使用默认设置 300 秒时，必须在代码发出后的 5 分钟（300 秒）内输入。
3. **已验证用户设备的双因素认证过期时间（0 表示永不过期）：**\
   **默认 = 7884000 秒（约 91 天）** - 此设置决定安全代码在用户本地设备上存储的时长。例如：在将该设置更改为 864000 的系统中，用户登录到一台笔记本电脑，使用通过电子邮件收到的安全代码并选择标有“这是一台私人电脑”的选项；安全代码将被存储，并在该设备上为用户自动应用 864000 秒（10 天），因此在接下来的 10 天内，用户在所有登录尝试中都无需再次从电子邮件中获取安全代码并重新输入。如果系统设置为 0，本地存储的安全代码将没有过期时间。

### 为用户启用双因素认证

{% hint style="success" %}
如果系统设置： *双因素认证* 设置为 *必需*，则所有用户都会自动启用双因素认证，并且该选项不会显示在用户编辑表单中。
{% endhint %}

1. 从顶部菜单中导航到 **系统** > **用户**.
2. 单击以 **选择所需的用户**.
3. 单击 **编辑** 左侧菜单中的。
4. 选择复选框选项 **双因素认证**.
5. 该 **电子邮件地址** 在启用双因素认证时，该字段变为必填。请确认已为用户输入有效且可访问的电子邮件地址，因为安全代码（登录所需）将发送到指定的电子邮件地址。
6. 单击 **提交** 以保存更改。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.verge.io/run-the-platform/zh/shen-fen-yan-zheng/multifactor-auth.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
