Script to input encrpyted password into htdigest (Apache)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script to input encrpyted password into htdigest (Apache)
# 1  
Old 01-25-2012
Script to input encrpyted password into htdigest (Apache)

Hey guys,

This is my situation.

I'm using the script to add a user account, however, i want the same details copied into the htdigest password list. the format is username:virtualservername:hashed/encrypted password.

This is the command :

sudo htdigest /etc/apache2/passwords VIRTUALSERVERNAME USERNAME

This are the exert from my script:

Code:
 
# Adding User (1st Step)
  read -p "Enter username : " username
  read -p "Enter password : " password
  egrep "^$username" /etc/passwd >/dev/null
  pass=$(perl -e 'print crypt($ARGV[0], "password")' $password)
  useradd -m -p $pass $username
  [ $? -eq 0 ] && echo "User has been added to system!" || echo "Failed to add a user!"
 
# Adding webuser to apache password list
sudo htdigest /etc/apache2/passwords VIRTUALSERVERNAME $username <<-EOF
$password
$password
EOF

This doesn't work unfortunately.

I would still be asked to insert the password manually.

P/s: Removed the -s prefix for the password form as i want to see the password while typing it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help OS X script : password input

Hello Sorry for the question.. i would like to make a script for OS X that allow me to change the password for a user account. i have to use this script on several iMac with the same user/password. i want to store the passwords inside the script, no security problems involved. the... (9 Replies)
Discussion started by: araan87
9 Replies

2. Shell Programming and Scripting

Input password to bash script, save, and enter when needed

I am looking for a way to start a script and have it prompt for a password that will be used later on in the script to SSH to another host and to SFTP. I don't want the password to be hard coded. Below is my script with the actual IP's and usernames removed. #!/usr/bin/expect -f... (2 Replies)
Discussion started by: jbrass
2 Replies

3. Shell Programming and Scripting

Shell script password input

hy, I wrote a simple shell script to monitor (with Nagios) a SNX VPN function. Here the Code snippet: testing=`ssh user@IP-address 'ls /etc/sysconfig/network-scripts/ifcfg-eth0'` #echo $testing if ; then echo "VPN is working" exit 0 else snx -s server -u user ... (2 Replies)
Discussion started by: tomies
2 Replies

4. Shell Programming and Scripting

password file as std input to script

I'm a fairly new AIX admin (disclaimer). We have SQL scripts written by end users that use a userid and passwd to connect to our DB2 database. Is it possible to create an "input file" that contains the db2 connect parameters and yet secure the file from the SQL creator? i.e., they can "use"... (2 Replies)
Discussion started by: mpheine
2 Replies

5. Web Development

Apache Password

Hello, What could break if I were to change the password for the apache user? Thanks... (1 Reply)
Discussion started by: buckeye1288
1 Replies

6. Shell Programming and Scripting

Input Password

I am writing a script that can automatically login to Storage CAM console. i use this command, ./sscs login -u user -h localhost. at that time it will prompt for password, is it possible for store password in a file and supply it when it waits for password. Thanks in advance. Regards SK (1 Reply)
Discussion started by: cutechaps
1 Replies

7. UNIX for Dummies Questions & Answers

To append \ in the input password

Hi I have the following issue i am going to ask from the user the password The password can have $ anywhere that is first last or in between but i have to append \ before the $ sign in the password can anyone please help For example o/p in the console will be like the... (3 Replies)
Discussion started by: ssuresh1999
3 Replies

8. Linux

Apache Server how to set password for all access?

Hello all, I am new to Linux and am trying to set a password for access to Apache server access. I have both Apache and Tomcat installed in my server, Apache forwards the requests to our Tomcat server which servers the java application we have. The Java application is not configured to ask... (1 Reply)
Discussion started by: firefox211
1 Replies

9. UNIX for Advanced & Expert Users

password required when using input redirection

Hello, I need to change user and run some commands by using a script. lets say, I'm using su - someuser << start password required -----> how can I enter the password here command 1 command 2 command 3 command 4 start While trying to run this I got the following message: "standard... (2 Replies)
Discussion started by: Alalush
2 Replies

10. Shell Programming and Scripting

Input Password

I have a script which connects to database. I want user to input user name and password but dont want the password characters to be displayed on screen. How can i accept input from user in encrypted form. (2 Replies)
Discussion started by: baglasumit21
2 Replies
Login or Register to Ask a Question
dxchpwd(1X)															       dxchpwd(1X)

NAME
dxchpwd - Create or change password program SYNOPSIS
dxchpwd dxchpwd -r | -l dxchpwd [-r | -l] -q dxchpwd [-r | -l] -u username OPTIONS
If dxchpwd is invoked without any options, it is assumed that the current user's password is to be changed. The following options are also accepted: Tells dxchpwd that the password change is to be done for a Local user. This can be combined with the -u and -q options. Tells dxchpwd that the password change is to be done for a NIS user. This can only be done from a NIS master and can be combined with the -u and -q options. Tells dxchpwd to query the user for the user name of the account whose password is to be changed. Tells dxchpwd to change this user's password. DESCRIPTION
The dxchpwd command lets you change your password. When you invoke the dxchpwd command, the program prompts you for the old password and then for the new password. Next, the program asks you for the new password again, to verify that you have typed it correctly. Note that the passwords are not displayed on the screen. Your new password must meet the length requirements specified by the authorization database for the user whose password is being changed. If your system is running with enhanced security, you may have to choose a password from a list of randomly generated passwords or you may be prohibited from changing your password until its minimum lifetime has expired, as specified in the authorization database. EXAMPLES
The following example requests that the password be changed for user smith: dxchpwd -u smith FILES
Password file Protected Password Database dxchpwd executable SEE ALSO
X(1X), xdm(1X), passwd(1) dxchpwd(1X)