Phase 9: Security & User Management
Bài 9.1: RBAC, Realm, User + Role
Lý thuyết cốt lõi
Authentication Realm:
pam: user Linux trên host (root@pam)pve: user nội bộ Proxmox (backup@pve)ad: Active Directoryldap: OpenLDAPopenid: OAuth/OIDC (Keycloak, Azure AD)
Role (tập quyền):
Administrator: fullPVEAdmin: như Administrator nhưng không sửa userPVEVMAdmin: quản lý VMPVEVMUser: console + start/stop VM (không tạo/xoá)PVEAuditor: read-only- Custom role: tự tạo
Permission path:
/→ toàn cluster/nodes/pve01→ 1 node/vms/100→ 1 VM/storage/local→ 1 storage/pool/production→ resource pool
Bài tập thực hành
Tạo user cho team dev, chỉ quản lý VM trong pool "dev":
# 1. Tạo pool
pvesh create /pools --poolid dev
# 2. Move VM 200 vào pool
qm set 200 --pool dev
# 3. Tạo user
pveum user add devuser@pve --password 'DevP@ss123' --comment 'Developer'
# 4. Assign role PVEVMAdmin cho user trên pool
pveum acl modify /pool/dev --users devuser@pve --roles PVEVMAdmin
# 5. Test: login devuser@pve, chỉ thấy VM trong pool dev
Kết quả đầu ra
$ pveum user list
┌──────────────┬────────┬────────┬─────────┬──────────┬────────────┐
│ userid │ enable │ expire │ email │ firstname│ comment │
├──────────────┼────────┼────────┼─────────┼──────────┼────────────┤
│ root@pam │ 1 │ 0 │ │ │ │
│ devuser@pve │ 1 │ 0 │ │ │ Developer │
└──────────────┴────────┴────────┴─────────┴──────────┴────────────┘
Ứng dụng thực tế
Self-service portal: 50 developer, mỗi người 1 pool riêng, được phép tạo tối đa 3 VM. Set quota qua pvesh set /pools/<id>/limits.
Bài 9.2: Integrate Active Directory + 2FA
Lý thuyết cốt lõi
AD integration:
- Thêm realm
ad, users AD login được Web GUI Proxmox - Hoặc LDAP mode cho AD (ổn định hơn)
2FA Proxmox hỗ trợ:
- TOTP (Google Authenticator, Authy)
- WebAuthn / YubiKey
- Recovery keys
Bài tập thực hành
Add AD realm:
pveum realm add corp --type ad \
--domain lab.local \
--server1 dc01.lab.local \
--port 636 --secure 1
Test login user@corp, user đang có trong AD:
pvesh get /access/users | grep @corp
Enable TOTP cho user:
- Login Web GUI → user icon → TFA → Add TOTP → scan QR bằng Google Authenticator → nhập mã 6 số confirm.
Hoặc CLI:
pveum user tfa new devuser@pve --type totp
Kết quả đầu ra
$ pveum user list --full
userid | realm-type | enable | tfa |
root@pam | pam | 1 | - |
devuser@pve | pve | 1 | totp |
john.doe@corp | ad | 1 | webauthn |
Troubleshooting
- AD bind fail: kiểm tra
ldapsearch -x -H ldaps://dc01.lab.local ... - 2FA reset khi mất phone: admin chạy
pveum user tfa delete devuser@pve --force
Ứng dụng thực tế
Compliance bắt buộc 2FA admin → set policy tfa trong realm, user chưa enable TOTP bị chặn login.
Bài 9.3: SSL certificate + Let's Encrypt
Lý thuyết cốt lõi
Proxmox dùng self-signed cert mặc định → browser cảnh báo.
Option:
- Upload cert riêng (corporate CA)
- Let's Encrypt ACME (tự động renew)
Bài tập thực hành
ACME với Let's Encrypt (port 80 phải mở ra Internet):
# 1. Đăng ký account
pvenode acme account register default [email protected]
# 2. Add domain
pvenode config set --acme domains=pve01.lab.example.com
# 3. Issue + install cert
pvenode acme cert order
# 4. Auto renew (cron đã có sẵn)
systemctl list-timers | grep acme
Kết quả đầu ra
$ pvenode acme cert order
Loading ACME account details
Placing ACME order
Order URL: https://acme-v02.api.letsencrypt.org/acme/order/...
Status: valid
...
SUCCESS: certificate successfully deployed for 'pve01.lab.example.com'
Browser → https://pve01.lab.example.com:8006 → padlock xanh.