Password recovery in login script help


 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Password recovery in login script help
# 1  
Old 03-06-2011
Power Password recovery in login script help

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

Hi guys. My case study is about creating a script that includes password recovery whenever a user forgets his/her password. I was not allowed by my instructor to have the login script of the admin.

So, I created a script in my account that will show only a sample. I have a "useradd" script in which a user can create an account in my account. He/she will enter his/her username, password, answer to 5 questions for password recovery. His/her information will be stored in the "login_users" script. And then, in the "profile" script, he can now have a chance to login.

My main problem is, if he/she entered a wrong password, it goes back to the profile script again without saying the, "did you forgot your password?" and he can't have a chance to choose which to answer in the 5 questions. I think there's a problem in my "login" script and I ask for your assistance.

Also, my problem in the "login" script is, how can I recover an info from a script to another script?? like for example, "pass" is a variable assigned for the real password of the user when he created an account in the "useradd" script, the info is stored in the "login_users" script. how can I access pass in the "login" script I have??

Another is, how can I hide the login_users script, because it should be hidden because all the info of the users are in there including there passwords.

Lastly, how can I hide the password whenever a user logs in. Usually, password is invisible in the login..

You can try my scripts to understand my problems, Thank you.

2. Relevant commands, code, scripts, algorithms:

Here are the related scripts: profile, useradd, userlist, (the login_users script will have a content whenever there's an account added in the useradd script)
Code:
#============================================================
#  Script Name:   profile
#  By:            JRG
#  Date:          March 5, 2011
#  Purpose:       main menu 
#  Command Line:  profile
#===========================================================
profile=~/casestudies/users
loop=y
while [ "$loop" = y ]
do
  clear
  tput cup 3 12; echo "  Welcome to your profile  "
  tput cup 4 12; echo "==========================="
  tput cup 6 9; echo "What do you want to do? "
  tput cup 7 9; echo "C - create an account"
  tput cup 8 9; echo "L - Login"
  tput cup 9 9; echo "Q - Quit"
   read choice || continue
     case $choice in
       [Cc]) ./useradd;;
       [Ll]) ./login1 ;;
       [Qq]) exit ;;
        *) tput cup 13 4; echo "Invalid Code"; read choice ;;
     esac
done



#============================================================
#  Script Name:   userlist
#  By:            JRG
#  Date:          March 5, 2011
#  Purpose:       Use awk to format colon-separated fields
#		  in a flat file and display to the screen
#  Command Line:  userlist
#===========================================================
clear
  tput cup 2 20; echo "User List"
  tput cup 3 20; echo "========="
  tput cup 5 0; echo "P - Print User List"
  awk -F: '{printf "%-12s %-12s %s\t%s %s %10.10s %s\n", $2, $3, $4, $1, $5, $6, $7}' login_users



#============================================================
#  Script Name:   useradd
#  By:            JRG
#  Date:          March 5, 2011
#  Purpose:       A shell script used to add 
#		  new user accounts to the login_users file
#  Command Line:  useradd
#===========================================================
trap "rm ~/tmp/* 2> /dev/null; exit" 0 1 2 3
userfile=~/casestudies/login_users

  clear
  tput cup 1 4; echo "User Accounts Additions"
  tput cup 2 4; echo "======================="
  tput cup 4 4; echo "Username : "
  tput cup 5 4; echo "Password : "
  tput cup 6 4; echo "Answer the following questions in case of password recovery"
  tput cup 7 4; echo "A. What is your 5th favorite color? "
  tput cup 8 4; echo "B. What is your favorite food? "
  tput cup 9 4; echo "C. What is the name of your pet? "
  tput cup 10 4; echo "D. What is the middle name of your mother's maiden name? "
  tput cup 11 4; echo "E. What is the model number of your laptop/monitor? "
  tput cup 13 4; echo "(Q)uit: "
  
  if [ "$username" = "q" ]
	then 
	  clear; exit   
  fi
  tput cup 4 18; read username
  tput cup 5 18; read passwd
  tput cup 7 18; read A
  tput cup 8 18; read B
  tput cup 9 18; read C
  tput cup 10 18; read D
  tput cup 11 18; read E	
# Check to see if username is not blank before you
#write to disk
  if [ "$username" > "           " ] 
  then echo "$username:$passwd:$A:$B:$C:$D:$E" >> $userfile 
  fi
  tput cup 13 10; echo -n "(q)uit: "
  tput cup 13 10; read choice
  if [ "$choice" = "q" ]
	then 
	  clear; exit   
  fi

3. The attempts at a solution (include all code and scripts):

This is the script in which I'm having a problem, this is my attempted script,
Code:
#============================================================
#  Script Name:   login1
#  By:            JRG
#  Date:          March 5, 2011
#  Purpose:       A shell script that enables a user to 
#		  login and recover password
#  Command Line:  login
#===========================================================
trap "rm ~/tmp/* 2> /dev/null; exit" 0 1 2 3
userfile=~/casestudies/login_users
  clear
  echo "      Login      "
  echo "================="
  echo -n "Username: " ; read username 
  echo -n "Password: " ; read passwd      

             
                while ["$pass" != "$passwd"]; do
                        echo "Incorrect password."
                        echo -n "Did you forgot your password (y)es or (n)o?: " 
                        read choice || continue
                        case $choice in
                             [Nn]) echo "Verify Password: " ; read passwd;
                  done
                       while ["$answer"!="$A|$B|$C|$D"]do
                             [Yy]) echo "Then choose a question to answer below"
                                   echo "A. What is your 5th favorite color? "
                                   echo "B. What is your favorite food? "
                                   echo "C. What is the name of your pet? "
                                   echo "D. What is the middle name of your mother's maiden name? "
                                   echo "E. What is the model number of your laptop/monitor? "
                             read question || continue
                   
                                case $question in
                                [Aa]) echo -n "answer: " ; read answer
                                     if["$answer"="$A"]
                                 then 
                                     echo "Correct, your password is: " $pass
                                 else
                                     echo "Incorrect. Choose another question to answer." ; read answer
                                 fi ;;
                                [Bb])echo -n "answer: " ; read answer
                                     if["$answer"="$B"]
                                 then 
                                     echo "Correct, your password is: " $pass
                                 else
                                     echo "Incorrect. Choose another question to answer." ; read answer
                                 fi ;;
                                [Cc])echo -n "answer: " ; read answer
                                     if["$answer"="$C"]
                                 then 
                                     echo "Correct, your password is: " $pass
                                 else
                                     echo "Incorrect. Choose another question to answer." ; read answer
                                 fi ;;
                                [Dd])echo -n "answer: " ; read answer
                                     if["$answer"="$D"]
                                 then 
                                     echo "Correct, your password is: " $pass
                                 else
                                     echo "Incorrect. Choose another question to answer." ; read answer
                                 fi ;;
                                [Ee])echo -n "answer: " ; read answer
                                     if["$answer"="$E"]
                                 then 
                                     echo "Correct, your password is: " $pass
                                 else
                                     echo "Incorrect. Choose another question to answer." ; read answer
                                 fi ;;
                       done
                                esac                     
                        esac

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Saint Louis University, Baguio City, Philippines, Ms. Castillo, IT 222

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).

Last edited by Scott; 03-06-2011 at 06:24 AM.. Reason: Added code tags
# 2  
Old 03-08-2011
In your script the $pass variable is not set ...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script for login to servers with user name and password and execute commands

I am having the 15 servers which need to do the monitoring Hi I need a shell script, By which i can log in to multiple servers and execute the commands.. I need to specify the username and password in the scripts. Please help me to write the script so that it can login with username and... (5 Replies)
Discussion started by: nandan8a
5 Replies

2. Shell Programming and Scripting

bash script for password recovery

Hi all, I'm a complete newbie to bash scripting, although I have some experience in programming. The thing is that I have a .dmg file on my mac which I protected with a password, and now I've forgotten it. I remember the first few letters of the password and the characters that represent the... (4 Replies)
Discussion started by: sujay.jauhar
4 Replies

3. Cybersecurity

Password Recovery

Perderabo has made posted a good thread in the FAQ section here: Lost root password / Can't login as root | Unix Linux Forums | Answers to Frequently Asked Questions (6 Replies)
Discussion started by: norsk hedensk
6 Replies

4. Cybersecurity

password recovery

I am trying to access an old email account but cannot recall the password and the backup email account has been closed, also. I need instructions or an expert who can assist recovering my password for web-based email account. (4 Replies)
Discussion started by: pp_mcgee
4 Replies

5. Shell Programming and Scripting

without password to login into remote machine- in the script ??

HI, I need to write a script .. when I run this script , will directly goto that remote machine without asking password.. Once it is entered, I needs to transfer some of the log files... how can I proceed ? (7 Replies)
Discussion started by: hegdeshashi
7 Replies

6. Forum Support Area for Unregistered Users & Account Problems

password recovery

hello, my password got lost - and your service to generate new passwords does not work -ive tried it out 50 times the last week or so, never got a single mail from it... please generate a new password for my account "congo" with mailadress. thanks. Thomas (3 Replies)
Discussion started by: congo00000001
3 Replies

7. UNIX for Dummies Questions & Answers

Password Recovery

Hi, I am new to unix and I set a password for a user and now I need to recover what that password was. Is there a way, where as root, I can view what a users passwords is? Thanks, Eric (2 Replies)
Discussion started by: ejbrever
2 Replies

8. Shell Programming and Scripting

FTP Script with hidden login name and Password

hi, i need a method to hide the login name and password ....during FTP ....in the script.. thnks (3 Replies)
Discussion started by: scorpiyanz
3 Replies

9. Shell Programming and Scripting

help for db password recovery

hi,all my database (.db) is created by sysbase adaptive server anywhere7.0 ! the user id is DBA. but I lost the password . Could you recovery the passwrod of this db file? thanks ! iwind (1 Reply)
Discussion started by: northwind
1 Replies

10. UNIX for Dummies Questions & Answers

Password recovery

We recently terminated a developer at my place of employment who created scripts on a windows server (that i do not have access to) that invoke FTP sessions on my UnixWare 7.1.1 servers. I need to know the password that is being used. Does anyone know of a good password crack? (8 Replies)
Discussion started by: rm -r *
8 Replies
Login or Register to Ask a Question