1.脚本里创建两个用户名和密码
2.让用户从屏幕输出账户和密码进行登录
3.如果账户输入错误,让他继续输入
4.账户输入正确,输入密码
5.密码正确,登录成功
6.同一个账号,密码最多错三次,三次都错将锁定账户。(此时脚本不能退出)
7.锁定账号以后,让他继续可以登录未锁账号
#!/bin/bash
useradd jinchuan1
if [ $? -eq 0 ];then
echo "123" | passwd --stdin jinchuan1
fi
useradd jinchuan2
if [ $? -eq 0 ];then
echo "456" | passwd --stdin jinchuan2
fi
a="jinchuan1"
b="jinchuan2"
c="123"
d="456"
while :
do
while :
do read -p "请输入用户名:" A
if [ $A == $a ];then
break
fi
if [ $A == $b ];then
break
fi
done
if [ $A == jinchuan1 ];then
for i in 1 2 3
do read -p "请输入密码" C
if [ $C == $c ];then
echo "登录成功"
break
fi
[ $i == 3 ] && passwd -l $A && echo "用户已经锁定"
done
fi
if [ $A == jinchuan2 ];then
for i in 1 2 3
do read -p "请输入密码" C
if [ $C == $d ];then
echo "登录成功"
break
fi
[ $i == 3 ] && passwd -l $A && echo "用户已经锁定"
done
fi
done