---
title: Security
description: 通过双重身份验证和 IP 允许列表保护管理控制台，管理管理员角色，并配置客户登录：通行密钥、Google 和 GitHub、验证码以及阻止的电子邮件域名。
url: https://nexcmp.com/zh-cn/docs/administration/security/
applies_to: NexCMP 1.6.1
updated: 2026-11-02
---

# Security {#security}

> **后台位置：** System › Admin › Console security (`/account`)、Admin users (`/users`)；System › Settings › Customer logins (`/settings/login`)。

## 管理控制台 {#admin-console}

### 双重身份验证 (TOTP) {#two-factor-authentication-totp}

控制台可从互联网访问，因此请启用 TOTP。

1. 打开**System › Admin › Console security**。
2. 在**Two-factor authentication (TOTP)**下点击**Start setup**。
3. 使用 Google Authenticator、Authy、1Password 或 Bitwarden 扫描二维码，然后输入 6 位数字代码。

### 允许的控制台 IP 范围 {#allowed-console-ip-ranges}

在**Allowed console IP ranges**下每行输入一个 IP 或 CIDR（IPv4 或 IPv6）。**留空表示允许任何地方。** 超出此范围的登录和 Admin API 请求都将被阻止。

::: warning 切勿将自己锁在外面
该页面会显示你当前的 IP，并要求新列表中包含它。请使用 **+ Add my IP**。如果无论如何都被锁在外面，请使用来自服务器的[紧急访问](https://nexcmp.com/zh-cn/docs/getting-started/cli-reference/#emergency-access)。
:::

### 更改密码 {#change-password}

填写**Current password**、**New password** 和 **Confirm new password**。请使用长且独特的密码（12 个字符或以上；安装向导对首个管理员强制要求 12 个字符）。

### 管理员账号与角色 {#administrator-accounts-and-roles}

打开**System › Admin › Admin users**并使用 **+ Create account**。

| 角色 | 访问权限 |
|---|---|
| `admin` | 对 Admin API 的完全访问权限 |
| `staff` | 整个系统的只读权限 |
| `user` | 单个客户资源的只读视图 |

根账号是在[安装向导](https://nexcmp.com/zh-cn/docs/getting-started/setup-wizard/)中创建的账号。行操作：**Edit**、**Reset PW**、**Key**、**Delete**。密码以加盐哈希存储；更改或锁定账号会立即终止其会话。

## 客户登录 {#customer-sign-in}

打开**System › Settings › Customer logins**。

| 设置 | 功能说明 |
|---|---|
| **Google sign-in** | 启用后输入OAuth客户端ID与密钥。将页面上显示的**Callback URL**复制到*Google Cloud Console › APIs & Services › Credentials › OAuth client ID › Authorized redirect URIs*中。使用**Test configuration**。 |
| **GitHub login** | 同理，对应 *GitHub › Settings › Developer settings › OAuth Apps › Authorization callback URL* |
| **Passkey** | 指纹、PIN码或硬件密钥登录；默认开启。Passkey绑定于域名，每个分销商域名独立运行。品牌重塑后可在 *Legacy passkey Domain* 中输入旧域名，以便为客户提供友好提示 |
| **添加登录方式时重新认证** | 添加Passkey或关联Google/GitHub之前再次要求输入密码（默认关闭） |
| **Captcha** | 注册时启用Cloudflare Turnstile或Google reCAPTCHA：启用、选择提供商、输入站点密钥和密钥 |
| **Block e-mail domains** | 每行一个域名（最多2000个）。注册时匹配的地址将被拒绝，并显示`email_domain_blocked` |

![显示带有回调URL的Google登录页面的客户登录页](https://nexcmp.com/zh-cn/docs/images/administration/security-01-customer-logins.webp)

### 内置策略 {#built-in-policies}

| 策略 | 值 |
|---|---|
| Customer password | 至少10个字符，包含字母和数字 |
| Customer session | 30天；“以客户身份登录”的会话持续1小时 |
| E-mail verification | 如果在销售设置中启用了*require e-mail verified*，则在创建虚拟机前必须验证 |
| Anti-carding | 账户余额低于最低充值额时，只能创建数量有限的虚拟机 |

## 服务器加固 {#server-hardening}

- 安装并配置TLS后，端口3000会关闭；详见[Installation](https://nexcmp.com/zh-cn/docs/getting-started/installation/#the-panel-port-3000)。
- 服务以无特权的`nexcmp`用户身份运行，并带有受限制的systemd沙箱。
- API密钥、支付凭证和SMTP密码均加密存储；主密钥位于`/var/lib/nexcmp/secrets` — 请保护好[backups](https://nexcmp.com/zh-cn/docs/getting-started/backup-and-restore/)。
- 安装前会使用SHA-256和Ed25519签名对版本进行验证。


