Escaping Encrypted password strings

Thread Solved

Join Date: May 2004
Posts: 10
Reputation: ajcamp is an unknown quantity at this point 
Solved Threads: 0
ajcamp ajcamp is offline Offline
Newbie Poster

Escaping Encrypted password strings

 
0
  #1
May 23rd, 2007
I'm trying to add users via a script using the following command.
The result is that I am only getting a portion of the encrypted password
in the /etc/shadow file. I've tried lots of variations on using ' hard quotes with no luck.

Any help? Thanks.

USER=newuser
PASSWD=`openssl passwd -1 $USER`

echo $PASSWD returns
$1$2DIVvhnL$5aSr5G1O17cQXdG8HshOu.

CMD="useradd -p `openssl passwd -1 $USER` $USER"
or
CMD="useradd -p $PASSWD $USER"

results in the following in /etc/shadow:
newuserIVvhnLaSr5G1O17cQXdG8HshOu.:13656:0:99999:7:::

The $1$2 portion of the passwd has been dropped. If there are other special characters in the password string, such as $ or / then the password gets truncated at those points as well.

I've tried variations like

PASSWD=`openssl passwd -1 $USER`
CMD="useradd -p $PASSWD $USER"
CMD="useradd -p ${PASSWD} $USER"

etc.

Thanks
Andrew
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 10
Reputation: ajcamp is an unknown quantity at this point 
Solved Threads: 0
ajcamp ajcamp is offline Offline
Newbie Poster

Re: Escaping Encrypted password strings

 
0
  #2
May 23rd, 2007
Ah, This works

CMD="useradd -p '`openssl passwd -1 $USER`' $USER"
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the IT Professionals' Lounge Forum
Thread Tools Search this Thread



Tag cloud for IT Professionals' Lounge
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC