[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ezjail encrypted password




On Wed, 22 Aug 2007, Troy Schultz wrote:

I really hate to bug you but I am going through all of the ezjail flavors and am having one problem with the user creation, as follows:

No problem at all. I like the smell of a challenge in the morning :)

# echo -n '$1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91' |\
# pw useradd -n admin -u 1001 -s /bin/sh -m -d /home/admin -G wheel -c 'Admin User' -H 0

How do I create the password -> $1$p75bbfK.$Kz3dwkoVlgZrfLZdAXQt91 is there a program that you used on Freebsd to create or is this something that you put together? If you could point me in the right direction I'd appreciate it.

In fact, the passwd stuff is really well hidden in the pw sources. I made a little script that creates a temporary master.passwd, adds a user and deletes everything behind it. The script is beer ware, must be run as root (since stupid pw only runs as root) and takes username and password as commandline parameters. No checks are performed on parameters. It outputs username:hashedpassword in the form appropriate to copy to /etc/master.passwd, if you only run cut -f 2, you'll only get the password as needed in ezjails flavours. (Note, that username could be used as salt and therefore is mandatory.)

==== snip: makepasswd.sh ====
#!/bin/sh

[ $# != 2 ] && echo "Usage: $0 user passwd" && exit

user=$1
password=$2

tdir="`mktemp -d /tmp/$$.XXXXXXX`"
touch ${tdir}/master.passwd ${tdir}/passwd ${tdir}/pwd.db
echo ${password} | pw useradd ${user} -V ${tdir} -h 0 2>/dev/null
cut -f 1,2 -d : ${tdir}/master.passwd
rm -r ${tdir}

==== snip: makepasswd.sh ====

Oh, and thanks of course for all the work you have done, I am pretty new to the jail stuff and ezjail is helping immensely

Nice to hear, thank you! Hope to get more feedback.

  erdgeist