

```markdown
# LXConsole 接入 LXD/Incus（客户端证书方式）

让 LXConsole 通过证书安全连接远程 LXD 或 Incus 服务器。

## 步骤

### 1. 在 LXD/Incus 服务器创建证书文件
文件名为 `lxconsole.crt`，内容完整粘贴：

```text
-----BEGIN CERTIFICATE-----
MIIE3TCCAsUCCFxcBXc/+MXGMA0GCSqGSIb3DQEBDQUAMDExEjAQBgNVBAsMCUxY
Q09OU09MRTEbMBkGA1UEAwwSQ2xpZW50IENlcnRpZmljYXRlMB4XDTI2MDMwNjA1
NDgzMVoXDTM2MDMwMzA1NDgzMVowMTESMBAGA1UECwwJTFhDT05TT0xFMRswGQYD
VQQDDBJDbGllbnQgQ2VydGlmaWNhdGUwggIiMA0GCSqGSIb3DQEBAQUAA4ICDwAw
ggIKAoICAQC3YTwc6Hl9nR/v1MZuvn2brDU6Duq3TVi+aOkvg6ZSfWGtJ012TAXG
YScZ5X3TUfCBLfiLZR7v91YKZkAbQ8uv0Ixgg0SeiY5tEHjdtlbDw98htQRxCrFZ
XmbYCwd67imAPojMEhT5YwKd0Uzn7PikzjiFqYjOJ7RFtBxA/S4GqpOmSX23LiLC
Z/vHds/Oile7mSjPAac8mX2H+kueZuqGUsZG701O9NVOJctaVZYaP+CWz2BnxjlT
6jNBprKkBUL+kgUnaE58P0ITtylAn/ys3Shdm0cbmJw1s1U0RALsmXTch7uxh3O8
NV4U5wvWDLFJy8jcHesH5icWyRwXNzRYhls5bOwPGaKTPqhV8Iyc8cSJL3eg/Iiz
lJCKLEY/lBcimmF0ShAZp6abwrQ7n+zut1OHV2x/x2myFaDbqNsptqdpwodAwtEA
1RTH+Tqxt/OabTL5U++BKWEamWiJItISqKmPOOXC2Ll7QpaBbdTBoPguFXxQAiET
WIy2E3diN3fHrVAmvMHFsOigtRYYbyipycmc6GWJUez4ijFYBupLrJ5eFEbx0ES5
F32Z/mXYQJYGADCPf7ZKzTyGRE3HTV8jviUs92/saKTj7/vXBm/bDVKnqbFScfK1
k61YxII1A3yZfd2PPzZKMUjGAo4lPnN5SVLyMUggpuIGpzYKtebeyQIDAQABMA0G
CSqGSIb3DQEBDQUAA4ICAQBe1EhJ5D9ooA/2dtyYUivfDn9zr15jOlNVCcbrQ9eH
xmdUFqY0eE4cbyKeT6c8QE76ud2+D268gwAjNQ6vHB8zJHPWuTzsv37hsrTVZozA
Z/QZH+GfB2K3LNzTEJkyCRJYKdx+BLi054Lw8eYdJJEelb/o2YrPC4OmMCSTqMeb
dQyjrpaXQrFik4PWK8RxCuawDx0U+LiqTro5fS3QBOV3c9pY0hE5GZtYc03SUCfs
3bf1W2tPM5msQgrJ/wVUJ6rmljWGMyeW2YsiibsU4YASWkOYOsjmmS9rQIP635NZ
fMT5eF7xGKYPgYn3iNa8Co9av0MIj17BINGzmPxAIuR0K/bcT5IA9itD2Yym4YyL
CavLfExinMKl6nA3mrosBoogl68hX/xcFvTIoj4jIY1eeKcRhchFEZ5hE1mAeEWu
4EIjdeI3g6TAZFGxGQQMoIIxA7hfdSzISvnXXnNZFvCrGWjUpbM+mn5lOgrJW+Bp
cN9S3TguArYvuXQNR/QoG8HFl0WjuItbCRUB0BhwOHYWe6B3yFUsuVEHdtxj7SGS
0KdmI2PXX0sf4jyJiv/IRYbGkgYG0rVJB7asTratRTZDBsAexsTBLDEweFFn3hLv
Jwn2mGV1+U6ulqge9X/XQyoJr/Z/gwSFtNedY9JwDr0zG7L1yYrWDtiShbrv1Vyy
1g==
-----END CERTIFICATE-----
```

```bash
nano lxconsole.crt   # 粘贴 → 保存退出
```

### 2. 导入信任

- LXD  
  ```bash
  lxc config trust add lxconsole.crt
  ```

- Incus  
  ```bash
  incus config trust add-certificate lxconsole.crt
  ```

验证：  
```bash
lxc config trust list   # 或 incus config trust list
```

### 3. 开启远程监听（非集群）

- LXD  
  ```bash
  lxc config set core.https_address [::]
  ```

- Incus  
  ```bash
  incus config set core.https_address=[::]:8443
  ```

### 4. 防火墙放行（若启用）

```bash
ufw allow 8443
```

### 5. LXConsole 面板添加服务器

- URL：`https://你的服务器IP:8443`  
- 认证：**Client certificate**  
- 首次连接通常需接受服务器证书

完成。

## 快速排查

- 证书未导入 → 检查 `trust list`  
- 端口不通 → `telnet IP 8443`  
- 日志 → `lxc monitor` 或 `journalctl -u snap.lxd.daemon`
