1

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?

gvkv
  • 293
  • 3
  • 14

1 Answers1

0

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).

lapo
  • 311
  • 3
  • 8
  • 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 04 '09 at 14:24