mkv

lighttpd htdigest

mkv
Aug 10th, 2014
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.99 KB | None | 0 0
  1. # Password protecting a folder with lighttpd
  2. # ==========================================
  3.  
  4. # First, make yourself root.
  5. #
  6. # Replace the values in the first 5 lines (if necessary)
  7. # then copy the rest of the file into putty:
  8.  
  9.  user="ed"
  10. realm="javs"
  11.  pass="hunter2"
  12.  root="/var/www"
  13.   dir="/topsecret"
  14.  
  15. hash=$(echo -n "$user:$realm:$pass" | md5sum | cut -b -32) &&
  16. echo "$user:$realm:$hash" > "/etc/lighttpd/.passwd" &&
  17. { rm "/etc/lighttpd/conf-enabled/99-dauth.conf"; true; } &&
  18. echo '
  19. server.modules += ( "mod_auth" )
  20. auth.backend = "htdigest"
  21. auth.backend.htdigest.userfile = "/etc/lighttpd/.passwd"
  22. auth.require = ( "vDIR/" =>
  23. (
  24. "method" => "digest",
  25. "realm" => "vREALM",
  26. "require" => "valid-user"
  27. )
  28. )
  29. ' |
  30. sed "s*vDIR*$dir*" |
  31. sed "s*vREALM*$realm*" > \
  32. "/etc/lighttpd/conf-available/99-dauth.conf" &&
  33. ln -s \
  34. "/etc/lighttpd/conf-available/99-dauth.conf" \
  35. "/etc/lighttpd/conf-enabled/99-dauth.conf" &&
  36. service lighttpd restart &&
  37. echo "ok done" ||
  38. echo "something went fuck"
Advertisement
Add Comment
Please, Sign In to add comment