ルートのデフォルトパスワードを使用するシステムイメージがあります。これしなければならないすべてのユーザーがこれを行うわけではないようですが、変更されます。
pamtesterを使用してログインをテストできることを知っています。
# pamtester system-auth root authenticate
Password:
コマンドラインにパスワードが必要です。私はこれを自動化したい。これは可能ですか?
ベストアンサー1
vi ./authenticate_test.sh
#!/bin/bash
echo "Checking your password. If it doesn't work, script will wait for a few seconds, don't worry..."
pamtester login $1 authenticate << eof
`echo $2`
eof
if [[ $? -eq 0 ]]
then
echo "script> Successful"
else
echo "script> Fail"
fi
次に、次を使用します。
$ ./authenticate_test.sh customuser rightpassword
Checking your password. If it doesn't work, script will wait for a few seconds, don't worry...
Password: pamtester: successfully authenticated
script> Successful
$ ./authenticate_test.sh customuser wrongpassword
Checking your password. If it doesn't work, script will wait for a few seconds, don't worry...
Password: pamtester: Authentication failure
script> Fail