summaryrefslogtreecommitdiff
path: root/man/zh_CN/man8/newusers.8
blob: 3c4277a7387afd9bd3cb178059b4f18ac97b4d36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
'\" t
.\"     Title: newusers
.\"    Author: Julianne Frances Haugh
.\" Generator: DocBook XSL Stylesheets v1.78.1 <http://docbook.sf.net/>
.\"      Date: 2014-05-09
.\"    Manual: 系统管理命令
.\"    Source: shadow-utils 4.2
.\"  Language: Chinese Simplified
.\"
.TH "NEWUSERS" "8" "2014-05-09" "shadow\-utils 4\&.2" "系统管理命令"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "名称"
newusers \- 批量更新和创建新用户
.SH "大纲"
.HP \w'\fBnewusers\fR\ 'u
\fBnewusers\fR [\fI选项\fR] [\fI文件\fR]
.SH "描述"
.PP
The
\fBnewusers\fR
command reads a
\fIfile\fR
(or the standard input by default) and uses this information to update a set of existing users or to create new users\&. Each line is in the same format as the standard password file (see
\fBpasswd\fR(5)) with the exceptions explained below:
.PP
pw_name:pw_passwd:pw_uid:pw_gid:pw_gecos:pw_dir:pw_shell
.PP
\fIpw_name\fR
.RS 4
这是用户的用户名。
.sp
既可以是新用户名也可以是现有用户名(也可以是
\fBnewusers\fR
以前创建的用户)。现有用户时,将会更改用户信息,否则会创建新用户。
.RE
.PP
\fIpw_passwd\fR
.RS 4
此字段将被加密然后用于加密后密码的新值。
.RE
.PP
\fIpw_uid\fR
.RS 4
此字段用于定义用户的 UID。
.sp
如果此字段为空,\fBnewusers\fR
会自动确定一个新的(未使用的)UID。
.sp
如果此字段包含一个数字,此数字会用于 UID。
.sp
如果此字段包含已经使用了的用户名(或者
\fBnewusers\fR
在前边已经创建的一个用户),将会使用指定用户的 UID。
.sp
如果一个现有用户更改了 UID,此用户的文件所有权需要手动修复。
.RE
.PP
\fIpw_gid\fR
.RS 4
此字段用于定义用户的主组 ID。
.sp
如果此字段包含一个现有组的组名(或者
\fBnewusers\fR
在前边创建的一个组),此组的 GID 会被用于做此用户的主组 ID。
.sp
如果此字段是一个数字,此数字会被用作此用户的主组 ID。如果没有对应此 GID 的现有组,将会使用此 GID 创建一个新组,名称和用户名相同。
.sp
如果此字段为空,将会使用用户名作为组名,\fBnewusers\fR
自动确定的一个 GID 作为主组 ID 来创建一个新组。
.sp
如果此字段包含一个不存在的组的名字(也没有由
\fBnewusers\fR
在前边创建),将使用指定的组名和
\fBnewusers\fR
自动确定的 GID 创建一个组,并作为用户的主组。
.RE
.PP
\fIpw_gecos\fR
.RS 4
此字段复制到用户的 GECOS 字段。
.RE
.PP
\fIpw_dir\fR
.RS 4
此字段用于定义用户的主目录。
.sp
如果此字段指定的不是现有的目录,将会创建指定的目录,所有权设置为创建或更新的用户及其主组。
.sp
如果现有用户的主目录变更,\fBnewusers\fR
不会移动或者复制旧目录的内容到新位置。这需要手动完成。
.RE
.PP
\fIpw_shell\fR
.RS 4
此字段定义了用户的 shell。对此字段不进行任何检查。
.RE
.PP
\fBnewusers\fR
首先尝试创建或更改所有指定的用户,然后将这些更改写入用户或组数据库。如果发生错误(除非是在最后写入数据库过程中),不会有任何更改。
.PP
此命令一般用于在大型的应用环境中,对大量账户进行一次性更新。
.SH "选项"
.PP
\fBnewusers\fR
命令可以使用的选项有:
.PP
\fB\-c\fR, \fB\-\-crypt\-method\fR
.RS 4
使用指定的方法加密密码。
.sp
可用的方法有 DES, MD5, NONE, and SHA256 或 SHA512,前提是您的 libc 支持这写方法。
.RE
.PP
\fB\-h\fR, \fB\-\-help\fR
.RS 4
现实帮助信息并退出。
.RE
.PP
\fB\-r\fR, \fB\-\-system\fR
.RS 4
创建一个系统账户。
.sp
System users will be created with no aging information in
/etc/shadow, and their numeric identifiers are chosen in the
\fBSYS_UID_MIN\fR\-\fBSYS_UID_MAX\fR
range, defined in
login\&.defs, instead of
\fBUID_MIN\fR\-\fBUID_MAX\fR
(and their
\fBGID\fR
counterparts for the creation of groups)\&.
.RE
.PP
\fB\-R\fR, \fB\-\-root\fR\ \&\fICHROOT_DIR\fR
.RS 4
Apply changes in the
\fICHROOT_DIR\fR
directory and use the configuration files from the
\fICHROOT_DIR\fR
directory\&.
.RE
.PP
\fB\-s\fR, \fB\-\-sha\-rounds\fR
.RS 4
使用指定次数的轮转来加密密码。
.sp
值 0 表示让系统为加密方法选择默认的轮转次数 (5000)。
.sp
会强制最小 1,000,最大 9,9999,9999
.sp
您只可以对 SHA256 或 SHA512 使用此选项。
.sp
默认,轮转数由
/etc/login\&.defs
文件中的 SHA_CRYPT_MIN_ROUNDS 和 SHA_CRYPT_MAX_ROUNDS 变量确定。
.RE
.SH "CAVEATS"
.PP
输入文件必须受到保护,因为它包含未加密的密码。
.PP
您需要确保你吗和加密方法符合系统的密码策略。
.SH "配置文件"
.PP
在
/etc/login\&.defs
中有如下配置变量,可以用来更改此工具的行为:
.PP
\fBENCRYPT_METHOD\fR (string)
.RS 4
这定义了系统加密密码的默认算法(如果没有在命令行上指定算法)。
.sp
可以使用如下值:\fIDES\fR
(default),
\fIMD5\fR, \fISHA256\fR, \fISHA512\fR\&.
.sp
注意,此参数会覆盖
\fBMD5_CRYPT_ENAB\fR
变量。
.RE
.PP
\fBGID_MAX\fR (number), \fBGID_MIN\fR (number)
.RS 4
\fBuseradd\fR,\fBgroupadd\fR
或
\fBnewusers\fR
创建的常规组的组 ID 的范围。
.sp
\fBGID_MIN\fR
和
\fBGID_MAX\fR
的默认值分别是 1000 和 60000。
.RE
.PP
\fBMAX_MEMBERS_PER_GROUP\fR (number)
.RS 4
每个组条目的最大成员数。达到最大值时,在
/etc/group
开始一个新条目(行)(使用同样的名称,同样的密码,同样的 GID)。
.sp
默认值是 0,意味着组中的成员数没有限制。
.sp
此功能(分割组)允许限制组文件中的行长度。这对于确保 NIS 组的行比长于 1024 字符。
.sp
如果要强制这个限制,可以使用 25。
.sp
注意:分割组可能不受所有工具的支持(甚至在 Shadow 工具集中)。您不应该使用这个变量,除非真的需要。
.RE
.PP
\fBMD5_CRYPT_ENAB\fR (boolean)
.RS 4
表示密码是否必须使用基于 MD5 的算法加密。如果设为
\fIyes\fR,新密码将使用可以和新版 FreeBSD 兼容的基于 MD5 的算法加密。它支持无限长度的密码以及更长的盐字符串。如果您需要将加密的密码复制到其它不理解新算法的系统,设置为
\fIno\fR。默认值是
\fIno\fR。
.sp
This variable is superseded by the
\fBENCRYPT_METHOD\fR
variable or by any command line option used to configure the encryption algorithm\&.
.sp
此变量已经废弃。您应该使用
\fBENCRYPT_METHOD\fR。
.RE
.PP
\fBPASS_MAX_DAYS\fR (number)
.RS 4
一个密码可以使用的最大天数。如果密码比这旧,将会强迫更改密码。如果不指定,就假定为 \-1,这会禁用这个限制。
.RE
.PP
\fBPASS_MIN_DAYS\fR (number)
.RS 4
两次更改密码时间的最小间隔。将会拒绝任何早于此的更改密码的尝试。如果不指定,假定为 \-1,将会禁用这个限制。
.RE
.PP
\fBPASS_WARN_AGE\fR (number)
.RS 4
密码过期之前给出警告的天数。0 表示只有只在过期的当天警告,负值表示不警告。如果没有指定,不会给警告。
.RE
.PP
\fBSHA_CRYPT_MIN_ROUNDS\fR (number), \fBSHA_CRYPT_MAX_ROUNDS\fR (number)
.RS 4
\fBENCRYPT_METHOD\fR
设为
\fISHA256\fR
或
\fISHA512\fR
时,此项确定加密算法默认使用 SHA 轮转数目(当轮转数没有通过命令行指定时)。
.sp
使用很多轮转,会让暴力破解更加困难。但是需要注意,认证用户时也会需要更多的 CPU 资源。
.sp
如果没有指定,libc 会选择默认的轮转数(5000)。
.sp
值必须在 1000 \- 999,999,999 之间。
.sp
如果只设置了一个
\fBSHA_CRYPT_MIN_ROUNDS\fR
或
\fBSHA_CRYPT_MAX_ROUNDS\fR
值,就会使用这个值。
.sp
如果
\fBSHA_CRYPT_MIN_ROUNDS\fR
>
\fBSHA_CRYPT_MAX_ROUNDS\fR,将会使用大的那个。
.RE
.PP
\fBSUB_GID_MIN\fR (number), \fBSUB_GID_MAX\fR (number), \fBSUB_GID_COUNT\fR (number)
.RS 4
If
/etc/subuid
exists, the commands
\fBuseradd\fR
and
\fBnewusers\fR
(unless the user already have subordinate group IDs) allocate
\fBSUB_GID_COUNT\fR
unused group IDs from the range
\fBSUB_GID_MIN\fR
to
\fBSUB_GID_MAX\fR
for each new user\&.
.sp
The default values for
\fBSUB_GID_MIN\fR,
\fBSUB_GID_MAX\fR,
\fBSUB_GID_COUNT\fR
are respectively 100000, 600100000 and 10000\&.
.RE
.PP
\fBSUB_UID_MIN\fR (number), \fBSUB_UID_MAX\fR (number), \fBSUB_UID_COUNT\fR (number)
.RS 4
If
/etc/subuid
exists, the commands
\fBuseradd\fR
and
\fBnewusers\fR
(unless the user already have subordinate user IDs) allocate
\fBSUB_UID_COUNT\fR
unused user IDs from the range
\fBSUB_UID_MIN\fR
to
\fBSUB_UID_MAX\fR
for each new user\&.
.sp
The default values for
\fBSUB_UID_MIN\fR,
\fBSUB_UID_MAX\fR,
\fBSUB_UID_COUNT\fR
are respectively 100000, 600100000 and 10000\&.
.RE
.PP
\fBSYS_GID_MAX\fR (number), \fBSYS_GID_MIN\fR (number)
.RS 4
\fBuseradd\fR、\fBgroupadd\fR
或
\fBnewusers\fR
创建的系统组的组 ID 的范围。
.sp
\fBSYS_GID_MIN\fR
和
\fBSYS_GID_MAX\fR
的默认值分别是 101 和
\fBGID_MIN\fR\-1。
.RE
.PP
\fBSYS_UID_MAX\fR (number), \fBSYS_UID_MIN\fR (number)
.RS 4
\fBuseradd\fR
或
\fBnewusers\fR
创建的系统用户的用户 ID 的范围。
.sp
\fBSYS_UID_MIN\fR
和
\fBSYS_UID_MAX\fR
的默认值分别是 101 和
\fBUID_MIN\fR\-1。
.RE
.PP
\fBUID_MAX\fR (number), \fBUID_MIN\fR (number)
.RS 4
\fBuseradd\fR
或
\fBnewusers\fR
创建的普通用户的用户 ID 的范围。
.sp
\fBUID_MIN\fR
和
\fBUID_MAX\fR
的默认值分别是 1000 和 60000。
.RE
.PP
\fBUMASK\fR (number)
.RS 4
文件模式创建掩码初始化为此值。如果没有指定,掩码初始化为 022。
.sp
\fBuseradd\fR
和
\fBnewusers\fR
使用此掩码设置它们创建的用户主目录的模式。
.sp
也被
\fBlogin\fR
用于指定用户的初始 umask。注意,此掩码可以被用户的 GECOS 行覆盖(当设置了
\fBQUOTAS_ENAB\fR
时),也可以被带
\fIK\fR
指示符的
\fBlimits\fR(5)
定义的限制值覆盖。
.RE
.SH "文件"
.PP
/etc/passwd
.RS 4
用户账户信息。
.RE
.PP
/etc/shadow
.RS 4
安全用户账户信息。
.RE
.PP
/etc/group
.RS 4
组账户信息。
.RE
.PP
/etc/gshadow
.RS 4
安全组账户信息。
.RE
.PP
/etc/login\&.defs
.RS 4
Shadow 密码套件配置。
.RE
.PP
/etc/subgid
.RS 4
Per user subordinate group IDs\&.
.RE
.PP
/etc/subuid
.RS 4
Per user subordinate user IDs\&.
.RE
.SH "参见"
.PP
\fBlogin.defs\fR(5),
\fBpasswd\fR(1),
\fBsubgid\fR(5), \fBsubuid\fR(5),\fBuseradd\fR(8)\&.