
我正在使用 pw 將使用者新增至 FreeBSD 系統,並且我想使用 -H 選項,例如,
pw add user userfoo -H pwfile
手冊頁說,我需要一個密碼「已以適合直接寫入密碼資料庫的形式加密提供」。
那什麼是合適的呢?特別是,我應該使用什麼樣的加密演算法以及檔案的格式是什麼?
答案1
我猜這意味著密碼的寫入形式/etc/master.passwd
,即其輸出crypt(3)
通常是以下形式的 MD5 salted 雜湊:
$1$salt$hash
PS:您引用的格式很奇怪,因為 FreeBSD 手冊頁面實際上是這樣說的:
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. [...]
雖然「add user」似乎是「useradd」的別名,但檔案描述子不是檔案而是數字(例如1是stdout,2是stderr)。