在 CentOS 上使用 Cobbler 批量装机 时,“加盐”通常指的是 为系统用户的密码(如 root)添加 salt(密码加盐哈希),而不是给 Cobbler 本身加盐。下面分几种常见情况说明。
Cobbler 的 kickstart 模板里,root 密码一般写成:
rootpw --iscrypted $6$xxxxxxxx
这里的 $6$ 就是 SHA-512 + salt 的加密方式。
openssl passwd -6 -salt $(openssl rand -hex 8) yourpassword
示例输出:
$6$3f9c1a2b$abcdef1234567890...
-6:SHA-512-salt:手动指定 salt(这就是“加盐”)然后写入 kickstart:
rootpw --iscrypted $6$3f9c1a2b$abcdef1234567890...
python3 -c "import crypt,os; print(crypt.crypt('yourpassword', crypt.mksalt(crypt.METHOD_SHA512)))"
Cobbler 支持:
cobbler system edit --name=node1 --root-pass=yourpassword
⚠️ 实际上 Cobbler 会自动加密,但 salt 不可控,安全性不如手动生成。
Cobbler 的 kickstart 模板(如 sample_end.ks)中:
rootpw --iscrypted $default_password_crypted
你可以改成:
rootpw --iscrypted $6$saltvalue$hashedpassword
或者在 profile 中设置:
cobbler profile edit --name=CentOS7 \
--kopts="rootpw=--iscrypted \$6\$salt\$hash"
(不推荐,复杂)
在 %post 阶段:
%post
useradd appuser
echo "appuser:$(openssl passwd -6 -salt $(openssl rand -hex 8) apppass)" | chpasswd -e
%end
-e 表示密码已是加密格式。
❌ Cobbler 本身没有“加盐”配置
❌ kickstart 不能直接写明文密码
✅ 所有密码必须是 crypt/SHA-512 + salt
如果你是指:
可以告诉我具体场景,我可以给你更针对性的方案。