Redis 安全
密码、绑定、重命名危险命令、网络安全。
Key Points暴露在公网的裸 Redis 等于把数据拱手送人;认证 + 限制访问是底线。
必做项
- 设
requirepass强密码,连接先 AUTH bind 127.0.0.1或内网地址,别监听 0.0.0.0 公网- 云上用安全组 / 防火墙只放通可信 IP
- 用
rename-command禁用 FLUSHALL / KEYS 等危险命令
禁用危险命令
Shell
# redis.conf:重命名为空字符串即禁用
rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command KEYS "do-not-use-keys"An internet-exposed Redis is ransomware bait: scanners hit 6379, FLUSHALL, then demand ransom. Set a password and restrict source IP before anything else — more important than any tuning.
必做项
- 设
requirepass强密码,连接先 AUTH bind 127.0.0.1或内网地址,别监听 0.0.0.0 公网- 云上用安全组 / 防火墙只放通可信 IP
- 用
rename-command禁用 FLUSHALL / KEYS 等危险命令
禁用危险命令
Shell
# redis.conf:重命名为空字符串即禁用
rename-command FLUSHALL ""
rename-command FLUSHDB ""
rename-command KEYS "do-not-use-keys"公网裸 Redis 是勒索软件最爱——它们扫到 6379 就
FLUSHALL 清空再索要赎金。上线前务必设密码 + 限制来源 IP,这比任何调优都重要。