Apache 您如何使用HT400用户帐户?

Apache 您如何使用HT400用户帐户?,apache,htdigest,Apache,Htdigest,如何为400个用户生成用户帐户以进行负载测试 Htdigest每次都会强制您键入密码,我曾经尝试过类似的dos管道 echo password > htdigest -c realm username%1 htdigest -c realm username%1 < password.txt echo password>htdigest-c领域用户名%1 htdigest-c领域用户名%1>outfile $ ./load_users.bash $ cat passwd.

如何为400个用户生成用户帐户以进行负载测试

Htdigest每次都会强制您键入密码,我曾经尝试过类似的dos管道

echo password > htdigest -c realm username%1 

htdigest -c realm username%1 < password.txt 
echo password>htdigest-c领域用户名%1
htdigest-c领域用户名%1
但它不起作用

(旁白:在unix/linux上,第一个应该是:

echo password | htdigest -c realm username$1
)

由于htdigest没有任何好的方法来传递密码,因此我将使用它来自动化这个过程

:


如果需要,用户可以在Windows上转换此密码。

您也可以查看trac在其网站上分发的python脚本以获取HttDigest密码,然后您可以将其自动化:

他们还建议采取以下措施:

可以使用md5sum实用程序使用以下方法生成摘要密码文件:

并手动删除结尾处的“-”,并将“${user}:trac:”添加到“to file”行的开头


我已经在FreeBSD上对此进行了测试,不确定这是否适用于Linux或Windows,因此您可能需要对其进行一些修改:

(echo -n "user:realm:" && echo -n "user:realm:testing" | md5) > outfile
输出文件包含:

user:realm:84af20dd88a2456d3bf6431fe8a59d16
htdigest也是这样:

htdigest -c outfile2 realm user
输出管2的输出

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
运行脚本:

$ ./load_users.bash 
生成的htdigest文件:

$ cat passwd.htdigest
joe:MyRealm:2603a6c581f336f2874dbdd253aee780
curly:MyRealm:fd3f9d87bba654439d5ba1f32c0286a8
larry:MyRealm:c1c3c0dc50a9b97e9f7ee582e3fce892
和纯文本文件:

$ cat passwd.txt 
joe:aLnqnrv0
curly:3xWxHKmv
larry:7v7m6mXY
在GNU/Linux上,可以使用(改编自上面的FreeBSD命令):
(echo-n“user:realm:&&echo-n”user:realm:passwd“| md5sum-| cut-d”“-f1)>>outfile
$ ./load_users.bash 
$ cat passwd.htdigest
joe:MyRealm:2603a6c581f336f2874dbdd253aee780
curly:MyRealm:fd3f9d87bba654439d5ba1f32c0286a8
larry:MyRealm:c1c3c0dc50a9b97e9f7ee582e3fce892
$ cat passwd.txt 
joe:aLnqnrv0
curly:3xWxHKmv
larry:7v7m6mXY