理論上服務(wù)器應(yīng)該沒(méi)有這么多的賬號(hào),由于歷史遺留問(wèn)題才導(dǎo)致這種情況出現(xiàn)
其實(shí)正確操作是鎖定沒(méi)有用的用戶(hù)密碼并禁止該用戶(hù)登錄
如:
#鎖定用戶(hù)密碼
usermod -L user
#將該用戶(hù)改成nologin
grep user /etc/passwd
#將最后一列的/bin/bash 改成/sbin/nologin
root用戶(hù)批量暴力修改其他用戶(hù)密碼
#!/bin/bash
users=(mq support nginx ar ...)
for user in "${users[@]}"; do
grep -w $user /etc/passwd >/dev/null
if [ $? -eq 0 ]; then
echo "Newpassword" |passwd --stdin $user >/dev/null
echo "用戶(hù):$user password was changed"
fi
done