如何编写允许用户在5分钟内输入X次密码尝试的shell脚本?

时间:2015-05-07 03:18:28

标签: shell terminal password-protection

如何编写一个shell脚本,允许用户在5分钟内输入X次密码尝试,否则会将用户注销?

到目前为止,我有这个:

    trap 'echo do not mess with this computer' 1 2 3 9 15 18
stty -echo

echo "key:"
read key1
echo "again"
read key2
key3=
if [ "$key1" = "$key2" ]
then
 tput clear

until [ "$key3" = "$key1" ]
do
echo "enter the key"
read key3
done

else echo "try again"
fi

stty echo

1 个答案:

答案 0 :(得分:0)

看一下这个问题,你可以为失败的SSH登录添加延迟,但你不能通过脚本来做到这一点。

https://unix.stackexchange.com/questions/105553/how-to-provide-login-delay-in-ssh