source: postlfs/security/shadow.xml@ d265d4c

10.0 10.1 11.0 11.1 11.2 11.3 12.0 12.1 7.10 7.4 7.5 7.6 7.6-blfs 7.6-systemd 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 basic bdubbs/svn elogind gnome kde5-13430 kde5-14269 kde5-14686 kea ken/TL2024 ken/inkscape-core-mods ken/tuningfonts krejzi/svn lazarus lxqt nosym perl-modules plabs/newcss plabs/python-mods python3.11 qt5new rahul/power-profiles-daemon renodr/vulkan-addition systemd-11177 systemd-13485 trunk upgradedb xry111/intltool xry111/llvm18 xry111/soup3 xry111/test-20220226 xry111/xf86-video-removal
Last change on this file since d265d4c was d265d4c, checked in by Krejzi <krejzi@…>, 12 years ago

remove pam_securetty from shadow instructions for now

git-svn-id: svn://svn.linuxfromscratch.org/BLFS/trunk/BOOK@9673 af4574ff-66df-0310-9fd7-8a98e5e911e0

  • Property mode set to 100644
File size: 22.8 KB
Line 
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
4 <!ENTITY % general-entities SYSTEM "../../general.ent">
5 %general-entities;
6
7 <!ENTITY shadow-download-http "http://pkg-shadow.alioth.debian.org/releases/shadow-&shadow-version;.tar.bz2 ">
8 <!ENTITY shadow-download-ftp " ">
9 <!ENTITY shadow-md5sum "d5f7a588fadb79faeb4b08b1eee82e9a">
10 <!ENTITY shadow-size "2.1 MB">
11 <!ENTITY shadow-buildsize "35 MB">
12 <!ENTITY shadow-time "0.3 SBU">
13]>
14
15<sect1 id="shadow" xreflabel="Shadow-&shadow-version;">
16 <?dbhtml filename="shadow.html"?>
17
18 <sect1info>
19 <othername>$LastChangedBy$</othername>
20 <date>$Date$</date>
21 </sect1info>
22
23 <title>Shadow-&shadow-version;</title>
24
25 <indexterm zone="shadow">
26 <primary sortas="a-Shadow">Shadow</primary>
27 </indexterm>
28
29 <sect2 role="package">
30 <title>Introduction to Shadow</title>
31
32 <para><application>Shadow</application> was indeed installed in LFS and
33 there is no reason to reinstall it unless you installed
34 <application>CrackLib</application> or
35 <application>Linux-PAM</application> after your LFS system was completed.
36 If you have installed <application>CrackLib</application> after LFS, then
37 reinstalling <application>Shadow</application> will enable strong password
38 support. If you have installed <application>Linux-PAM</application>,
39 reinstalling <application>Shadow</application> will allow programs such as
40 <command>login</command> and <command>su</command> to utilize PAM.</para>
41
42 &lfs70_checked;
43
44 <bridgehead renderas="sect3">Package Information</bridgehead>
45 <itemizedlist spacing="compact">
46 <listitem>
47 <para>Download (HTTP): <ulink url="&shadow-download-http;"/></para>
48 </listitem>
49<!-- <listitem>
50 <para>Download (FTP): <ulink url="&shadow-download-ftp;"/></para>
51 </listitem> -->
52 <listitem>
53 <para>Download MD5 sum: &shadow-md5sum;</para>
54 </listitem>
55 <listitem>
56 <para>Download size: &shadow-size;</para>
57 </listitem>
58 <listitem>
59 <para>Estimated disk space required: &shadow-buildsize;</para>
60 </listitem>
61 <listitem>
62 <para>Estimated build time: &shadow-time;</para>
63 </listitem>
64 </itemizedlist>
65
66 <bridgehead renderas="sect3">Additional Downloads</bridgehead>
67 <itemizedlist spacing='compact'>
68 <listitem>
69 <para>Required patch: <ulink
70 url="http://www.&lfs-domainname;/patches/lfs/development/shadow-&shadow-version;-nscd-1.patch"/>
71 </para>
72 </listitem>
73 </itemizedlist>
74
75 <bridgehead renderas="sect3">Shadow Dependencies</bridgehead>
76
77 <bridgehead renderas="sect4">Required</bridgehead>
78 <para role="required"><xref linkend="linux-pam"/> or
79 <xref linkend="cracklib"/></para>
80
81 <para condition="html" role="usernotes">User Notes:
82 <ulink url="&blfs-wiki;/shadow"/></para>
83
84 </sect2>
85
86 <sect2 role="installation">
87 <title>Installation of Shadow</title>
88
89 <important>
90 <para>The installation commands shown below are for installations where
91 <application>Linux-PAM</application> has been installed (with or
92 without a <application>CrackLib</application> installation) and
93 <application>Shadow</application> is being reinstalled to support the
94 <application>Linux-PAM</application> installation.</para>
95
96 <para> If you are reinstalling <application>Shadow</application> to
97 provide strong password support using the
98 <application>CrackLib</application> library without using
99 <application>Linux-PAM</application>, ensure you add the
100 <parameter>--with-libcrack</parameter> parameter to the
101 <command>configure</command> script below and also issue the following
102 command:</para>
103
104<screen><userinput>sed -i 's@DICTPATH.*@DICTPATH\t/lib/cracklib/pw_dict@' etc/login.defs</userinput></screen>
105 </important>
106
107 <para>Reinstall <application>Shadow</application> by running the following
108 commands:</para>
109
110<screen><userinput>sed -i 's/groups$(EXEEXT) //' src/Makefile.in &amp;&amp;
111find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \; &amp;&amp;
112sed -i -e 's/ ko//' -e 's/ zh_CN zh_TW//' man/Makefile.in &amp;&amp;
113
114sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' \
115 -e 's@/var/spool/mail@/var/mail@' etc/login.defs &amp;&amp;
116
117sed -i -e 's@PATH=/sbin:/bin:/usr/sbin:/usr/bin@&amp;:/usr/local/sbin:/usr/local/bin@' \
118 -e 's@PATH=/bin:/usr/bin@&amp;:/usr/local/bin@' etc/login.defs &amp;&amp;
119
120patch -Np1 -i ../shadow-&shadow-version;-nscd-1.patch &amp;&amp;
121
122./configure --prefix=/usr --sysconfdir=/etc \
123 --without-acl --without-attr &amp;&amp;
124make</userinput></screen>
125
126 <para>This package does not come with a test suite.</para>
127
128 <para>Now, as the <systemitem class="username">root</systemitem> user:</para>
129
130<screen role="root"><userinput>make install &amp;&amp;
131mv -v /usr/bin/passwd /bin</userinput></screen>
132
133 </sect2>
134
135 <sect2 role="commands">
136 <title>Command Explanations</title>
137
138 <para><command>sed -i 's/groups$(EXEEXT) //' src/Makefile.in</command>:
139 This command is used to suppress the installation of the
140 <command>groups</command> program as the version from the
141 <application>Coreutils</application> package installed during LFS is
142 preferred.</para>
143
144 <para><command>find man -name Makefile.in -exec ... {} \;</command>: This
145 command is used to suppress the installation of the
146 <command>groups</command> man pages so the existing ones installed from
147 the <application>Coreutils</application> package are not replaced.</para>
148
149 <para><command>sed -i -e '...' -e '...' man/Makefile.in</command>: This
150 command disables the installation of Chinese and Korean manual pages, since
151 <application>Man-DB</application> cannot format them properly.</para>
152
153 <para><command>sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@'
154 -e 's@/var/spool/mail@/var/mail@' etc/login.defs</command>:
155 Instead of using the default 'DES' method, this command modifies the
156 installation to use the more secure 'SHA512' method of hashing passwords,
157 which also allows passwords longer than eight characters. It also changes
158 the obsolete <filename class="directory">/var/spool/mail</filename>
159 location for user mailboxes that <application>Shadow</application> uses by
160 default to the <filename class="directory">/var/mail</filename>
161 location.</para>
162
163 <para><command>sed -i -e
164 's@PATH=/sbin:/bin:/usr/sbin:/usr/bin@&amp;:/usr/local/sbin:/usr/local/bin@'
165 -e 's@PATH=/bin:/usr/bin@&amp;:/usr/local/bin@' etc/login.defs</command>:
166 This sed expands PATH to <filename class="directory">/usr/local/bin</filename>
167 for normal and <systemitem class="username">root</systemitem> user and to
168 <filename class="directory">/usr/local/sbin</filename> for
169 <systemitem class="username">root</systemitem> user only.</para>
170
171 <para><command>--without-acl</command>: Disables linking with <xref linkend="acl"/>
172 since <application>Shadow</application> fails to compile if it is present.</para>
173
174 <para><command>--without-attr</command>: Disables linking with <xref linkend="attr"/>
175 since <application>Shadow</application> fails to compile if it is present.</para>
176
177 <para><command>mv -v /usr/bin/passwd /bin</command>: The
178 <command>passwd</command> program may be needed during times when the
179 <filename class='directory'>/usr</filename> filesystem is not mounted so
180 it is moved into the root partition.</para>
181
182 </sect2>
183
184 <sect2 role="configuration">
185 <title>Configuring Shadow</title>
186
187 <para><application>Shadow</application>'s stock configuration for the
188 <command>useradd</command> utility may not be desirable for your
189 installation. One default parameter causes <command>useradd</command> to
190 create a mailbox file for any newly created user.
191 <command>useradd</command> will make the group ownership of this file to
192 the <systemitem class="groupname">mail</systemitem> group with 0660
193 permissions. If you would prefer that these mailbox files are not created
194 by <command>useradd</command>, issue the
195 following command as the <systemitem class="username">root</systemitem> user:</para>
196
197<screen role="root"><userinput>sed -i 's/yes/no/' /etc/default/useradd</userinput></screen>
198
199 </sect2>
200
201 <sect2 role="configuration">
202 <title>Configuring Linux-PAM to Work with Shadow</title>
203
204 <note>
205 <para>The rest of this page is devoted to configuring
206 <application>Shadow</application> to work properly with
207 <application>Linux-PAM</application>. If you do not have
208 <application>Linux-PAM</application> installed, and you reinstalled
209 <application>Shadow</application> to support strong passwords via
210 the <application>CrackLib</application> library, no further configuration
211 is required.</para>
212 </note>
213
214 <sect3 id="pam.d">
215 <title>Config Files</title>
216
217 <para><filename>/etc/pam.d/*</filename> or alternatively
218 <filename>/etc/pam.conf, /etc/login.defs, and
219 /etc/security/*</filename></para>
220
221 <indexterm zone="shadow pam.d">
222 <primary sortas="e-etc-pam.d">/etc/pam.d/*</primary>
223 </indexterm>
224
225 <indexterm zone="shadow pam.d">
226 <primary sortas="e-etc-pam.conf">/etc/pam.conf</primary>
227 </indexterm>
228
229 <indexterm zone="shadow pam.d">
230 <primary sortas="e-etc-login.defs">/etc/login.defs</primary>
231 </indexterm>
232
233 <indexterm zone="shadow pam.d">
234 <primary sortas="e-etc-security">/etc/security/*</primary>
235 </indexterm>
236
237 </sect3>
238
239 <sect3>
240 <title>Configuration Information</title>
241
242 <para>Configuring your system to use <application>Linux-PAM</application>
243 can be a complex task. The information below will provide a basic setup
244 so that <application>Shadow</application>'s login and password
245 functionality will work effectively with
246 <application>Linux-PAM</application>. Review the information and links on
247 the <xref linkend="linux-pam"/> page for further configuration
248 information. For information specific to integrating
249 <application>Shadow</application>, <application>Linux-PAM</application>
250 and <application>CrackLib</application>, you can visit the following
251 link:</para>
252
253 <itemizedlist spacing="compact">
254 <listitem>
255 <para><ulink
256 url="http://www.deer-run.com/~hal/sysadmin/pam_cracklib.html"/></para>
257 </listitem>
258 </itemizedlist>
259
260 <sect4 id="pam-login-defs">
261 <title>Configuring /etc/login.defs</title>
262
263 <para>The <command>login</command> program currently performs many
264 functions which <application>Linux-PAM</application> modules should
265 now handle. The following <command>sed</command> command will comment
266 out the appropriate lines in <filename>/etc/login.defs</filename>, and
267 stop <command>login</command> from performing these functions (a backup
268 file named <filename>/etc/login.defs.orig</filename> is also created
269 to preserve the original file's contents). Issue the following commands
270 as the <systemitem class="username">root</systemitem> user:</para>
271
272 <indexterm zone="shadow pam-login-defs">
273 <primary sortas="e-etc-login.defs">/etc/login.defs</primary>
274 </indexterm>
275
276<screen role="root"><userinput>install -v -m644 /etc/login.defs /etc/login.defs.orig &amp;&amp;
277for FUNCTION in FAIL_DELAY LASTLOG_ENAB \
278 MAIL_CHECK_ENAB \
279 OBSCURE_CHECKS_ENAB \
280 PORTTIME_CHECKS_ENAB \
281 CONSOLE MOTD_FILE \
282 NOLOGINS_FILE ENV_HZ \
283 SU_WHEEL_ONLY \
284 CRACKLIB_DICTPATH \
285 SYS_UID_MIN SYS_UID_MAX \
286 SYS_GID_MIN SYS_GID_MAX \
287 PASS_CHANGE_TRIES \
288 PASS_ALWAYS_WARN \
289 CHFN_AUTH ENVIRON_FILE
290do
291 sed -i "s/^$FUNCTION/# &amp;/" /etc/login.defs
292done</userinput></screen>
293
294 </sect4>
295
296 <sect4>
297 <title>Configuring the /etc/pam.d/ Files</title>
298
299 <para>As mentioned previously in the
300 <application>Linux-PAM</application> instructions,
301 <application>Linux-PAM</application> has two supported methods for
302 configuration. The commands below assume that you've chosen to use
303 a directory based configuration, where each program has its own
304 configuration file. You can optionally use a single
305 <filename>/etc/pam.conf</filename> configuration file by using the
306 text from the files below, and supplying the program name as an
307 additional first field for each line.</para>
308
309 <para>As the <systemitem class="username">root</systemitem> user,
310 replace the following <application>Linux-PAM</application>
311 configuration files in the
312 <filename class="directory">/etc/pam.d/</filename> directory (or
313 add the contents to the <filename>/etc/pam.conf</filename> file) using
314 the following commands:</para>
315
316 </sect4>
317
318 <sect4>
319 <title>'system-account'</title>
320
321<screen role="root"><userinput>cat &gt; /etc/pam.d/system-account &lt;&lt; "EOF"
322<literal># Begin /etc/pam.d/system-account
323
324account required pam_unix.so
325
326# End /etc/pam.d/system-account</literal>
327EOF</userinput></screen>
328
329 </sect4>
330
331 <sect4>
332 <title>'system-auth'</title>
333
334<screen role="root"><userinput>cat &gt; /etc/pam.d/system-auth &lt;&lt; "EOF"
335<literal># Begin /etc/pam.d/system-auth
336
337auth required pam_unix.so
338
339# End /etc/pam.d/system-auth</literal>
340EOF</userinput></screen>
341
342 </sect4>
343
344 <sect4>
345 <title>'system-passwd' (with cracklib)</title>
346
347<screen role="root"><userinput>cat &gt; /etc/pam.d/system-password &lt;&lt; "EOF"
348<literal># Begin /etc/pam.d/system-password
349
350# check new passwords for strength (man pam_cracklib)
351password required pam_cracklib.so type=Linux retry=3 difok=5 \
352 difignore=23 minlen=9 dcredit=1 \
353 ucredit=1 lcredit=1 ocredit=1 \
354 dictpath=/lib/cracklib/pw_dict
355# use sha512 hash for encryption, use shadow, and use the
356# authentication token (chosen password) set by pam_cracklib
357# above (or any previous modules)
358password required pam_unix.so sha512 shadow use_authtok
359
360# End /etc/pam.d/system-password</literal>
361EOF</userinput></screen>
362
363 <note><para>In its default configuration, owing to credits,
364 pam_cracklib will allow multiple case passwords as short as 6
365 characters, even with the <parameter>minlen</parameter> value
366 set to 11. You should review the pam_cracklib(8) man page and
367 determine if these default values are acceptable for the security
368 of your system.</para></note>
369
370 </sect4>
371
372 <sect4>
373 <title>'system-passwd' (without cracklib)</title>
374
375<screen role="root"><userinput>cat &gt; /etc/pam.d/system-password &lt;&lt; "EOF"
376<literal># Begin /etc/pam.d/system-password
377
378# use sha512 hash for encryption, use shadow, and try to use any previously
379# defined authentication token (chosen password) set by any prior module
380password required pam_unix.so sha512 shadow try_first_pass
381
382# End /etc/pam.d/system-password</literal>
383EOF</userinput></screen>
384
385 </sect4>
386
387 <sect4>
388 <title>'system-session'</title>
389
390<screen role="root"><userinput>cat &gt; /etc/pam.d/system-session &lt;&lt; "EOF"
391<literal># Begin /etc/pam.d/system-session
392
393session required pam_unix.so
394
395# End /etc/pam.d/system-session</literal>
396EOF</userinput></screen>
397
398 </sect4>
399
400 <sect4>
401 <title>'login'</title>
402
403<screen role="root"><userinput>cat &gt; /etc/pam.d/login &lt;&lt; "EOF"
404<literal># Begin /etc/pam.d/login
405
406# Set failure delay before next prompt to 3 seconds
407auth optional pam_faildelay.so delay=3000000
408
409# Check to make sure that the user is allowed to login
410auth requisite pam_nologin.so
411
412# Check to make sure that root is allowed to login
413# Disabled by default. You will need to create /etc/securetty
414# file for this module to function. See man 5 securetty.
415#auth required pam_securetty.so
416
417# Additional group memberships - disabled by default
418#auth optional pam_group.so
419
420# include the default auth settings
421auth include system-auth
422
423# check access for the user
424account required pam_access.so
425
426# include the default account settings
427account include system-account
428
429# Set default environment variables for the user
430session required pam_env.so
431
432# Set resource limits for the user
433session required pam_limits.so
434
435# Display date of last login - Disabled by default
436#session optional pam_lastlog.so
437
438# Display the message of the day - Disabled by default
439#session optional pam_motd.so
440
441# Check user's mail - Disabled by default
442#session optional pam_mail.so standard quiet
443
444# include the default session and password settings
445session include system-session
446password include system-password
447
448# End /etc/pam.d/login</literal>
449EOF</userinput></screen>
450
451 </sect4>
452
453 <sect4>
454 <title>'passwd'</title>
455
456<screen role="root"><userinput>cat &gt; /etc/pam.d/passwd &lt;&lt; "EOF"
457<literal># Begin /etc/pam.d/passwd
458
459password include system-password
460
461# End /etc/pam.d/passwd</literal>
462EOF</userinput></screen>
463
464 </sect4>
465
466 <sect4>
467 <title>'su'</title>
468
469<screen role="root"><userinput>cat &gt; /etc/pam.d/su &lt;&lt; "EOF"
470<literal># Begin /etc/pam.d/su
471
472# always allow root
473auth sufficient pam_rootok.so
474auth include system-auth
475
476# include the default account settings
477account include system-account
478
479# Set default environment variables for the service user
480session required pam_env.so
481
482# include system session defaults
483session include system-session
484
485# End /etc/pam.d/su</literal>
486EOF</userinput></screen>
487
488 </sect4>
489
490 <sect4>
491 <title>'chage'</title>
492
493<screen role="root"><userinput>cat &gt; /etc/pam.d/chage &lt;&lt; "EOF"
494<literal>#Begin /etc/pam.d/chage
495
496# always allow root
497auth sufficient pam_rootok.so
498
499# include system defaults for auth account and session
500auth include system-auth
501account include system-account
502session include system-session
503
504# Always permit for authentication updates
505password required pam_permit.so
506
507# End /etc/pam.d/chage</literal>
508EOF</userinput></screen>
509
510 </sect4>
511
512 <sect4>
513 <title>'chfn', 'chgpasswd', 'chgpasswd', 'chsh', 'groupadd',
514 'groupdel', 'groupmems', 'groupmod', 'newusers', 'useradd', 'userdel'
515 and 'usermod'</title>
516
517<screen role="root"><userinput>for PROGRAM in chfn chgpasswd chpasswd chsh groupadd groupdel \
518 groupmems groupmod newusers useradd userdel usermod
519do
520 install -v -m644 /etc/pam.d/chage /etc/pam.d/$PROGRAM
521 sed -i "s/chage/$PROGRAM/" /etc/pam.d/$PROGRAM
522done</userinput></screen>
523
524 <warning>
525 <para>At this point, you should do a simple test to see if
526 <application>Shadow</application> is working as expected. Open
527 another terminal and log in as a user, then <command>su</command> to
528 <systemitem class="username">root</systemitem>. If you do not see any
529 errors, then all is well and you should proceed with the rest of the
530 configuration. If you did receive errors, stop now and double check
531 the above configuration files manually. You can also run the test
532 suite from the <application>Linux-PAM</application> package to assist
533 you in determining the problem. If you cannot find and
534 fix the error, you should recompile <application>Shadow</application>
535 adding the <option>--without-libpam</option> switch to the
536 <command>configure</command> command in the above instructions
537 (also move the <filename>/etc/login.defs.orig</filename> backup
538 file to <filename>/etc/login.defs</filename>). If you
539 fail to do this and the errors remain, you will be unable to log into
540 your system.</para>
541 </warning>
542
543 </sect4>
544
545 <sect4>
546 <title>Other</title>
547
548 <para>Currently, <filename>/etc/pam.d/other</filename> is configured
549 to allow anyone with an account on the machine to use PAM-aware
550 programs without a configuration file for that program. After testing
551 <application>Linux-PAM</application> for proper configuration, install
552 a more restrictive <filename>other</filename> file so that
553 program-specific configuration files are required:</para>
554
555<screen role="root"><userinput>cat &gt; /etc/pam.d/other &lt;&lt; "EOF"
556<literal># Begin /etc/pam.d/other
557
558auth required pam_warn.so
559auth required pam_deny.so
560account required pam_warn.so
561account required pam_deny.so
562password required pam_warn.so
563password required pam_deny.so
564session required pam_warn.so
565session required pam_deny.so
566
567# End /etc/pam.d/other</literal>
568EOF</userinput></screen>
569
570 </sect4>
571
572 <sect4 id="pam-access">
573 <title>Configuring Login Access</title>
574
575 <para>Instead of using the <filename>/etc/login.access</filename>
576 file for controlling access to the system,
577 <application>Linux-PAM</application> uses the
578 <filename class='libraryfile'>pam_access.so</filename> module along
579 with the <filename>/etc/security/access.conf</filename> file. Rename
580 the <filename>/etc/login.access</filename> file using the following
581 command:</para>
582
583 <indexterm zone="shadow pam-access">
584 <primary sortas="e-etc-security-access.conf">/etc/security/access.conf</primary>
585 </indexterm>
586
587<screen role="root"><userinput>if [ -f /etc/login.access ]; then
588 mv -v /etc/login.access /etc/login.access.NOUSE
589fi</userinput></screen>
590
591 </sect4>
592
593 <sect4 id="pam-limits">
594 <title>Configuring Resource Limits</title>
595
596 <para>Instead of using the <filename>/etc/limits</filename> file
597 for limiting usage of system resources,
598 <application>Linux-PAM</application> uses the
599 <filename class='libraryfile'>pam_limits.so</filename> module along
600 with the <filename>/etc/security/limits.conf</filename> file. Rename
601 the <filename>/etc/limits</filename> file using the following
602 command:</para>
603
604 <indexterm zone="shadow pam-limits">
605 <primary sortas="e-etc-security-limits.conf">/etc/security/limits.conf</primary>
606 </indexterm>
607
608<screen role="root"><userinput>if [ -f /etc/limits ]; then
609 mv -v /etc/limits /etc/limits.NOUSE
610fi</userinput></screen>
611
612 </sect4>
613
614 </sect3>
615
616 </sect2>
617
618 <sect2 role="content">
619 <title>Contents</title>
620
621 <para>A list of the installed files, along with their short descriptions
622 can be found at
623 <ulink url="&lfs-root;/chapter06/shadow.html#contents-shadow"/>.</para>
624
625 </sect2>
626
627</sect1>
Note: See TracBrowser for help on using the repository browser.