負荷テストを行うために400人のユーザーのユーザーアカウントを生成するにはどうすればよいですか?400人のユーザーアカウントをどのようにhtdigestしますか?
HTDigestによる力あなたは毎回パスワードを入力するために、私は
echo password > htdigest -c realm username%1
htdigest -c realm username%1 < password.txt
のようなドスパイプを試してみましたが、それはさておき...
負荷テストを行うために400人のユーザーのユーザーアカウントを生成するにはどうすればよいですか?400人のユーザーアカウントをどのようにhtdigestしますか?
HTDigestによる力あなたは毎回パスワードを入力するために、私は
echo password > htdigest -c realm username%1
htdigest -c realm username%1 < password.txt
のようなドスパイプを試してみましたが、それはさておき...
を(動作していない:UNIX/Linuxの最初のもので次のようになります。
echo password | htdigest -c realm username$1
)
のに、htdigestはPASを渡すための任意の良い方法を持っていないので私はexpect
を使用してプロセスを自動化します。
An example from http://www.seanodonnell.com/code/?id=21:
#!/usr/bin/expect
#########################################
#$ file: htpasswd.sh
#$ desc: Automated htpasswd shell script
#########################################
#$
#$ usage example:
#$
#$ ./htpasswd.sh passwdpath username userpass
#$
######################################
set htpasswdpath [lindex $argv 0]
set username [lindex $argv 1]
set userpass [lindex $argv 2]
# spawn the htpasswd command process
spawn htpasswd $htpasswdpath $username
# Automate the 'New password' Procedure
expect "New password:"
send "$userpass\r"
expect "Re-type new password:"
send "$userpass\r"
必要な場合は、Windowsのためにこれを変換するために、ユーザーへの課題として残されています。あなたはまた、Tracはhtdigestをパスワードに自分のウェブサイト上で配布することをPythonスクリプトをチェックアウトすることができ
、あなたはそれを自動化することができます:
Generating htdigest passwords without Apache
彼らはまた、これらの線に沿って何かがうまくいく勧め:
:は、そのような方法を使用してダイジェスト・パスワード・ファイルを生成するためのmd5sumユーティリティを使用することが可能です
$ printf "${user}:trac:${password}" | md5sum - >>user.htdigest
最後に手動で「 - 」を削除し、「$ {user}:trac:」を「to-file」の行の先頭に追加します。
私はあなたがそれを少し変更する必要がありますので、これは、LinuxまたはWindows上で動作するかどうかわからない、FreeBSD上でこれをテストしています
(echo -n "user:realm:" && echo -n "user:realm:testing" | md5) > outfile
outfileには含まれています
user:realm:84af20dd88a2456d3bf6431fe8a59d16
htdigestと同じこと:
htdigest -c outfile2 realm user
彼らは、これにより、コマンドラインの実装の正しさを証明し、両方とも同じです指定の出力ファイル
user:realm:84af20dd88a2456d3bf6431fe8a59d16
で出力!
ユーザ名のリストを読み込み、それぞれにランダムなパスワードを生成し、htdigestファイルとプレーンテキストファイルの両方に出力するスクリプトです。 Linux上でテストされていますが、他のシステム用に変更する必要があるかもしれません。特に、md5sum
はmd5
であり、head
は常に-c
フラグを受け入れます。
#!/bin/bash
# auth realm for digest auth
AUTH_REALM=MyRealm
# file locations
# a file containing a list of user names,
# one name per line, e.g.,
# $ cat users.txt
# joe
# curly
# larry
USER_FILE=users.txt
# htdigest file, needs to exist
HTDIGEST_FILE=passwd.htdigest
# insecure password file
PASSWD_FILE=passwd.txt
# read the names from the user file
while read username
do
# generate a pseudo-random password
rand_pw=`< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c8`
# hash the username, realm, and password
htdigest_hash=`printf $username:$AUTH_REALM:$rand_pw | md5sum -`
# build an htdigest appropriate line, and tack it onto the file
echo "$username:$AUTH_REALM:${htdigest_hash:0:32}" >> $HTDIGEST_FILE
# put the username and password in plain text
# clearly, this is terribly insecure, but good for
# testing and importing
echo "$username:$rand_pw" >> $PASSWD_FILE
done < $USER_FILE
これは、最初のユーザー名がファイルのように入力し、結果が見えるものです:
スクリプトを実行$ cat users.txt
joe
curly
larry
:
$ ./load_users.bash
たのに、htdigestファイル:
$ cat passwd.htdigest
joe:MyRealm:2603a6c581f336f2874dbdd253aee780
curly:MyRealm:fd3f9d87bba654439d5ba1f32c0286a8
larry:MyRealm:c1c3c0dc50a9b97e9f7ee582e3fce892
を
プレーンテキストのfiル:GNU/Linuxのの1で
$ cat passwd.txt
joe:aLnqnrv0
curly:3xWxHKmv
larry:7v7m6mXY
(上記のFreeBSDのコマンドから適応)使用することができます '(エコー-n "ユーザー:レルム:" &&エコー-n "ユーザー:レルム:passwdの" | md5sum - | cut -d "-f1)>> outfile' – blerontin