2009-03-14 11 views
9

आप 400 उपयोगकर्ताओं के लिए लोड परीक्षण करने के लिए उपयोगकर्ता खाते कैसे उत्पन्न करते हैं?आप 400 उपयोगकर्ता खातों को कैसे सीमित करते हैं?

Htdigest बलों आप हर बार एक पासवर्ड लिखना, मैं की तरह

echo password > htdigest -c realm username%1 

htdigest -c realm username%1 < password.txt 

डॉस पाइप की कोशिश की है, लेकिन यह काम कर रहा है नहीं ...

उत्तर

6

(एक तरफ: यूनिक्स/लिनक्स पहले एक पर होना चाहिए:

echo password | htdigest -c realm username$1 

)

htdigest क़दम पारित करने के लिए किसी भी अच्छा तरीका नहीं है के रूप में तलवार में, मैं प्रक्रिया को स्वचालित करने के लिए 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" 

यह उपयोगकर्ता के लिए एक अभ्यास विंडोज के लिए इस कन्वर्ट करने के लिए यदि आवश्यक के रूप में बचा है।

16

तुम भी अजगर स्क्रिप्ट Trac htdigest पासवर्ड के लिए अपनी वेबसाइट पर वितरित करता है की जाँच कर सकते हैं, आप तो यह स्वचालित कर सकते हैं:

Generating htdigest passwords without Apache

उन्होंने यह भी सुझाव है कि इन पंक्तियों के साथ कुछ काम करेंगे:

:

यह md5sum उपयोगिता का उपयोग करने के लिए इस तरह के विधि का उपयोग कर पचा-पासवर्ड फ़ाइल उत्पन्न करने के लिए संभव है

$ printf "${user}:trac:${password}" | md5sum - >>user.htdigest 

और अंत में मैन्युअल रूप से "-" हटाएं और "$ {user}: trac:" को 'to-file' से लाइन की शुरुआत में जोड़ें।


मैं FreeBSD पर इस परीक्षण किया है, यकीन है कि अगर यह लिनक्स या विंडोज पर काम करेंगे, ताकि आप इसे एक छोटे से संशोधित करना पड़ सकता नहीं:

(echo -n "user:realm:" && echo -n "user:realm:testing" | md5) > outfile 

outfile शामिल हैं:

user:realm:84af20dd88a2456d3bf6431fe8a59d16 

htdigest के साथ भी यही बात:

htdigest -c outfile2 realm user 
outfile2

user:realm:84af20dd88a2456d3bf6431fe8a59d16 

में

उत्पादन वे एक ही, कमांड लाइन कार्यान्वयन की जिससे साबित शुद्धता दोनों कर रहे हैं!

+3

जीएनयू/लिनक्स एक पर (FreeBSD आदेश से अनुकूलित ऊपर) इस्तेमाल कर सकते हैं: '(गूंज -n" उपयोगकर्ता: दायरे: "&& गूंज -n" उपयोगकर्ता: दायरे: पासवर्ड "| md5sum - | कट-डी '' -एफ 1) >> आउटफाइल' – blerontin

1

यहां एक स्क्रिप्ट है जो उपयोगकर्ता नामों की एक सूची में पढ़ेगी, प्रत्येक के लिए एक यादृच्छिक पासवर्ड उत्पन्न करेगी, और उन्हें एक htdigest फ़ाइल, और एक सादा पाठ फ़ाइल दोनों में आउटपुट करेगी। इसका परीक्षण लिनक्स पर किया गया है, लेकिन अन्य प्रणालियों के लिए संशोधित करने की आवश्यकता हो सकती है। विशेष रूप से, md5summd5 हो सकता है, और head हमेशा -c ध्वज स्वीकार करता है।

$ ./load_users.bash 

जिसके परिणामस्वरूप htdigest फ़ाइल:

$ cat passwd.htdigest 
joe:MyRealm:2603a6c581f336f2874dbdd253aee780 
curly:MyRealm:fd3f9d87bba654439d5ba1f32c0286a8 
larry:MyRealm:c1c3c0dc50a9b97e9f7ee582e3fce892 

$ cat users.txt 
joe 
curly 
larry 

स्क्रिप्ट चल रहा है:

#!/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 

यह वही है इनपुट और परिणाम है, की तरह लग रहे पहले उपयोगकर्ता नाम फ़ाइल है

और सादा पाठ फाई le:

$ cat passwd.txt 
joe:aLnqnrv0 
curly:3xWxHKmv 
larry:7v7m6mXY 
संबंधित मुद्दे