LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-18-2012, 01:58 PM   #1
g1103
LQ Newbie
 
Registered: Apr 2011
Posts: 3

Rep: Reputation: 0
scripting password reset to htdbm (apache user)


Hi all,

I'm trying to write a script that will pass a "random" password to the htdbm command to reset an apache user password.

The goal here is to write the script in such a way that the person who is running the script doesn't know the password of the apache user they are resetting.

My problem right now is that I can't seem to get my variable that holds the new password into the htdbm command. this is line 24. I can't help but wonder if I'm doing something dumb here =/

Can someone look and see a way to accomplish my goal?

Code:
PS3='Option or Enter: '
PS4=''

DBDEST=/usr/local/apache/passwd/passwords.htdbm
LOGDEST=/var/log/audit/audit.log

# shell function to generate passwords
genpasswd() {
        local l=$1
        [ "$l" == "" ] && l=7
        tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs
}

NEWPASS=`genpasswd`

echo $NEWPASS

# add a user
functionAdd()
{
echo "Enter the username as <FirstNameLastName>:"
echo
read NAME
htdbm $DBDEST $NAME < $NEWPASS
echo
echo "Added $NAME" >> $LOGDEST
}

# teh menu

select i in List Add Reset Remove Quit
do
   case $i in
      List)  htdbm -l $DBDEST;echo;;
      Add)      functionAdd;;
#      Comment)  echo "COMMENT: Enter username to comment:";echo;read NAME;echo "Enter Comment:";echo;read COMMENT;htdbm -t $DBDEST $NAME $COMMENT;;
      Reset) echo "RESET: Enter username to Reset:";echo;read NAME;htdbm $DBDEST $NAME;echo;echo "Reset $NAME" >> $LOGDEST;;
      Remove)  echo "REMOVE: Enter the username to remove:";echo;read NAME;htdbm -x $DBDEST $NAME;echo;echo "Removed $NAME" >> $LOGDEST;;
      Quit)  break;;
   esac
done
 
Old 05-18-2012, 03:19 PM   #2
g1103
LQ Newbie
 
Registered: Apr 2011
Posts: 3

Original Poster
Rep: Reputation: 0
nevermind... solution was to replace

Quote:
htdbm $DBDEST $NAME < $NEWPASS
with

Quote:
htdbm -b $DBDEST $NAME $NEWPASS
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to reset (forgotten) user password? Cartech3 Linux - Newbie 6 02-05-2012 01:31 AM
How to reset FTP user password? anandrhce Linux - General 2 08-27-2010 10:43 PM
domain user under samba must reset the password mianmajidali Linux - Server 1 05-04-2009 08:05 AM
Apache authentication (.htaccess) password reset page hattori.hanzo Linux - Newbie 0 11-05-2008 12:01 AM
Reset user password via script fluffyvoidbunny SUSE / openSUSE 8 03-10-2006 02:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:28 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration