Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using pw to add users to a FreeBSD system and I'd like to use the -H option, e.g.,

pw add user userfoo -H pwfile

The man page says that I need to have a password "supplied already encrypted in a form suitable for writing directly to the password database."

So what's suitable? In particular, what kind of encryption algorithm should I use and what's the format of the file?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

I guess that means the form in which password are written in /etc/master.passwd that is, the output of crypt(3) which usually is a MD5 salted hash of this form:

$1$salt$hash

PS: that's a strange format you're quoting, as FreeBSD man page actually says this:

pw [−V etcdir] useradd [name|uid] [−C config] [−q] [−n name] [−u uid]
   [−c comment] [−d dir] [−e date] [−p date] [−g group] [−G grouplist]
   [−m] [−M mode] [−k dir] [−w method] [−s shell] [−o] [−L class]
   [−h fd | −H fd] [−N] [−P] [−Y]

−H fd     Read an encrypted password string from the specified file
          descriptor. [...]

and while "add user" seems to be an alias of "useradd", a file descriptor is not a file but a number (e.g. 1 is stdout, 2 is stderr).

share|improve this answer
    
I guess I shouldn't work so late so that I read the man page properly. File descriptor is no problem anyway--I can just read a file when I run my script and pass it along. Thanks. –  gvkv Sep 4 '09 at 14:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.