Search code examples
md5squid.htpasswd

How to mass add squid users (htpasswd)


I normally add a new user in squid with this command

touch /etc/squid/squid_access; htpasswd /etc/squid/squid_access "NEWuser"

then it prompts me to input the password for "newuser" and conirm it again.

How can I automate this so that I add a range of new users(user1-user500) with the same or password?


Solution

  • You might get what you want with the seq command, on which youu can perform a loop in bash. You might get what you want with this or something similar:

    #!/bin/sh
    touch /etc/squid/squid_access
    for i in $(seq 1 500)
    do
        htpasswd /etc/squid/squid_access "new-user-$i"
    done