+ -
当前位置:首页 → 问答吧 → 关于pw添加用户的一个疑问

关于pw添加用户的一个疑问

时间:2003-11-29

来源:互联网

用pw useradd lhmm建立一个帐户后,这个帐户的初始密码是什么?

作者: lhmwzy   发布时间: 2003-11-29

我以前也问过这个问题,但没有人知道。估计是不让知道的。

作者: devel   发布时间: 2003-11-29

那我该怎么设置这个用户的初始密码呢?
不会再用passwd lhmm来设一个密码吧。
这样的话,pw还不如useradd来的方便呢

作者: lhmwzy   发布时间: 2003-11-29

密码不会是随机的吧,只能由root来更改?

作者: lhmwzy   发布时间: 2003-11-29

pw is useful for script, suppose that you have 500 user to create... with pw, you can let user define password themself.


from man pw:
-h fd This option provides a special interface by which interac-
tive scripts can set an account password using pw. Because
the command line and environment are fundamentally insecure
mechanisms by which programs can accept information, pw
will only allow setting of account and group passwords via
a file descriptor (usually a pipe between an interactive
script and the program). sh, bash, ksh and perl all pos-
sess mechanisms by which this can be done. Alternatively,
pw will prompt for the user's password if -h 0 is given,
nominating stdin as the file descriptor on which to read
the password. Note that this password will be read only
once and is intended for use by a script rather than for
interactive use. If you wish to have new password confir-
mation along the lines of passwd(1), this must be imple-
mented as part of an interactive script that calls pw.

If a value of `-' is given as the argument fd, then the
password will be set to `*', rendering the account inacces-
sible via password-based login.

作者: werix   发布时间: 2003-11-29

呵呵,还不是很明白。

作者: lhmwzy   发布时间: 2003-11-29

可能我没写清楚,给你举个实例:

假设你有500新学生入学,你要给每个人都建立一个账号,作为管理员的你该怎么办?正常的办法是写一个script (脚本?),先把每个人的账号一下都建立起来,但是不给定密码,给学生们半天的时间,让他们上机自己给密码,如果有人捣乱抢先的话,你再重新设制被抢账号。PW 的作用是让你写script,useradd/adduser 一类是加一两个人时用。man pw , -h 选项让你可以执行script的同时问你要给定的密码,这样可以防止抢账号。清楚了嘛?

作者: werix   发布时间: 2003-11-29

OK,谢谢老大。

作者: lhmwzy   发布时间: 2003-11-29

好像有一个台湾的网站上有关于加大量用户的文章, haha网站吧!

作者: rianren   发布时间: 2003-11-29

找不到那个台湾的网站

作者: lhmwzy   发布时间: 2003-11-29