944,017 Members | Top Members by Rank

Ad:
May 23rd, 2007
0

Escaping Encrypted password strings

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ajcamp is offline Offline
10 posts
since May 2004
May 23rd, 2007
0

Re: Escaping Encrypted password strings

Ah, This works

CMD="useradd -p '`openssl passwd -1 $USER`' $USER"
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ajcamp is offline Offline
10 posts
since May 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in IT Professionals' Lounge Forum Timeline: Computer Applications... [?]
Next Thread in IT Professionals' Lounge Forum Timeline: Any open source contributor here?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC