vault backup: 2026-01-05 14:26:17

This commit is contained in:
windyboy
2026-01-05 14:26:17 +08:00
parent be7c6cdcc9
commit 40f3fe3eb8
290 changed files with 1947 additions and 282 deletions
@@ -0,0 +1,201 @@
应用系统名称: 广州市投资项目信息化平台
用户单位: 广州市发展和改革委员会
使用架构(单机/主备/读写分离/其他) :2节点主备(自动切换)
正式or测试环境:正式环境
物理机or虚拟机:物理机
操作系统:Kylin Linux Advanced Server release V10 (Tercel)
CPU信息:Kunpeng-920
CPU(s): 96
内存:254G
备份是否独立磁盘:否
备份策略 --暂未配置
存储信息:
--主库
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/data-data 1.0T 18G 1007G 2% /data
--备库
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/data-data 1.0T 18G 1007G 2% /data
2节点主备集群,自动切换模式
10.201.23.102 主库
10.201.23.103 备库
10.209.42.16 监控
1、数据库基本信息:
数据库页大小:32K
数据库簇大小:32K
数据库字符集:UTF-8
数据库大小写是否敏感:不敏感
数据库实例名:GRP1_DW_01/GRP1_DW_02
数据库名:dmdb
数据库超级管理员账号/密码:SYSDBA/Hn@dameng123 #数据库系统用户密码修改后妥善保存,一旦丢失无法找回。
数据库审计员账号/密码:SYSAUDITOR/SYSAUDITOR
数据库安全员账号/密码:SYSSSO/SYSSSO
数据库默认端口:35239
数据库安装版本:
---------- -----------------------------------------
1 --05134284194-20240814-239099-20108 Pack10
---------- ---------------------------------
1 DM Database Server 64 V8
2 8.4
3 安全版
4 DB Version: 0x7000c
5 05134284194-20240814-239099-20108
6 Msg Version: 12
7 Gsu level(5) cnt: 0
授权编号:2B01108287 (测试授权)
产品有效期:2024-12-25
数据库软件安装路径:/home/dmdba/dmdbms
数据库数据文件路径:/data/dmdata/
数据库归档文件路径:/data/dmdata/dmarch
归档空间限制:100G #如果不够可调整
数据库备份文件路径:暂未配置备份
数据库驱动路径:/home/dmdba/dmdbms/drivers
数据库文档路径:/home/dmdba/dmdbms/doc
数据库日志路径:/home/dmdba/dmdbms/log
dmdba用户密码: Hn@dameng123
注意:请创建新的表空间和用户供业务使用,切勿使用系统默认的用户(SYSDBA)和表空间(main)。
2、数据库客户端命令工具:
su - dmdba
cd /home/dmdba/dmdbms/bin
./disql SYSDBA/'"Hn@dameng123"':5236
说明:密码含特殊字符使用单引号+双引号包围起来
3、数据库图形化管理工具:
客户端管理工具:manager
cd /home/dmdba/dmdbms/tool
./manager
4、数据库数据迁移工具:
./dts
5、数据库服务重启步骤:
切换至dmdba用户:
su - dmdba
cd /home/dmdba/dmdbms/bin
关闭确认监视器(监视器服务器): ./DmMonitorServiceGRP1 stop
关闭主库守护进程:./DmWatcherServiceGRP1 stop
关闭备库守护进程:./DmWatcherServiceGRP1 stop
关闭主库实例:./DmServicedmdb stop
关闭备库实例:./DmServicedmdb stop
启动主库实例:./DmServicedmdb start
启动备库实例:./DmServicedmdb start
启动主库守护进程:./DmWatcherServiceGRP1 start
启动备库守护进程:./DmWatcherServiceGRP1 start
启动确认监视器(监视器服务器): ./DmMonitorServiceGRP1 start
查看数据库服务进程
ps -ef|grep dmserver
6,管理工具的安装使用(管理工具可跟商务申请)
##管理工具下载(WIN
https://eco.dameng.com/download/
##管理工具的安装使用(安装选择组件,只安装客户端就行)
https://eco.dameng.com/document/dm/zh-cn/start/install-dm-windows-prepare.html
7、应用配置链接主备集群的配置:
方法一:
在中间件或者应用服务器上,新建/etc/dm_svc.conf配置文件。
①文件存放:
Linux:将dm_svc.conf文件放在应用服务器和中间件服务器/etc目录下。
Windows32位:将dm_svc.conf文件放在应用服务器system32目录下。
Windows64位:将dm_svc.conf文件放在应用服务器system32和syswow64目录下。
vi /etc/dm_svc.conf
TIME_ZONE=(480)
LANGUAGE=(cn)
DMDW=(10.201.23.102:35239,10.201.23.103:35239)
[DMDW]
LOGIN_ENCRYPT=(0)
LOGIN_MODE=(1)
说明:客户端程序连接数据库时,需要指定 IP 端口处替换为服务名即可,
例如:disql SYSDBA/'"Hn@dameng123"'@DMDW。jdbc的url为:jdbc:dm://DMDW
注意:
1)当修改了 dm_svc.conf 内容后,需要重启客户端程序,修改的配置才能生效。
2)请把该文件路径授予666权限。
方法二:
集群连接服务名和ip配置参数直接配置在URL连接串
JDBC服务连接配置说明
配置应用连接串:(JDBC连接串选项请参考《DM程序员手册》中的4.5.4 DM 扩展连接属性的使用)
主备集群:
非xml文件:
jdbc:dm://DMDW?DMDW=(10.201.23.102:35239,10.201.23.103:35239)&LOGIN_MODE=(1)
xml文件:
jdbc:dm://DMDW?DMDW=(10.201.23.102:35239,10.201.23.103:35239)&LOGIN_MODE=(1)
8,创建用户和表空间,禁止使用系统默认的用户(SYSDBA)和表空间(main)存放业务数据。
示例:
- 创建用户
create user test identified by "Hn@dameng123";
- 用户角色分配,管理工具上看有什么角色,根据具体情况而定,DBA角色应该是不用分配给应用账号的。
grant resource,public,soi,vti,svi to test;
select * from dba_role_privs where grantee='TEST';
-创建表空间,指定用户的默认表空间
(数据文件存放在跟其他数据文件一样的就行,注意文件名不能一样,以下指定每个数据文件10G,视实际情况而定,不够再加数据文件,要留意空间是否足够)
select * from v$tablespace;
select path from v$datafile;
//数据表空间
create tablespace test datafile '/data/dmdata/dmdb/test01.dbf' size 1024 autoextend on next 128 maxsize 10240;
alter tablespace test add datafile '/data/dmdata/dmdb/test02.dbf' size 128 autoextend on next 128 maxsize 10240;
//索引表空间
create tablespace test_index datafile '/data/dmdata/dmdb/test_index01.dbf' size 128 autoextend on next 128 maxsize 10240;
//设置用户的默认表空间
alter user test default tablespace test;
alter user test default index tablespace test_index;
//查询用户表空间信息
select username,user_id,default_tablespace,default_index_tablespace
from dba_users;
====普通监视器查看集群状态
在主备节点均部署普通监视器,可以用于日常查看集群状态
切换dmdba用户
su - dmdba
cd /home/dmdba/dmdbms/bin
dmmonitor /data/dmdata/dmdb/dmmonitor_GRP1.ini
=== 手动切换主库(打开监视器后)
示例:
dmmonitor /data/dmdata/dmdb/dmmonitor_GRP1.ini
login
用户名:SYSDBA
密码:Hn@dameng123
switchover GRP1.GRP1_DW_02
@@ -0,0 +1,372 @@
## 一、远程桌面
### Office Windows Desktop
- **TeamViewer 设备号**
```
299 885 389
```
- **密码**
```
Admingzzn@1
```
### VM Windows 10
- **rdesk**
```
1 269 698 093
```
```
a4pvYPW2YO3aER
```
todesk
```
487 821 301
```
```
a4pvYPW2YO3aER=
```
### GZZN Opensuse Desktop
rustdesk
```
1135993583
```
```
4ZZzxrAfwFj5q1
```
rustdesk 中继密码
```
4BWKesxFCiKVPj7j6Zm7qV4JW8FtvRXZY1Zejv4nGxk=
```
## 二、服务器信息
### 服务器密码
```
8VLtg#ZYA@AJSFJcPM
```
### 服务器使用
- 主机:103
- 调整内存:100GB
---
## 三、二期资源
### 主机 10.194.62.26
```
Gzzwy@%2020$
```
### 内存百分比脚本
```bash
#!/bin/bash
free -h
echo "内存使用百分比: $(free | awk 'NR==2{printf "%.2f%%", $3*100/$2 }')"
```
---
## 四、工具与探针
### 工具下载
```bash
curl -k http://10.205.205.26:9092/tools/sh | bash
```
### 探针安装
```bash
curl -k https://10.207.33.1:9000/up-install/up-install.sh | bash -x
```
### 安装失败节点
- 10.209.42.14
- 10.209.42.15
- 10.209.42.18
- 10.209.42.20
- 10.209.42.21
- 10.209.42.22
### 探针测试
```bash
nc -uvz 10.207.33.1 12201
systemctl status uniprobe
```
### 手动运行探针
```bash
bash -x /usr/local/bin/uniprobe-worker.sh -n 10.207.33.1:9000 \
-a 1qgmg9koe1v2s998jsceikklontia2v9nact3gumfk6mkcd02251 \
> /tmp/uniprobe/test.txt 2>&1
```
上传日志:
```bash
rz /tmp/uniprobe/test.txt
```
### 抓包验证
```bash
tcpdump -i any port 12201 -w a.pcap
```
---
## 五、数据迁移生产环境
### 1. MinIO 迁移
- 迁移桶:**fgw-law**
- URL: `http://130.120.3.126:9000`
- key: `GZZNEXAMPLE`
- secret: `wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY`
- bucketName: `fgw-law`
MinIO 客户端配置:
```bash
mc alias set src http://130.120.3.126:9000 GZZNEXAMPLE wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
```
---
### 2. Elasticsearch 迁移
- 索引:**fgw_law_file_index**
- uris: `10.100.100.187:9200,10.100.100.188:9200,10.100.100.189:9200`
- 用户名: `elastic`
- 密码: `yjj@2022EmS,12`
#### elasticdump 工具
```bash
docker pull elasticdump/elasticsearch-dump
```
**导出 Mapping**
```bash
docker run --rm --network host -v "$PWD:/dump" elasticdump/elasticsearch-dump \
--input=http://elastic:yjj%402022EmS%2C12@localhost:9200/my_index \
--output=/dump/my_index_mapping.json \
--type=mapping --debug
```
**导出 Mapping + Data**
```bash
# Mapping
sudo docker run --rm --network host \
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
-v "$PWD:/dump" elasticdump/elasticsearch-dump \
--input="https://elastic:yjj%402022EmS%2C12@127.0.0.1:9200/fgw_law_file_index" \
--output="/dump/fgw_law_file_index_mapping.json" \
--type=mapping --timeout=300000
# Data
sudo docker run --rm --network host \
-e NODE_TLS_REJECT_UNAUTHORIZED=0 \
-v "$PWD:/dump" elasticdump/elasticsearch-dump \
--input="https://elastic:yjj%402022EmS%2C12@127.0.0.1:9200/fgw_law_file_index" \
--output="/dump/fgw_law_file_index_data.json" \
--type=data --limit=2000 --concurrency=4 --fileSize=100mb --timeout=300000
```
#### Snapshot 方式
**注册仓库**
```bash
curl -s -H 'Content-Type: application/json' \
-X PUT 'http://127.0.0.1:8200/_snapshot/local_backup' \
-d '{"type":"fs","settings":{"location":"/snapshots","compress":true}}'
```
**创建快照**
```bash
curl -s -H 'Content-Type: application/json' \
-X PUT 'http://127.0.0.1:8200/_snapshot/local_backup/fgw_2025_09_03?wait_for_completion=true' \
-d '{
"indices": "fgw_law_file_index",
"ignore_unavailable": true,
"include_global_state": false
}'
```
**校验快照**
```bash
curl -s 'http://127.0.0.1:8200/_snapshot/local_backup/fgw_2025_09_03?pretty'
```
**打包快照**
```bash
tar czf /opt/elastic/fgw_law_snapshot_2025-09-03.tgz -C /opt/elastic/snapshots .
```
**恢复(相同索引名)**
```bash
curl -s -H 'Content-Type: application/json' \
-X POST 'http://127.0.0.1:8200/_snapshot/local_backup/fgw_2025_09_03/_restore' \
-d '{
"indices": "fgw_law_file_index",
"include_global_state": false
}'
```
**恢复(新索引名)**
```bash
curl -s -H 'Content-Type: application/json' \
-X POST 'http://127.0.0.1:8200/_snapshot/local_backup/fgw_2025_09_03/_restore' \
-d '{
"indices": "fgw_law_file_index",
"rename_pattern": "fgw_law_file_index",
"rename_replacement": "fgw_law_file_index_restored",
"include_global_state": false
}'
```
---
### 3. MongoDB 迁移
- 数据库:**fgw_v3**
- host: `10.100.101.101`
- 用户名: `fgw_v3`
- 密码: `Fgw@2024`
- 端口: `27017`
**导出**
```bash
/opt/mongodb/mongodb-database-tools-100.9.4/bin/mongodump \
--host 10.100.101.101 --port 27017 \
-u 'fgw_v3' -p 'Fgw@2024' \
--db fgw_v3 \
--authenticationDatabase fgw_v3 \
--authenticationMechanism SCRAM-SHA-256 \
--archive=/opt/mongodb/export/fgw_v3_$(date +%F).archive.gz \
--gzip
```
**另一种导出方式**
```bash
sudo mongodb-database-tools-100.9.4/bin/mongodump -u fgw_v3 -p Fgw@2024 -h localhost \
--db fgw_v3 --archive=fgw_v3-$(date +%F).gz --gzip
```
**导入**
```bash
/data/soft/mongodb-database-tools-100.9.4/bin/mongorestore \
--host localhost --port 27017 \
-u 'fgw_v3' -p 'FgwV3@202403' \
--authenticationDatabase fgw_v3 \
--authenticationMechanism SCRAM-SHA-256 \
--archive=/data/tmp/fgw_v3.archive.gz --gzip
```
---
10.209.42.20 mongo
```
VOLUME_DB=$(docker inspect mongodb | jq -r '.[0].Mounts[] | select(.Destination=="/data/db") | .Source')
echo $VOLUME_DB
ls -l $VOLUME_DB
```
更新监控软件
```bash
curl -k http://10.205.205.26:9092/tools/sh | bash
```
```bash
systemctl status pp-monitor
```
服务器移交:
10.209.42.19 zookeeper
新密码:
```
uve|ph7ro9bieCh#
```
```
echo -e 'uve|ph7ro9bieCh#\nuve|ph7ro9bieCh#' | passwd
```
@@ -0,0 +1,280 @@
太好了 — 你已经贴出了 `password-auth` 的当前内容,基于它我会直接给出**可复制的、安全步骤**:先备份,再替换为建议的密码策略(使用 `pam_pwquality`,最小长度 12、`difok=3`、至少 3 类字符、并在 `pam_unix` 上启用密码历史 `remember=5`)。同时我会说明为什么这样改、如何测试,以及如何回滚。
> 说明:我保留 `pam_pwquality` 为 `requisite`(与你当前一致),因为这会在强度检查失败时立即终止并拒绝密码更改,减少后续模块运行。但如果你希望即使强度检查失败也执行后续模块(例如记录历史或其它处理),可以把它改成 `required`。我在下面也给出小备注。
---
## 一步一步来(复制黏贴即可)
1. 先备份原文件:
```bash
cp /etc/pam.d/password-auth /etc/pam.d/password-auth.bak.$(date +%F_%T)
ls -l /etc/pam.d/password-auth*
```
2. 将下面内容写入临时文件并做替换(安全写入):
```bash
cat <<'EOF' | tee /etc/pam.d/password-auth.new >/dev/null
# /etc/pam.d/password-auth - modified recommended settings
auth required pam_kysec.so
#%PAM-1.0
auth required pam_env.so
auth required pam_faillock.so preauth audit deny=3 even_deny_root unlock_time=60
#auth sufficient pam_fprintd.so
auth sufficient pam_unix.so nullok try_first_pass
#auth sufficient pam_sss.so use_first_pass
auth [default=die] pam_faillock.so authfail audit deny=3 even_deny_root unlock_time=60
auth sufficient pam_faillock.so authsucc audit deny=3 even_deny_root unlock_time=60
auth requisite pam_succeed_if.so uid >= 1000 quiet_success
auth required pam_deny.so
account required pam_unix.so
account sufficient pam_localuser.so
account sufficient pam_succeed_if.so uid < 1000 quiet
#account [default=bad success=ok user_unknown=ignore] pam_sss.so
account required pam_permit.so
# Password quality: enforce length, classes, difok
# - minlen=12 : minimal length (increase if you want stronger)
# - difok=3 : new password must differ in at least 3 characters from old
# - minclass=3: at least 3 character classes (uppercase, lowercase, digit, other)
# - u/l/d/ocredit -1 : require at least one of each (set ocredit=0 to make special char optional)
password requisite pam_pwquality.so retry=3 minlen=12 difok=3 minclass=3 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=0 local_users_only
# UNIX module performs the actual password change and supports history
# remember=5 : prevent reuse of last 5 passwords
password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok remember=5
# If you have SSSD and want it to accept the token, uncomment below (but test first)
#password sufficient pam_sss.so use_authtok
password required pam_deny.so
session optional pam_keyinit.so revoke
session required pam_limits.so
#session optional pam_systemd.so
session [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session required pam_unix.so
#session optional pam_sss.so
EOF
```
```bash
mv /etc/pam.d/password-auth /etc/pam.d/password-auth.orig.$(date +%F_%T)
mv /etc/pam.d/password-auth.new /etc/pam.d/password-auth
chmod 644 /etc/pam.d/password-auth
ls -l /etc/pam.d/password-auth*
```
---
## 为什么这样改(要点)
- `pam_pwquality.so minlen=12 difok=3 minclass=3 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=0`
- 最短 12 个字符、至少 3 类字符、与旧密码至少 3 个字符不同。`ocredit=0` 表示**特殊字符非强制但建议**(若你要强制特殊字符,将 `ocredit=-1`)。
- `pam_unix.so ... remember=5`
- 实际写入 `/etc/shadow` 的模块,`remember=5` 阻止重复最近 5 个密码(提升安全性)。
- 保留 `pam_faillock`:继续防暴力破解(失败 3 次锁 60 秒)。
- `pam_deny.so` 保持在最后以确保策略失败时拒绝。
---
## 测试(非常重要)
在替换后不要立刻登出 root。先用一个普通用户或测试账号验证:
1. 创建测试用户(如果没有):
```bash
sudo useradd -m testpwuser || true
sudo passwd testpwuser # 按提示设置一个弱密码测试(应被拒绝)
```
2. 测试几种密码:
- 尝试 `abc123`(应失败)
- 尝试 `Abcdef12345`(若满足 minlen & classes 应通过)
- 尝试重复旧密码(应被 `remember=5` 拒绝)
3. 查看认证日志:
```bash
sudo tail -n 200 /var/log/auth.log # 或 /var/log/secure,视系统而定
# 或实时监测:
sudo tail -f /var/log/auth.log
```
4. 如果你使用 SSH,需要测试 `passwd` 改密是否与 SSH 有影响(通常没有),但如果你的环境有集中认证(SSSD/LDAP),请特别测试这些路径。
---
## 回滚(若出现问题)
如果验证失败或导致登录异常,立刻恢复备份:
```bash
# 恢复最初备份
sudo cp /etc/pam.d/password-auth.bak.* /etc/pam.d/password-auth
# 或恢复刚做的原始文件
sudo mv /etc/pam.d/password-auth.orig.* /etc/pam.d/password-auth
```
然后重启相关服务或直接重启机器(如果需要)。
---
## 额外建议(可选)
- 若你希望强制所有四类字符(UPPER+lower+digit+special),把 `ocredit=0` 改成 `ocredit=-1`(并把 `minclass=3` 可留或删)。
- 如果你更希望**即使强度检查失败也执行后续模块**(例如记录历史、通知或其它逻辑),可把 `password requisite pam_pwquality.so ...` 改为 `password required ...`
- 如果系统使用 SSSD/LDAP,请确认是否需要在 `password` 区块保留 `pam_sss.so use_authtok`(我在建议中注释了它,避免在没有 SSSD 测试的系统上造成问题)。若你确实使用 SSSD,请取消注释并测试。
---
如果你愿意,我可以:
- 直接检查你当前 `/etc/pam.d/system-auth``/etc/pam.d/common-password`(如果存在)并给出一致化建议;
- 或根据你的偏好(更严格:强制特殊字符 / 更宽松:允许 passphrase)把上面的配置调成两个不同的“严格度模板”供你选择并直接生成替换命令。
现在我已经把一个安全性较好的建议给出——要我继续把 `system-auth` / `common-password` 一并对齐吗?
项目:4
```bash
cp /etc/pam.d/password-auth /etc/pam.d/password-auth.bak.$(date +%F_%T)
ls -l /etc/pam.d/password-auth*
```
```bash
cat <<'EOF' | tee /etc/pam.d/password-auth.new >/dev/null
# /etc/pam.d/password-auth - modified recommended settings
auth required pam_kysec.so
#%PAM-1.0
auth required pam_env.so
auth required pam_faillock.so preauth audit deny=3 even_deny_root unlock_time=60
#auth sufficient pam_fprintd.so
auth sufficient pam_unix.so nullok try_first_pass
#auth sufficient pam_sss.so use_first_pass
auth [default=die] pam_faillock.so authfail audit deny=3 even_deny_root unlock_time=60
auth sufficient pam_faillock.so authsucc audit deny=3 even_deny_root unlock_time=60
auth requisite pam_succeed_if.so uid >= 1000 quiet_success
auth required pam_deny.so
account required pam_unix.so
account sufficient pam_localuser.so
account sufficient pam_succeed_if.so uid < 1000 quiet
#account [default=bad success=ok user_unknown=ignore] pam_sss.so
account required pam_permit.so
# Password quality: enforce length, classes, difok
# - minlen=12 : minimal length (increase if you want stronger)
# - difok=3 : new password must differ in at least 3 characters from old
# - minclass=3: at least 3 character classes (uppercase, lowercase, digit, other)
# - u/l/d/ocredit -1 : require at least one of each (set ocredit=0 to make special char optional)
password requisite pam_pwquality.so retry=3 minlen=12 difok=3 minclass=3 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=0 local_users_only
# UNIX module performs the actual password change and supports history
# remember=5 : prevent reuse of last 5 passwords
password sufficient pam_unix.so sha512 shadow nullok try_first_pass use_authtok remember=5
# If you have SSSD and want it to accept the token, uncomment below (but test first)
#password sufficient pam_sss.so use_authtok
password required pam_deny.so
session optional pam_keyinit.so revoke
session required pam_limits.so
#session optional pam_systemd.so
session [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid
session required pam_unix.so
#session optional pam_sss.so
EOF
```
```
mv /etc/pam.d/password-auth.new /etc/pam.d/password-auth
```
```
ip addr | grep en
cat /etc/pam.d/password-auth | grep pwq
```
达梦:
```
cd /home/dmdba/dmdbms/bin
./disql SYSDBA/'"Hn@dameng123"':35236
```
```
SELECT ROLE$ FROM V$DATABASE;
```
```
SELECT PARA_NAME, PARA_VALUE
FROM V$DM_INI
WHERE PARA_NAME='ENABLE_AUDIT';
```
```
SP_SET_PARA_VALUE(1, 'ENABLE_AUDIT', 2);
```
```
cd /home/dmdba/dmdbms/bin
./disql SYSAUDITOR/SYSAUDITOR@localhost:35239
```
```
SP_SET_ENABLE_AUDIT(2);
SELECT PARA_NAME, PARA_VALUE, PARA_TYPE
FROM V$DM_INI WHERE PARA_NAME='ENABLE_AUDIT';
```
@@ -0,0 +1,340 @@
a)应对登录的用户进行身份标识和鉴别,身份标识具有唯一性,身份鉴别信息具有复杂度要求并定期更换;
"建议该操作系统合理设置密码复杂度策略(设置/etc/pam.d/system-auth password requisite pam_cracklib.so difok=3
minlen=8 minclass=3 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1"
文件存储服务器(10.209.42.14
数据库服务器210.201.23.103
应用支撑服务器110.209.42.20
服务器410.209.42.22
数据库服务器110.201.23.102
业务服务器310.209.42.13
业务服务器210.209.42.12
业务服务器110.209.42.11
服务器110.209.42.16
服务器210.209.42.18
服务器310.209.42.19
缓存服务器(10.209.42.15
应用支撑服务器210.209.42.21
代理服务器110.209.42.17
建议该应用系统设置密码定期更换策略(密码定期更换时间:90天)
121.8.227.238
建议该数据库设置登录失败处理功能,限制用户非法登录(用户登录失败5次锁定5分钟);配置登录连接超时自动退出功能(超时自动退出时间30分钟)。
mongodb10.209.42.20
建议该数据库设置登录失败处理功能,限制用户非法登录(部分用户需要设置登录失败次数和锁定时间FAILED_ATTEMPS=5LOCK_TIME=5,用户登录失败5次锁定5分钟);配置登录连接超时自动退出功能(所有的用户需要设置超时功能CONN_IDLE_TIME=1800,超时退出时间不大于30分钟)。
该数据库未设置登录失败处理功能,未限制用户非法登录(部分用户的登录失败次数和锁定时间未设置(SYSDBA、SYS、SYSSSO和SYSAUDITOR、FGW_V3、FGW_SECURITY、FGW_IEJMS));未配置登录连接超时自动退出功能。
达梦数据库110.201.23.102
达梦数据库210.201.23.103
该数据库未设置登录失败处理功能,未限制用户非法登录;未配置登录连接超时自动退出功能(timeout 0)。
建议该数据库设置登录失败处理功能,限制用户非法登录(用户登录失败5次锁定5分钟);配置登录连接超时自动退出功能(timeout 30)。
该中间件设置登录失败处理功能,未限制用户非法登录(用户登录失败5次锁定5分钟);配置登录连接超时自动退出功能(登录连接超时时间:30分钟)。
nacos10.209.42.21
该操作系统涉及到的重要审计数据、重要配置数据未定期进行本地备份,备份策略设置未合理、备份配置设置未正确,备份结果与备份策略未一致,在发生数据丢失时未能够进行数据恢复
测评对象
文件存储服务器(10.209.42.14
数据库服务器210.201.23.103
应用支撑服务器110.209.42.20
服务器410.209.42.22
数据库服务器110.201.23.102
业务服务器310.209.42.13
业务服务器210.209.42.12
业务服务器110.209.42.11
服务器110.209.42.16
服务器210.209.42.18
服务器310.209.42.19
缓存服务器(10.209.42.15
应用支撑服务器210.209.42.21
代理服务器110.209.42.17
该操作系统涉及的鉴别数据在登录时未自动保存和显示历史账号和口令,未能保证鉴别信息所在的存储空间被释放或重新分配前得到完全清除
该操作系统涉及的鉴别数据在登录时未自动保存和显示历史账号和口令,未能保证鉴别信息所在的存储空间被释放或重新分配前得到完全清除
建议该操作系统涉及的鉴别数据采取相关技术措施保证鉴别信息所在的存储空间被释放或重新分配前得到完全清除
测评对象
文件存储服务器(10.209.42.14
数据库服务器210.201.23.103
应用支撑服务器110.209.42.20
服务器410.209.42.22
数据库服务器110.201.23.102
业务服务器310.209.42.13
业务服务器210.209.42.12
业务服务器110.209.42.11
服务器110.209.42.16
服务器210.209.42.18
服务器310.209.42.19
缓存服务器(10.209.42.15
应用支撑服务器210.209.42.21
代理服务器110.209.42.17
该操作系统未安装防恶意代码软件,未能对新型的入侵和病毒行为及时进行识别并有效阻断,防恶意代码库未更新至最新版本。
建议该操作系统安装防恶意代码软件(云平台提供的青藤云),能对新型的入侵和病毒行为及时进行识别并有效阻断,防恶意代码库更新至最新版本。
测评对象
文件存储服务器(10.209.42.14
应用支撑服务器110.209.42.20
服务器410.209.42.22
服务器110.209.42.16
服务器210.209.42.18
服务器310.209.42.19
缓存服务器(10.209.42.15
应用支撑服务器210.209.42.21
该操作系统未合理设置密码复杂度策略
"建议该操作系统合理设置密码复杂度策略(设置/etc/pam.d/system-auth password requisite pam_cracklib.so difok=3
minlen=8 minclass=3 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1"
文件存储服务器(10.209.42.14
数据库服务器210.201.23.103
应用支撑服务器110.209.42.20
服务器410.209.42.22
数据库服务器110.201.23.102
业务服务器310.209.42.13
业务服务器210.209.42.12
业务服务器110.209.42.11
服务器110.209.42.16
服务器210.209.42.18
服务器310.209.42.19
缓存服务器(10.209.42.15
应用支撑服务器210.209.42.21
代理服务器110.209.42.17
该管理终端涉及的鉴别数据在登录时未自动保存和显示历史账号和口令,未能保证鉴别信息所在的存储空间被释放或重新分配前得到完全清除
建议该管理终端涉及的鉴别数据采取相关技术措施保证鉴别信息所在的存储空间被释放或重新分配前得到完全清除
业务管理终端(172.16.28.233
运维管理终端(172.16.28.239
该数据库鉴别数据未保证存储空间被释放或重新分配前得到完全清除
建议该数据库鉴别数据采取相关技术措施保证鉴别信息所在的存储空间被释放或重新分配前得到完全清除
mongodb10.209.42.20
redis10.209.42.15
达梦数据库110.201.23.102
达梦数据库210.201.23.103
该数据库涉及到的重要审计数据、重要配置数据、重要业务数据、重要个人信息未定期进行本地备份,备份策略未设置合理、备份配置未设置正确,备份策略与备份结果未一致,在发生数据丢失时未能够进行数据恢复,近期恢复测试记录未能够进行正常的数据恢复
建议该数据库涉及到的重要审计数据、重要配置数据、重要业务数据、重要个人信息未定期进行本地备份,备份策略未设置合理、备份配置未设置正确,备份策略与备份结果未一致,在发生数据丢失时未能够进行数据恢复,近期恢复测试记录未能够进行正常的数据恢复
mongodb10.209.42.20
redis10.209.42.15
达梦数据库110.201.23.102
达梦数据库210.201.23.103
该数据库审计记录未定期进行备份(dmsql_GRP1_DW_02_SYSDBA),审计记录保存时间未满足6个月
建议该数据库审计记录定期进行备份(dmsql_GRP1_DW_02_SYSDBA),审计记录保存时间满足6个月
达梦数据库210.201.23.103
该数据库审计记录未定期进行备份,审计记录保存时间未满足6个月
建议该数据库审计记录定期进行备份,审计记录保存时间满足6个月
mongodb10.209.42.20
该数据库未采用ssl安全传输协议进行远程管理,未能避免鉴别数据在网络传输过程中被窃听的风险。
建议该数据库采用ssl安全传输协议进行远程管理,避免鉴别数据在网络传输过程中被窃听的风险。
达梦数据库110.201.23.102
达梦数据库210.201.23.103
该数据库未采用安全传输协议,未采用加密安全方式进行远程管理,未能够避免鉴别数据在网络传输过程中被窃听的风险。
建议该数据库采用安全传输协议(如ssl),采用加密安全方式进行远程管理,能够避免鉴别数据在网络传输过程中被窃听的风险。
mongodb10.209.42.20
redis10.209.42.15
该数据库未开启密码复杂度功能,未设置密码定期更换策略。
建议该数据库启用密码复杂度功能(密码长度大于8位,由数字、字母和特殊字符3种组成),设置定期更换口令周期(定期更换周期不大于90天)。
mongodb10.209.42.20
redis10.209.42.15
达梦数据库110.201.23.102
达梦数据库210.201.23.103
该数据库未开启审计功能,审计范围未覆盖每个用户,未对重要的用户行为和重要安全事件进行审计。 该数据库未开启审计功能
mongodb10.209.42.20
该数据库未启用安全审计功能(ENABLE_AUDIT=0
建议该数据库启用安全审计功能(ENABLE_AUDIT=2
达梦数据库110.201.23.102
达梦数据库210.201.23.103
该数据库未设置登录失败处理功能,未限制用户非法登录(部分用户的登录失败次数和锁定时间未设置(SYSDBA、SYS、SYSSSO和SYSAUDITOR、FGW_V3、FGW_SECURITY、FGW_IEJMS));未配置登录连接超时自动退出功能。
建议该数据库设置登录失败处理功能,限制用户非法登录(部分用户需要设置登录失败次数和锁定时间FAILED_ATTEMPS=5LOCK_TIME=5,用户登录失败5次锁定5分钟);配置登录连接超时自动退出功能(所有的用户需要设置超时功能CONN_IDLE_TIME=1800,超时退出时间不大于30分钟)。
达梦数据库110.201.23.102
达梦数据库210.201.23.103
该数据库未设置登录失败处理功能,未限制用户非法登录;未配置登录连接超时自动退出功能(timeout 0)。
建议该数据库设置登录失败处理功能,限制用户非法登录(用户登录失败5次锁定5分钟);配置登录连接超时自动退出功能(timeout 30)。
redis10.209.42.15
该数据库未设置登录失败处理功能,未限制用户非法登录;未配置登录连接超时自动退出功能。
建议该数据库设置登录失败处理功能,限制用户非法登录(用户登录失败5次锁定5分钟);配置登录连接超时自动退出功能(超时自动退出时间30分钟)。
mongodb10.209.42.20
该应用系统涉及到的重要审计数据、重要配置数据、重要业务数据、重要个人信息未定期进行本地备份
建议该应用系统涉及到的重要审计数据、重要配置数据、重要业务数据、重要个人信息定期进行本地备份
智慧评审系统(https://121.8.227.238/portal/
智慧评审系统-粤政易(https://121.8.227.238/fgw-mobile/
"固定资产投资调度管理系统(https://121.8.227.238/
http://121.8.227.238/"
"固定资产投资调度管理系统-粤政易(https://121.8.227.238/mobile/
http://121.8.227.238/mobile/"
该应用系统涉及的鉴别数据未能保证鉴别信息所在的存储空间被释放或重新分配前得到完全清除
建议该应用系统涉及的鉴别数据采取相关技术措施保证鉴别信息所在的存储空间被释放或重新分配前得到完全清除
测评对象
智慧评审系统(https://121.8.227.238/portal/
智慧评审系统-粤政易(https://121.8.227.238/fgw-mobile/
"固定资产投资调度管理系统(https://121.8.227.238/
http://121.8.227.238/"
"固定资产投资调度管理系统-粤政易(https://121.8.227.238/mobile/
http://121.8.227.238/mobile/"
该应用系统审计记录未定期进行备份(未备份登录日志),审计记录保存时间未满足6个月
建议该应用系统审计记录定期进行备份(备份登录日志)
测评对象
智慧评审系统(https://121.8.227.238/portal/
该应用系统审计记录未定期进行备份(未备份登录日志,未备份操作日志),审计记录保存时间未满足6个月
建议该应用系统审计记录定期进行备份(备份登录日志,备份操作日志)
测评对象
智慧评审系统-粤政易(https://121.8.227.238/fgw-mobile/
"固定资产投资调度管理系统-粤政易(https://121.8.227.238/mobile/
http://121.8.227.238/mobile/"
该中间件未设置登录失败处理功能,未限制用户非法登录;未配置登录连接超时自动退出功能。 该中间件设置登录失败处理功能,未限制用户非法登录(用户登录失败5次锁定5分钟);配置登录连接超时自动退出功能(登录连接超时时间:30分钟)。该中间件未设置密码复杂度策略,未设置密码定期更换策略。
建议该中间件设置密码复杂度策略(密码长度大于8位,由数字、字母和特殊字符三种组成),设置密码定期更换策略(定期更换密码策略:90天)
nacos10.209.42.21
该中间件未开启审计功能(未具有catalina和localhost-access.log
建议该中间件开启审计功能(具有catalina和localhost-access.log
tomcat-mbp-portal10.209.42.11
tomcat-fgw-review10.209.42.13
tomcat-fgw-portal10.209.42.11
nginx-fgw-nginx-mobile10.209.42.12
该中间件所在操作系统未合理设置密码复杂度策略
"建议该中间件所在操作系统合理设置密码复杂度策略(设置/etc/pam.d/system-auth password requisite pam_cracklib.so difok=3
minlen=8 minclass=3 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1"
测评对象
tomcat-mbp-portal10.209.42.11
nginx-fgw-nginx-mobile10.209.42.12
tomcat-fgw-review10.209.42.13
tomcat-fgw-portal10.209.42.11
nginx10.209.42.17
该中间件所在操作系统涉及的鉴别数据未能保证鉴别信息所在的存储空间被释放或重新分配前得到完全清除
建议该中间件所在操作系统涉及的鉴别数据保证鉴别信息所在的存储空间被释放或重新分配前得到完全清除
tomcat-mbp-portal10.209.42.11
nginx10.209.42.17
该中间件涉及到的重要审计数据、重要配置数据未定期进行本地备份,备份策略未设置合理、备份配置未设置正确,备份结果与备份策略未一致,在发生数据丢失时未能够进行数据恢复。
建议该中间件涉及到的重要审计数据、重要配置数据定期进行本地备份,备份策略设置合理、备份配置设置正确,备份结果与备份策略一致,在发生数据丢失时能够进行数据恢复。
tomcat-mbp-portal10.209.42.11
nginx-fgw-nginx-mobile10.209.42.12
nacos10.209.42.21
tomcat-fgw-review10.209.42.13
tomcat-fgw-portal10.209.42.11
nginx10.209.42.17
该中间件采用http传输协议,未采用加密安全方式进行远程管理,未能够避免鉴别数据在网络传输过程中被窃听的风险。
建议该中间件采用https传输协议,采用加密安全方式进行远程管理,能够避免鉴别数据在网络传输过程中被窃听的风险。
nacos10.209.42.21
该应用系统未设置密码复杂度功能,未设置密码定期更换策略
建议该应用系统设置密码复杂度功能(密码长度8位以上,由字母、数字、特殊字符三种组成),设置密码定期更换策略(密码定期更换时间:90天)
测评对象
智慧评审系统(https://121.8.227.238/portal/
智慧评审系统-粤政易(https://121.8.227.238/fgw-mobile/
该应用系统未设置密码定期更换策略
建议该应用系统设置密码定期更换策略(密码定期更换时间:90天)
"固定资产投资调度管理系统(https://121.8.227.238/
http://121.8.227.238/"
"固定资产投资调度管理系统-粤政易(https://121.8.227.238/mobile/
http://121.8.227.238/mobile/"
该应用系统未设置登录失败处理功能,未限制用户非法登录;未配置登录连接超时自动退出功能
建议该应用系统设置登录失败处理功能,限制用户非法登录(用户登录失败5次锁定5分钟);配置登录连接超时自动退出功能(超时退出时间:30分钟)
测评对象
智慧评审系统-粤政易(https://121.8.227.238/fgw-mobile/
"固定资产投资调度管理系统(https://121.8.227.238/
http://121.8.227.238/"
"固定资产投资调度管理系统-粤政易(https://121.8.227.238/mobile/
http://121.8.227.238/mobile/"
该应用系统未开启审计功能(未能区分手机端登录日志,未有操作日志),审计范围未覆盖每个用户,未对重要的用户行为和重要安全事件进行审计。
建议该应用系统开启审计功能(区分手机端登录日志,具有操作日志)
测评对象
"固定资产投资调度管理系统-粤政易(https://121.8.227.238/mobile/
http://121.8.227.238/mobile/"
该应用系统未采用https传输协议
建议该应用系统采用https传输协议测评对象
"固定资产投资调度管理系统-粤政易(https://121.8.227.238/mobile/
http://121.8.227.238/mobile/"
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,627 @@
Apologies for the confusion caused by the deprecated commands in the MinIO Client (`mc`). The MinIO team periodically updates `mc` to enhance functionality and improve usability, which sometimes leads to changes in command syntax. To ensure compatibility and take advantage of the latest features, it's essential to use the updated commands.
Below is the **updated guide** for creating an **API user** with **read and write** permissions equivalent to the **root user** using the latest `mc` commands: `mc admin policy create` and `mc admin policy attach`.
---
## **Table of Contents**
1. [Prerequisites](#prerequisites)
2. [Understanding MinIO Users and Policies](#understanding-minio-users-and-policies)
3. [Installing and Configuring MinIO Client (`mc`)](#installing-and-configuring-minio-client-mc)
4. [Creating a Full Access Policy](#creating-a-full-access-policy)
5. [Creating the API User and Assigning the Policy](#creating-the-api-user-and-assigning-the-policy)
6. [Verifying the API User](#verifying-the-api-user)
7. [Best Practices](#best-practices)
8. [Example: Creating an API User with Full Access](#example-creating-an-api-user-with-full-access)
9. [Additional Resources](#additional-resources)
---
## **1. Prerequisites**
Ensure you have the following before proceeding:
- **MinIO Server**: Installed and running in production.
- **Root Access**: Administrative privileges to manage MinIO users and policies.
- **MinIO Client (`mc`)**: Installed on your local machine or a management server.
- **Network Access**: Ability to connect to the MinIO server from where `mc` is installed.
---
## **2. Understanding MinIO Users and Policies**
### **a. Users**
In MinIO, users are entities (applications, services, or individuals) that interact with the MinIO server. Each user has a unique **Access Key** and **Secret Key** used for authentication.
### **b. Policies**
Policies define the permissions associated with users. They determine what actions a user can perform and on which resources (buckets or objects). Policies can be **predefined** or **custom**.
- **Read-Only**: Allows users to read objects but not modify or delete them.
- **Write-Only**: Allows users to upload objects but not read or delete them.
- **Full Access**: Grants all permissions, including read, write, and delete.
---
## **3. Installing and Configuring MinIO Client (`mc`)**
The MinIO Client (`mc`) is a command-line tool that simplifies managing MinIO servers and performing administrative tasks.
### **a. Download and Install `mc`**
1. **Download the Latest Release:**
```bash
wget https://dl.min.io/client/mc/release/linux-amd64/mc
```
2. **Make the Binary Executable:**
```bash
chmod +x mc
```
3. **Move `mc` to a Directory in Your PATH:**
```bash
sudo mv mc /usr/local/bin/
```
4. **Verify Installation:**
```bash
mc --version
```
**Expected Output:**
```
mc version RELEASE.2023-07-24T16-40-29Z
```
### **b. Configure `mc` to Connect to Your MinIO Server**
1. **Set Up an Alias for Your MinIO Server:**
Replace `<ALIAS>`, `<MINIO_ENDPOINT>`, `<YOUR-ACCESS-KEY>`, and `<YOUR-SECRET-KEY>` with your actual details.
```bash
mc alias set <ALIAS> <MINIO_ENDPOINT> <YOUR-ACCESS-KEY> <YOUR-SECRET-KEY> --api S3v4
```
**Example:**
```bash
mc alias set myminio https://minio.example.com Ab3dE6fG9hJkLmN0 Pq8Rs5Tu7Vw9Xy1Z2a3Bc4De5Fg6Hi7J --api S3v4
```
2. **Verify Connection:**
```bash
mc ls myminio
```
**Expected Output:**
```
[2024-04-25 10:00:00 UTC] Bucket1
[2024-04-25 10:00:00 UTC] Bucket2
```
If you encounter errors, ensure that:
- The MinIO server is accessible from your machine.
- The access and secret keys are correct.
- Network firewalls or security groups allow traffic on MinIO ports (default: 9000 for S3 API).
---
## **4. Creating a Full Access Policy**
To replicate the root user's permissions, you'll need to create a policy that grants **full access** to all resources.
### **a. Define the Policy JSON**
1. **Create a File Named `full-access.json`:**
```bash
nano full-access.json
```
2. **Add the Following Content:**
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::*"
]
}
]
}
```
**Policy Breakdown:**
- **`s3:*`**: Grants all S3 actions (create, read, update, delete).
- **`arn:aws:s3:::*`**: Applies to all buckets and objects.
**_Caution:_** This policy grants **full access**. Ensure that it's only assigned to trusted users.
3. **Save and Exit:**
- Press `CTRL + O`, then `ENTER` to save.
- Press `CTRL + X` to exit.
### **b. Validate the Policy JSON**
Ensure that the JSON syntax is correct. You can use tools like [JSONLint](https://jsonlint.com/) or run:
```bash
jq empty full-access.json
```
If the command executes without errors, the JSON is valid.
### **c. Create the Policy in MinIO**
Use the updated `mc admin policy create` command instead of the deprecated `add` command.
```bash
mc admin policy create <ALIAS> <POLICY_NAME> <POLICY_FILE>
```
**Example:**
```bash
mc admin policy create myminio full-access full-access.json
```
**Expected Output:**
```
Policy full-access created successfully
```
---
## **5. Creating the API User and Assigning the Policy**
Now that the **full access** policy is defined, you can create a new API user and assign this policy to them.
### **a. Create the API User**
Use the `mc` client to create a new user. You will need to generate an **Access Key** and **Secret Key** for the user.
#### **Method 1: Manual Key Generation**
1. **Generate an Access Key:**
```bash
ACCESS_KEY=$(openssl rand -hex 8)
echo "Access Key: $ACCESS_KEY"
```
2. **Generate a Secret Key:**
```bash
SECRET_KEY=$(openssl rand -hex 16)
echo "Secret Key: $SECRET_KEY"
```
**_Sample Output:_**
```
Access Key: a1b2c3d4e5f6g7h8
Secret Key: i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4
```
#### **Method 2: Using MinIO Client (`mc`) to Create User with Keys**
Alternatively, you can let `mc` generate the keys for you.
```bash
mc admin user add <ALIAS> <USERNAME> <SECRET_KEY>
```
**Example:**
```bash
mc admin user add myminio apiuser1 i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4
```
**_Note:_** Replace `<USERNAME>` and `<SECRET_KEY>` with your desired username and a strong secret key.
**_Recommendation:_** Use **Method 1** to generate strong, random keys.
### **b. Attach the Policy to the User**
Assign the previously created **full-access** policy to the new user.
```bash
mc admin policy attach <ALIAS> <POLICY_NAME> user=<USERNAME>
```
**Example:**
```bash
mc admin policy attach myminio full-access user=apiuser1
```
**Expected Output:**
```
Policy full-access attached to user apiuser1 successfully
```
---
## **6. Verifying the API User**
Ensure that the new user has been created and has the correct permissions.
### **a. List Users**
```bash
mc admin user list <ALIAS>
```
**Example:**
```bash
mc admin user list myminio
```
**Expected Output:**
```
ACCESSKEY USERNAME
Ab3dE6fG9hJkLmN0 minioadmin
a1b2c3d4e5f6g7h8 apiuser1
```
### **b. Test Access with API User Credentials**
To confirm that the user has the correct permissions:
1. **Configure `mc` with the New User:**
```bash
mc alias set apiuser myminio https://minio.example.com <ACCESS_KEY> <SECRET_KEY> --api S3v4
```
**Example:**
```bash
mc alias set apiuser myminio https://minio.example.com a1b2c3d4e5f6g7h8 i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4 --api S3v4
```
2. **List All Buckets:**
```bash
mc ls apiuser
```
**Expected Output:**
```
[2024-04-25 10:00:00 UTC] Bucket1
[2024-04-25 10:00:00 UTC] Bucket2
```
3. **Create a New Bucket:**
```bash
mc mb apiuser/new-bucket
```
**Expected Output:**
```
Bucket created successfully `new-bucket`.
```
4. **Upload an Object:**
```bash
mc cp example.txt apiuser/new-bucket/
```
**Expected Output:**
```
Upload Success: example.txt to new-bucket/example.txt
```
5. **Download an Object:**
```bash
mc cp apiuser/new-bucket/example.txt ./example.txt
```
**Expected Output:**
```
Download Success: new-bucket/example.txt to example.txt
```
6. **Delete an Object:**
```bash
mc rm apiuser/new-bucket/example.txt
```
**Expected Output:**
```
Removed `new-bucket/example.txt`
```
7. **Remove the Bucket:**
```bash
mc rb apiuser/new-bucket
```
**Expected Output:**
```
Removed `new-bucket`.
```
**_Note:_** Since the API user has **full access**, all these operations should succeed, mirroring the root user's capabilities.
---
## **7. Best Practices**
To maintain a secure and efficient MinIO environment, adhere to the following best practices when managing API users:
### **a. Principle of Least Privilege**
- **Assign Minimal Permissions**: Only grant users the permissions they strictly need.
- **Avoid Over-Permissioning**: Do not assign full access unless absolutely necessary.
**_Note:_** While you're setting up an API user with full access, ensure that this is truly required and that the credentials are handled securely.
### **b. Regularly Rotate Credentials**
- **Change Access and Secret Keys Periodically**: Minimizes the risk of compromised credentials.
- **Update Dependent Applications**: Ensure that applications using these keys are updated accordingly.
### **c. Use Strong, Unique Credentials**
- **High Entropy**: Use long and randomly generated keys.
- **Avoid Reuse**: Ensure that each user has unique credentials.
### **d. Monitor and Audit User Activities**
- **Enable Logging**: Keep track of user actions for auditing purposes.
- **Set Up Alerts**: Notify administrators of unusual activities or access patterns.
### **e. Secure Storage of Credentials**
- **Use Secret Management Tools**: Tools like [HashiCorp Vault](https://www.vaultproject.io/), [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/), or [Kubernetes Secrets](https://kubernetes.io/docs/concepts/configuration/secret/) can securely store and manage credentials.
- **Avoid Hardcoding Credentials**: Do not embed access keys in application code or configuration files.
### **f. Limit User Lifespans**
- **Temporary Access**: For users that need temporary access, set expiration policies or regularly review and deactivate unused users.
---
## **8. Example: Creating an API User with Full Access**
Let's walk through a practical example where we create an API user named `apiuser1` with **full access** to all buckets and objects, mirroring the root user's permissions.
### **Step 1: Define the Full Access Policy**
1. **Create `full-access.json`:**
```bash
nano full-access.json
```
2. **Add the Following Content:**
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:*"
],
"Resource": [
"arn:aws:s3:::*"
]
}
]
}
```
3. **Save and Exit:**
- Press `CTRL + O`, then `ENTER` to save.
- Press `CTRL + X` to exit.
4. **Validate the Policy JSON:**
```bash
jq empty full-access.json
```
**No output means the JSON is valid.**
### **Step 2: Add the Policy to MinIO**
```bash
mc admin policy create myminio full-access full-access.json
```
**Expected Output:**
```
Policy full-access created successfully
```
### **Step 3: Create the API User**
1. **Generate Access and Secret Keys:**
```bash
ACCESS_KEY=$(openssl rand -hex 8)
SECRET_KEY=$(openssl rand -hex 16)
echo "Access Key: $ACCESS_KEY"
echo "Secret Key: $SECRET_KEY"
```
**Sample Output:**
```
Access Key: a1b2c3d4e5f6g7h8
Secret Key: i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4
```
2. **Add the User with the Policy:**
```bash
mc admin user add myminio apiuser1 i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4
mc admin policy attach myminio full-access user=apiuser1
```
**Expected Output:**
```
User apiuser1 added successfully
Policy full-access attached to user apiuser1 successfully
```
### **Step 4: Test the API User**
1. **Configure `mc` with the New User:**
```bash
mc alias set apiuser1 myminio https://minio.example.com a1b2c3d4e5f6g7h8 i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4 --api S3v4
```
2. **List All Buckets:**
```bash
mc ls apiuser1
```
**Expected Output:**
```
[2024-04-25 10:00:00 UTC] Bucket1
[2024-04-25 10:00:00 UTC] Bucket2
```
3. **Create a New Bucket:**
```bash
mc mb apiuser1/new-bucket
```
**Expected Output:**
```
Bucket created successfully `new-bucket`.
```
4. **Upload an Object:**
```bash
mc cp example.txt apiuser1/new-bucket/
```
**Expected Output:**
```
Upload Success: example.txt to new-bucket/example.txt
```
5. **Download an Object:**
```bash
mc cp apiuser1/new-bucket/example.txt ./example.txt
```
**Expected Output:**
```
Download Success: new-bucket/example.txt to example.txt
```
6. **Delete an Object:**
```bash
mc rm apiuser1/new-bucket/example.txt
```
**Expected Output:**
```
Removed `new-bucket/example.txt`
```
7. **Remove the Bucket:**
```bash
mc rb apiuser1/new-bucket
```
**Expected Output:**
```
Removed `new-bucket`.
```
**_Note:_** Since the API user has **full access**, all these operations should succeed, mirroring the root user's capabilities.
---
## **9. Additional Resources**
- **MinIO Official Documentation:**
- [MinIO Client (`mc`) Quickstart Guide](https://docs.min.io/docs/minio-client-quickstart-guide.html)
- [MinIO Admin API](https://docs.min.io/docs/minio-admin-complete-guide.html)
- [MinIO Policy Documentation](https://docs.min.io/docs/minio-policy-guide.html)
- **Security Best Practices:**
- [MinIO Security Best Practices](https://docs.min.io/docs/minio-security.html)
- **Secret Management:**
- [HashiCorp Vault](https://www.vaultproject.io/)
- [AWS Secrets Manager](https://aws.amazon.com/secrets-manager/)
- [Kubernetes Secrets](https://kubernetes.io/docs/concepts/configuration/secret/)
- **MinIO Community and Support:**
- [MinIO GitHub Repository](https://github.com/minio/minio)
- [MinIO Community Slack](https://slack.min.io/)
---
## **Conclusion**
By following the updated steps outlined above, you can create an API user in MinIO with **read and write** permissions equivalent to the **root user** using the latest `mc admin policy create` and `mc admin policy attach` commands. This setup allows your applications or services to interact with MinIO seamlessly while maintaining secure and controlled access.
**_Important Considerations:_**
- **Security Risks**: Granting full access poses significant security risks. Ensure that the API user's credentials are stored securely and are only accessible to authorized applications.
- **Audit and Monitoring**: Regularly monitor the API user's activities to detect any unauthorized or unusual behaviors.
- **Credential Management**: Implement robust credential management practices, including regular rotation and secure storage.
Always tailor your MinIO user policies to align with your organization's security policies and operational requirements.
If you encounter any issues or need further assistance, consider reaching out to the [MinIO community](https://min.io/community.html) or consulting the official [MinIO documentation](https://docs.min.io/).