old-www/LDP/www.debian.org/doc/manuals/debian-reference/ch04.en.html

1239 lines
61 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Chapter 4. Authentication</title>
<link rel="stylesheet" href="debian-reference.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.en.html" title="Debian Reference">
<link rel="up" href="index.en.html" title="Debian Reference">
<link rel="prev" href="ch03.en.html" title="Chapter 3. The system initialization">
<link rel="next" href="ch05.en.html" title="Chapter 5. Network setup">
<link rel="preface" href="pr01.en.html" title="Preface">
<link rel="chapter" href="ch01.en.html" title="Chapter 1. GNU/Linux tutorials">
<link rel="chapter" href="ch02.en.html" title="Chapter 2. Debian package management">
<link rel="chapter" href="ch03.en.html" title="Chapter 3. The system initialization">
<link rel="chapter" href="ch04.en.html" title="Chapter 4. Authentication">
<link rel="chapter" href="ch05.en.html" title="Chapter 5. Network setup">
<link rel="chapter" href="ch06.en.html" title="Chapter 6. Network applications">
<link rel="chapter" href="ch07.en.html" title="Chapter 7. The X Window System">
<link rel="chapter" href="ch08.en.html" title="Chapter 8. I18N and L10N">
<link rel="chapter" href="ch09.en.html" title="Chapter 9. System tips">
<link rel="chapter" href="ch10.en.html" title="Chapter 10. Data management">
<link rel="chapter" href="ch11.en.html" title="Chapter 11. Data conversion">
<link rel="chapter" href="ch12.en.html" title="Chapter 12. Programming">
<link rel="appendix" href="apa.en.html" title="Appendix A. Appendix">
<link rel="section" href="ch04.en.html#_normal_unix_authentication" title="4.1. Normal Unix authentication">
<link rel="section" href="ch04.en.html#_managing_account_and_password_information" title="4.2. Managing account and password information">
<link rel="section" href="ch04.en.html#_good_password" title="4.3. Good password">
<link rel="section" href="ch04.en.html#_creating_encrypted_password" title="4.4. Creating encrypted password">
<link rel="section" href="ch04.en.html#_pam_and_nss" title="4.5. PAM and NSS">
<link rel="section" href="ch04.en.html#_other_access_controls" title="4.6. Other access controls">
<link rel="section" href="ch04.en.html#_security_of_authentication" title="4.7. Security of authentication">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<div class="navheader">
<table width="100%" summary="Navigation header">
<tr><th colspan="3" align="center">Chapter 4. Authentication</th></tr>
<tr>
<td width="20%" align="left">
<a accesskey="p" href="ch03.en.html"><img src="images/prev.gif" alt="Prev"></a> </td>
<th width="60%" align="center"> </th>
<td width="20%" align="right"> <a accesskey="n" href="ch05.en.html"><img src="images/next.gif" alt="Next"></a>
</td>
</tr>
</table>
<hr>
</div>
<div class="chapter">
<div class="titlepage"><div><div><h2 class="title">
<a name="_authentication"></a>Chapter 4. Authentication</h2></div></div></div>
<div class="toc">
<p><b>Table of Contents</b></p>
<dl>
<dt><span class="section"><a href="ch04.en.html#_normal_unix_authentication">4.1. Normal Unix authentication</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_managing_account_and_password_information">4.2. Managing account and password information</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_good_password">4.3. Good password</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_creating_encrypted_password">4.4. Creating encrypted password</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_pam_and_nss">4.5. PAM and NSS</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch04.en.html#_configuration_files_accessed_by_the_pam_and_nss">4.5.1. Configuration files accessed by the PAM and NSS</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_the_modern_centralized_system_management">4.5.2. The modern centralized system management</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_why_gnu_su_does_not_support_the_wheel_group">4.5.3. "Why GNU su does not support the wheel group"</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_stricter_password_rule">4.5.4. Stricter password rule</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="ch04.en.html#_other_access_controls">4.6. Other access controls</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch04.en.html#_sudo">4.6.1. sudo</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_policykit">4.6.2. PolicyKit</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_selinux">4.6.3. SELinux</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_restricting_access_to_some_server_services">4.6.4. Restricting access to some server services</a></span></dt>
</dl></dd>
<dt><span class="section"><a href="ch04.en.html#_security_of_authentication">4.7. Security of authentication</a></span></dt>
<dd><dl>
<dt><span class="section"><a href="ch04.en.html#_secure_password_over_the_internet">4.7.1. Secure password over the Internet</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_secure_shell">4.7.2. Secure Shell</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_extra_security_measures_for_the_internet">4.7.3. Extra security measures for the Internet</a></span></dt>
<dt><span class="section"><a href="ch04.en.html#_securing_the_root_password">4.7.4. Securing the root password</a></span></dt>
</dl></dd>
</dl>
</div>
<p>When a person (or a program) requests access to the system, authentication confirms the identity to be a trusted one.</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>Configuration errors of PAM may lock you out of your own system. You must have a rescue CD handy or setup an alternative boot partition. To recover, boot the system with them and correct things from there.</p></td></tr>
</table></div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_normal_unix_authentication"></a>4.1. Normal Unix authentication</h2></div></div></div>
<p>Normal Unix authentication is provided by the <span class="citerefentry"><span class="refentrytitle">pam_unix</span>(8)</span> module under the <a class="ulink" href="http://en.wikipedia.org/wiki/Pluggable_Authentication_Modules" target="_top">PAM (Pluggable Authentication Modules)</a>. Its 3 important configuration files, with "<code class="literal">:</code>" separated entries, are the following.</p>
<div class="table">
<a name="dimportantconfigilesforpam_unixi"></a><p class="title"><b>Table 4.1. 3 important configuration files for <span class="citerefentry"><span class="refentrytitle">pam_unix</span>(8)</span></b></p>
<div class="table-contents"><table summary="3 important configuration files for pam_unix8" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
file
</th>
<th align="left">
permission
</th>
<th align="left">
user
</th>
<th align="left">
group
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<code class="literal">/etc/passwd</code>
</td>
<td align="left">
<code class="literal">-rw-r--r--</code>
</td>
<td align="left">
<code class="literal">root</code>
</td>
<td align="left">
<code class="literal">root</code>
</td>
<td align="left">
(sanitized) user account information
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/shadow</code>
</td>
<td align="left">
<code class="literal">-rw-r-----</code>
</td>
<td align="left">
<code class="literal">root</code>
</td>
<td align="left">
<code class="literal">shadow</code>
</td>
<td align="left">
secure user account information
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/group</code>
</td>
<td align="left">
<code class="literal">-rw-r--r--</code>
</td>
<td align="left">
<code class="literal">root</code>
</td>
<td align="left">
<code class="literal">root</code>
</td>
<td align="left">
group information
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>"<code class="literal">/etc/passwd</code>" contains the following.</p>
<pre class="screen"> ...
user1:x:1000:1000:User1 Name,,,:/home/user1:/bin/bash
user2:x:1001:1001:User2 Name,,,:/home/user2:/bin/bash
...</pre>
<p>As explained in <span class="citerefentry"><span class="refentrytitle">passwd</span>(5)</span>, each "<code class="literal">:</code>" separated entry of this file means the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Login name
</p></li>
<li class="listitem"><p>
Password specification entry
</p></li>
<li class="listitem"><p>
Numerical user ID
</p></li>
<li class="listitem"><p>
Numerical group ID
</p></li>
<li class="listitem"><p>
User name or comment field
</p></li>
<li class="listitem"><p>
User home directory
</p></li>
<li class="listitem"><p>
Optional user command interpreter
</p></li>
</ul></div>
<p>The second entry of "<code class="literal">/etc/passwd</code>" was used for the encrypted password entry. After the introduction of "<code class="literal">/etc/shadow</code>", this entry is used for the password specification entry.</p>
<div class="table">
<a name="thesecondentrycontentofetcpasswd"></a><p class="title"><b>Table 4.2. The second entry content of "<code class="literal">/etc/passwd</code>"</b></p>
<div class="table-contents"><table summary='The second entry content of "/etc/passwd"' border="1">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
content
</th>
<th align="left">
meaning
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
(empty)
</td>
<td align="left">
passwordless account
</td>
</tr>
<tr>
<td align="left">
x
</td>
<td align="left">
the encrypted password is in "<code class="literal">/etc/shadow</code>"
</td>
</tr>
<tr>
<td align="left">
*
</td>
<td align="left">
no login for this account
</td>
</tr>
<tr>
<td align="left">
!
</td>
<td align="left">
no login for this account
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>"<code class="literal">/etc/shadow</code>" contains the following.</p>
<pre class="screen"> ...
user1:$1$Xop0FYH9$IfxyQwBe9b8tiyIkt2P4F/:13262:0:99999:7:::
user2:$1$vXGZLVbS$ElyErNf/agUDsm1DehJMS/:13261:0:99999:7:::
...</pre>
<p>As explained in <span class="citerefentry"><span class="refentrytitle">shadow</span>(5)</span>, each "<code class="literal">:</code>" separated entry of this file means the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Login name
</p></li>
<li class="listitem"><p>
Encrypted password (The initial "<code class="literal">$1$</code>" indicates use of the MD5 encryption. The "*" indicates no login.)
</p></li>
<li class="listitem"><p>
Days since Jan 1, 1970 that password was last changed
</p></li>
<li class="listitem"><p>
Days before password may be changed
</p></li>
<li class="listitem"><p>
Days after which password must be changed
</p></li>
<li class="listitem"><p>
Days before password is to expire that user is warned
</p></li>
<li class="listitem"><p>
</p></li>
</ul></div>
<p>"<code class="literal">/etc/group</code>" contains the following.</p>
<pre class="screen">group1:x:20:user1,user2</pre>
<p>As explained in <span class="citerefentry"><span class="refentrytitle">group</span>(5)</span>, each "<code class="literal">:</code>" separated entry of this file means the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Group name
</p></li>
<li class="listitem"><p>
Encrypted password (not really used)
</p></li>
<li class="listitem"><p>
Numerical group ID
</p></li>
<li class="listitem"><p>
"," separated list of user names
</p></li>
</ul></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>"<code class="literal">/etc/gshadow</code>" provides the similar function as "<code class="literal">/etc/shadow</code>" for "<code class="literal">/etc/group</code>" but is not really used.</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>The actual group membership of a user may be dynamically added if "<code class="literal">auth optional pam_group.so</code>" line is added to "<code class="literal">/etc/pam.d/common-auth</code>" and set it in "<code class="literal">/etc/security/group.conf</code>". See <span class="citerefentry"><span class="refentrytitle">pam_group</span>(8)</span>.</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>The <code class="literal">base-passwd</code> package contains an authoritative list of the user and the group: "<code class="literal">/usr/share/doc/base-passwd/users-and-groups.html</code>".</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_managing_account_and_password_information"></a>4.2. Managing account and password information</h2></div></div></div>
<p>Here are few notable commands to manage account information.</p>
<div class="table">
<a name="listofcommandstocountinformation"></a><p class="title"><b>Table 4.3. List of commands to manage account information</b></p>
<div class="table-contents"><table summary="List of commands to manage account information" border="1">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
command
</th>
<th align="left">
function
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<code class="literal">getent passwd &lt;user_name&gt;</code>
</td>
<td align="left">
browse account information of "<code class="literal">&lt;user_name&gt;</code>"
</td>
</tr>
<tr>
<td align="left">
<code class="literal">getent shadow &lt;user_name&gt;</code>
</td>
<td align="left">
browse shadowed account information of "<code class="literal">&lt;user_name&gt;</code>"
</td>
</tr>
<tr>
<td align="left">
<code class="literal">getent group &lt;group_name&gt;</code>
</td>
<td align="left">
browse group information of "<code class="literal">&lt;group_name&gt;</code>"
</td>
</tr>
<tr>
<td align="left">
<code class="literal">passwd</code>
</td>
<td align="left">
manage password for the account
</td>
</tr>
<tr>
<td align="left">
<code class="literal">passwd -e</code>
</td>
<td align="left">
set one-time password for the account activation
</td>
</tr>
<tr>
<td align="left">
<code class="literal">chage</code>
</td>
<td align="left">
manage password aging information
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>You may need to have the root privilege for some functions to work. See <span class="citerefentry"><span class="refentrytitle">crypt</span>(3)</span> for the password and data encryption.</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>On the system set up with PAM and NSS as the Debian <a class="ulink" href="http://alioth.debian.org" target="_top">alioth</a> machine, the content of local "<code class="literal">/etc/passwd</code>", "<code class="literal">/etc/group</code>" and "<code class="literal">/etc/shadow</code>" may not be actively used by the system. Above commands are valid even under such environment.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_good_password"></a>4.3. Good password</h2></div></div></div>
<p>When creating an account during your system installation or with the <span class="citerefentry"><span class="refentrytitle">passwd</span>(1)</span> command, you should choose a <a class="ulink" href="http://en.wikipedia.org/wiki/Password_strength" target="_top">good password</a> which consists of 6 to 8 characters including one or more characters from each of the following sets according to <span class="citerefentry"><span class="refentrytitle">passwd</span>(1)</span>.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Lower case alphabetics
</p></li>
<li class="listitem"><p>
Digits 0 through 9
</p></li>
<li class="listitem"><p>
Punctuation marks
</p></li>
</ul></div>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Warning">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td>
<th align="left">Warning</th>
</tr>
<tr><td align="left" valign="top"><p>Do not chose guessable words for the password.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_creating_encrypted_password"></a>4.4. Creating encrypted password</h2></div></div></div>
<p>There are independent tools to generate encrypted password with salt.</p>
<div class="table">
<a name="listoftoolstogeneratepassword"></a><p class="title"><b>Table 4.4. List of tools to generate password</b></p>
<div class="table-contents"><table summary="List of tools to generate password" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
command
</th>
<th align="left">
function
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/whois" target="_top">
<code class="literal">whois</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=whois" target="_top">http://qa.debian.org/popcon.php?package=whois</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/w/whois.html" target="_top">320</a></td>
<td align="left">
<code class="literal">mkpasswd</code>
</td>
<td align="left">
over-featured front end to the <span class="citerefentry"><span class="refentrytitle">crypt</span>(3)</span> library
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/openssl" target="_top">
<code class="literal">openssl</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=openssl" target="_top">http://qa.debian.org/popcon.php?package=openssl</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/o/openssl.html" target="_top">1079</a></td>
<td align="left">
<code class="literal">openssl passwd</code>
</td>
<td align="left">
compute password hashes (OpenSSL). <span class="citerefentry"><span class="refentrytitle">passwd</span>(1ssl)</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_pam_and_nss"></a>4.5. PAM and NSS</h2></div></div></div>
<p>Modern <a class="ulink" href="http://en.wikipedia.org/wiki/Unix-like" target="_top">Unix-like</a> systems such as the Debian system provide <a class="ulink" href="http://en.wikipedia.org/wiki/Pluggable_Authentication_Modules" target="_top">PAM (Pluggable Authentication Modules)</a> and <a class="ulink" href="http://en.wikipedia.org/wiki/Name_Service_Switch" target="_top">NSS (Name Service Switch)</a> mechanism to the local system administrator to configure his system. The role of these can be summarizes as the following.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
PAM offers a flexible authentication mechanism used by the application software thus involves password data exchange.
</p></li>
<li class="listitem"><p>
NSS offers a flexible name service mechanism which is frequently used by the <a class="ulink" href="http://en.wikipedia.org/wiki/C_standard_library" target="_top">C standard library</a> to obtain the user and group name for programs such as <span class="citerefentry"><span class="refentrytitle">ls</span>(1)</span> and <span class="citerefentry"><span class="refentrytitle">id</span>(1)</span>.
</p></li>
</ul></div>
<p>These PAM and NSS systems need to be configured consistently.</p>
<p>The notable packages of PAM and NSS systems are the following.</p>
<div class="table">
<a name="listofnotablepamandnsssystems"></a><p class="title"><b>Table 4.5. List of notable PAM and NSS systems</b></p>
<div class="table-contents"><table summary="List of notable PAM and NSS systems" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/libpam-modules" target="_top">
<code class="literal">libpam-modules</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=libpam-modules" target="_top">http://qa.debian.org/popcon.php?package=libpam-modules</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/libp/libpam-modules.html" target="_top">813</a></td>
<td align="left">
Pluggable Authentication Modules (basic service)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/libpam-ldap" target="_top">
<code class="literal">libpam-ldap</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=libpam-ldap" target="_top">http://qa.debian.org/popcon.php?package=libpam-ldap</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/libp/libpam-ldap.html" target="_top">205</a></td>
<td align="left">
Pluggable Authentication Module allowing LDAP interfaces
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/libpam-cracklib" target="_top">
<code class="literal">libpam-cracklib</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=libpam-cracklib" target="_top">http://qa.debian.org/popcon.php?package=libpam-cracklib</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/libp/libpam-cracklib.html" target="_top">138</a></td>
<td align="left">
Pluggable Authentication Module to enable cracklib support
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/libpam-doc" target="_top">
<code class="literal">libpam-doc</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=libpam-doc" target="_top">http://qa.debian.org/popcon.php?package=libpam-doc</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/libp/libpam-doc.html" target="_top">986</a></td>
<td align="left">
Pluggable Authentication Modules (documentation in html and text)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/libc6" target="_top">
<code class="literal">libc6</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=libc6" target="_top">http://qa.debian.org/popcon.php?package=libc6</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/libc/libc6.html" target="_top">9500</a></td>
<td align="left">
GNU C Library: Shared libraries which also provides "Name Service Switch" service
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/glibc-doc" target="_top">
<code class="literal">glibc-doc</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=glibc-doc" target="_top">http://qa.debian.org/popcon.php?package=glibc-doc</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/glibc-doc.html" target="_top">1898</a></td>
<td align="left">
GNU C Library: Manpages
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/glibc-doc-reference" target="_top">
<code class="literal">glibc-doc-reference</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=glibc-doc-reference" target="_top">http://qa.debian.org/popcon.php?package=glibc-doc-reference</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/g/glibc-doc-reference.html" target="_top">11816</a></td>
<td align="left">
GNU C Library: Reference manual in info, pdf and html format (non-free)
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/libnss-mdns" target="_top">
<code class="literal">libnss-mdns</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=libnss-mdns" target="_top">http://qa.debian.org/popcon.php?package=libnss-mdns</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/libn/libnss-mdns.html" target="_top">144</a></td>
<td align="left">
NSS module for Multicast DNS name resolution
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/libnss-ldap" target="_top">
<code class="literal">libnss-ldap</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=libnss-ldap" target="_top">http://qa.debian.org/popcon.php?package=libnss-ldap</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/libn/libnss-ldap.html" target="_top">226</a></td>
<td align="left">
NSS module for using LDAP as a naming service
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/libnss-ldapd" target="_top">
<code class="literal">libnss-ldapd</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=libnss-ldapd" target="_top">http://qa.debian.org/popcon.php?package=libnss-ldapd</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/libn/libnss-ldapd.html" target="_top">155</a></td>
<td align="left">
NSS module for using LDAP as a naming service (new folk of <code class="literal">libnss-ldap</code>)
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
"The Linux-PAM System Administrators' Guide" in <code class="literal">libpam-doc</code> is essential for learning PAM configuration.
</p></li>
<li class="listitem"><p>
"System Databases and Name Service Switch" section in <code class="literal">glibc-doc-reference</code> is essential for learning NSS configuration.
</p></li>
</ul></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>You can see more extensive and current list by "<code class="literal">aptitude search 'libpam-|libnss-'</code>" command. The acronym NSS may also mean "Network Security Service" which is different from "Name Service Switch".</p></td></tr>
</table></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>PAM is the most basic way to initialize environment variables for each program with the system wide default value.</p></td></tr>
</table></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_configuration_files_accessed_by_the_pam_and_nss"></a>4.5.1. Configuration files accessed by the PAM and NSS</h3></div></div></div>
<p>Here are few notable configuration files accessed by the PAM.</p>
<div class="table">
<a name="listofconfigurataccessedbythepam"></a><p class="title"><b>Table 4.6. List of configuration files accessed by the PAM</b></p>
<div class="table-contents"><table summary="List of configuration files accessed by the PAM" border="1">
<colgroup>
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
configuration file
</th>
<th align="left">
function
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
<code class="literal">/etc/pam.d/&lt;program_name&gt;</code>
</td>
<td align="left">
set up PAM configuration for the "<code class="literal">&lt;program_name&gt;</code>" program; see <span class="citerefentry"><span class="refentrytitle">pam</span>(7)</span> and <span class="citerefentry"><span class="refentrytitle">pam.d</span>(5)</span>
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/nsswitch.conf</code>
</td>
<td align="left">
set up NSS configuration with the entry for each service. See <span class="citerefentry"><span class="refentrytitle">nsswitch.conf</span>(5)</span>
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/nologin</code>
</td>
<td align="left">
limit the user login by the <span class="citerefentry"><span class="refentrytitle">pam_nologin</span>(8)</span> module
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/securetty</code>
</td>
<td align="left">
limit the tty for the root access by the <span class="citerefentry"><span class="refentrytitle">pam_securetty</span>(8)</span> module
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/security/access.conf</code>
</td>
<td align="left">
set access limit by the <span class="citerefentry"><span class="refentrytitle">pam_access</span>(8)</span> module
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/security/group.conf</code>
</td>
<td align="left">
set group based restraint by the <span class="citerefentry"><span class="refentrytitle">pam_group</span>(8)</span> module
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/security/pam_env.conf</code>
</td>
<td align="left">
set environment variables by the <span class="citerefentry"><span class="refentrytitle">pam_env</span>(8)</span> module
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/environment</code>
</td>
<td align="left">
set additional environment variables by the <span class="citerefentry"><span class="refentrytitle">pam_env</span>(8)</span> module with the "<code class="literal">readenv=1</code>" argument
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/default/locale</code>
</td>
<td align="left">
set locale by <span class="citerefentry"><span class="refentrytitle">pam_env</span>(8)</span> module with the "<code class="literal">readenv=1 envfile=/etc/default/locale</code>" argument. (Debian)
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/security/limits.conf</code>
</td>
<td align="left">
set resource restraint (ulimit, core, …) by the <span class="citerefentry"><span class="refentrytitle">pam_linits</span>(8)</span> module
</td>
</tr>
<tr>
<td align="left">
<code class="literal">/etc/security/time.conf</code>
</td>
<td align="left">
set time restraint by the <span class="citerefentry"><span class="refentrytitle">pam_time</span>(8)</span> module
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>The limitation of the password selection is implemented by the PAM modules, <span class="citerefentry"><span class="refentrytitle">pam_unix</span>(8)</span> and <span class="citerefentry"><span class="refentrytitle">pam_cracklib</span>(8)</span>. They can be configured by their arguments.</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>PAM modules use suffix "<code class="literal">.so</code>" for their filenames.</p></td></tr>
</table></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_the_modern_centralized_system_management"></a>4.5.2. The modern centralized system management</h3></div></div></div>
<p>The modern centralized system management can be deployed using the centralized <a class="ulink" href="http://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol" target="_top">Lightweight Directory Access Protocol (LDAP)</a> server to administer many Unix-like and non-Unix-like systems on the network. The open source implementation of the Lightweight Directory Access Protocol is <a class="ulink" href="http://www.openldap.org/" target="_top">OpenLDAP Software</a>.</p>
<p>The LDAP server provides the account information through the use of PAM and NSS with <code class="literal">libpam-ldap</code> and <code class="literal">libnss-ldap</code> packages for the Debian system. Several actions are required to enable this (I have not used this setup and the following is purely secondary information. Please read this in this context.).</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
You set up a centralized LDAP server by running program such as stand-alone LDAP daemon, <span class="citerefentry"><span class="refentrytitle">slapd</span>(8)</span>.
</p></li>
<li class="listitem">
<p>
You change the PAM configuration files in the "<code class="literal">/etc/pam.d/</code>" directory to use "<code class="literal">pam_ldap.so</code>" instead of the default "<code class="literal">pam_unix.so</code>".
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p>
Debian uses "<code class="literal">/etc/pam_ldap.conf</code>" as the configuration file for <code class="literal">libpam-ldap</code> and "<code class="literal">/etc/pam_ldap.secret</code>" as the file to store the password of the root.
</p></li></ul></div>
</li>
<li class="listitem">
<p>
You change the NSS configuration in the "<code class="literal">/etc/nsswitch.conf</code>" file to use "<code class="literal">ldap</code>" instead of the default ("<code class="literal">compat</code>" or "<code class="literal">file</code>").
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="circle"><li class="listitem"><p>
Debian uses "<code class="literal">/etc/libnss-ldap.conf</code>" as the configuration file for <code class="literal">libnss-ldap</code>.
</p></li></ul></div>
</li>
<li class="listitem"><p>
You must make <code class="literal">libpam-ldap</code> to use <a class="ulink" href="http://en.wikipedia.org/wiki/Transport_Layer_Security" target="_top">SSL (or TLS)</a> connection for the security of password.
</p></li>
<li class="listitem"><p>
You may make <code class="literal">libnss-ldap</code> to use <a class="ulink" href="http://en.wikipedia.org/wiki/Transport_Layer_Security" target="_top">SSL (or TLS)</a> connection to ensure integrity of data at the cost of the LDAP network overhead.
</p></li>
<li class="listitem"><p>
You should run <span class="citerefentry"><span class="refentrytitle">nscd</span>(8)</span> locally to cache any LDAP search results in order to reduce the LDAP network traffic.
</p></li>
</ul></div>
<p>See documentations in <span class="citerefentry"><span class="refentrytitle">pam_ldap.conf</span>(5)</span> and "<code class="literal">/usr/share/doc/libpam-doc/html/</code>" offered by the <code class="literal">libpam-doc</code> package and "<code class="literal">info libc 'Name Service Switch'</code>" offered by the <code class="literal">glibc-doc</code> package.</p>
<p>Similarly, you can set up alternative centralized systems with other methods.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem">
<p>
Integration of user and group with the Windows system.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="circle">
<li class="listitem"><p>
Access <a class="ulink" href="http://en.wikipedia.org/wiki/Windows_domain" target="_top">Windows domain</a> services by the <code class="literal">winbind</code> and <code class="literal">libpam_winbind</code> packages.
</p></li>
<li class="listitem"><p>
See <span class="citerefentry"><span class="refentrytitle">winbindd</span>(8)</span> and <a class="ulink" href="http://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/integrate-ms-networks.html" target="_top">Integrating MS Windows Networks with Samba</a>.
</p></li>
</ul></div>
</li>
<li class="listitem">
<p>
Integration user and group with the legacy Unix-like system.
</p>
<div class="itemizedlist"><ul class="itemizedlist" type="circle">
<li class="listitem"><p>
Access <a class="ulink" href="http://en.wikipedia.org/wiki/Network_Information_Service" target="_top">NIS (originally called YP)</a> or <a class="ulink" href="http://en.wikipedia.org/wiki/NIS+" target="_top">NIS+</a> by the <code class="literal">nis</code> package.
</p></li>
<li class="listitem"><p>
See <a class="ulink" href="http://tldp.org/HOWTO/NIS-HOWTO/" target="_top">The Linux NIS(YP)/NYS/NIS+ HOWTO</a>.
</p></li>
</ul></div>
</li>
</ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_why_gnu_su_does_not_support_the_wheel_group"></a>4.5.3. "Why GNU su does not support the wheel group"</h3></div></div></div>
<p>This is the famous phrase at the bottom of the old "<code class="literal">info su</code>" page by Richard M. Stallman. Not to worry: the current <code class="literal">su</code> command in Debian uses PAM, so that one can restrict the ability to use <code class="literal">su</code> to the <code class="literal">root</code> group by enabling the line with "<code class="literal">pam_wheel.so</code>" in "<code class="literal">/etc/pam.d/su</code>".</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_stricter_password_rule"></a>4.5.4. Stricter password rule</h3></div></div></div>
<p>Installing the <code class="literal">libpam-cracklib</code> package enables you to force stricter password rule, for example, by having active lines in "<code class="literal">/etc/pam.d/common-password</code>" as the following.</p>
<p>For <code class="literal">squeeze</code>:</p>
<pre class="screen">password required pam_cracklib.so retry=3 minlen=9 difok=3
password [success=1 default=ignore] pam_unix.so use_authtok nullok md5
password requisite pam_deny.so
password required pam_permit.so</pre>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_other_access_controls"></a>4.6. Other access controls</h2></div></div></div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>See <a class="xref" href="ch09.en.html#_alt_sysrq_key" title="9.5.15. Alt-SysRq key">Section 9.5.15, “Alt-SysRq key”</a> for restricting the kernel <a class="ulink" href="http://en.wikipedia.org/wiki/Secure_attention_key" target="_top">secure attention key (SAK)</a> feature.</p></td></tr>
</table></div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_sudo"></a>4.6.1. sudo</h3></div></div></div>
<p><span class="citerefentry"><span class="refentrytitle">sudo</span>(8)</span> is a program designed to allow a sysadmin to give limited root privileges to users and log root activity. <code class="literal">sudo</code> requires only an ordinary user's password. Install <code class="literal">sudo</code> package and activate it by setting options in "<code class="literal">/etc/sudoers</code>". See configuration example at "<code class="literal">/usr/share/doc/sudo/examples/sudoers</code>" and <a class="xref" href="ch01.en.html#_sudo_configuration" title="1.1.12. sudo configuration">Section 1.1.12, “sudo configuration”</a>.</p>
<p>My usage of <code class="literal">sudo</code> for the single user system (see <a class="xref" href="ch01.en.html#_sudo_configuration" title="1.1.12. sudo configuration">Section 1.1.12, “sudo configuration”</a>) is aimed to protect myself from my own stupidity. Personally, I consider using <code class="literal">sudo</code> a better alternative to using the system from the root account all the time. For example, the following changes the owner of "<code class="literal">&lt;some_file&gt;</code>" to "<code class="literal">&lt;my_name&gt;</code>".</p>
<pre class="screen">$ sudo chown &lt;my_name&gt; &lt;some_file&gt;</pre>
<p>Of course if you know the root password (as self-installed Debian users do), any command can be run under root from any user's account using "<code class="literal">su -c</code>".</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_policykit"></a>4.6.2. PolicyKit</h3></div></div></div>
<p><a class="ulink" href="http://en.wikipedia.org/wiki/PolicyKit" target="_top">PolicyKit</a> is an operating system component for controlling system-wide privileges in Unix-like operating systems.</p>
<p>Newer GUI applications are not designed to run as privileged processes. They talk to privileged processes via PolicyKit to perform administrative operations.</p>
<p>PolicyKit limits such operations to user accounts belonging to the <code class="literal">sudo</code> group on Debian system.</p>
<p>See <span class="citerefentry"><span class="refentrytitle">polkit</span>(8)</span>.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_selinux"></a>4.6.3. SELinux</h3></div></div></div>
<p><a class="ulink" href="http://en.wikipedia.org/wiki/Security-Enhanced_Linux" target="_top">Security-Enhanced Linux (SELinux)</a> is a framework to tighten privilege model tighter than the ordinary Unix-like security model with the <a class="ulink" href="http://en.wikipedia.org/wiki/Mandatory_access_control" target="_top">mandatory access control (MAC)</a> policies. The root power may be restricted under some conditions.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_restricting_access_to_some_server_services"></a>4.6.4. Restricting access to some server services</h3></div></div></div>
<p>For system security, It is a good idea to disable as much server programs as possible. This becomes critical for network servers. Having unused servers, activated either directly as <a class="ulink" href="http://en.wikipedia.org/wiki/Daemon_(computer_software)" target="_top">daemon</a> or via <a class="ulink" href="http://en.wikipedia.org/wiki/Super-server" target="_top">super-server</a> program, are considered security risks.</p>
<p>Many programs, such as <span class="citerefentry"><span class="refentrytitle">sshd</span>(8)</span>, use PAM based access control. There are many ways to restrict access to some server services.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
configuration files: "<code class="literal">/etc/default/&lt;program_name&gt;</code>"
</p></li>
<li class="listitem"><p>
runlevel configuration for <a class="ulink" href="http://en.wikipedia.org/wiki/Daemon_(computer_software)" target="_top">daemon</a>
</p></li>
<li class="listitem"><p>
<a class="ulink" href="http://en.wikipedia.org/wiki/Pluggable_Authentication_Modules" target="_top">PAM (Pluggable Authentication Modules)</a>
</p></li>
<li class="listitem"><p>
"<code class="literal">/etc/inetd.conf</code>" for <a class="ulink" href="http://en.wikipedia.org/wiki/Super-server" target="_top">super-server</a>
</p></li>
<li class="listitem"><p>
"<code class="literal">/etc/hosts.deny</code>" and "<code class="literal">/etc/hosts.allow</code>" for <a class="ulink" href="http://en.wikipedia.org/wiki/TCP_Wrapper" target="_top">TCP wrapper</a>, <span class="citerefentry"><span class="refentrytitle">tcpd</span>(8)</span>
</p></li>
<li class="listitem"><p>
"<code class="literal">/etc/rpc.conf</code>" for <a class="ulink" href="http://en.wikipedia.org/wiki/Open_Network_Computing_Remote_Procedure_Call" target="_top">Sun RPC</a>
</p></li>
<li class="listitem"><p>
"<code class="literal">/etc/at.allow</code>" and "<code class="literal">/etc/at.deny</code>" for <span class="citerefentry"><span class="refentrytitle">atd</span>(8)</span>
</p></li>
<li class="listitem"><p>
"<code class="literal">/etc/cron.allow</code>" and "<code class="literal">/etc/cron.deny</code>" for <span class="citerefentry"><span class="refentrytitle">crontab</span>(1)</span>
</p></li>
<li class="listitem"><p><a class="ulink" href="http://en.wikipedia.org/wiki/Firewall" target="_top">Network firewall</a> of <a class="ulink" href="http://en.wikipedia.org/wiki/Netfilter" target="_top">netfilter</a> infrastructure
</p></li>
</ul></div>
<p>See <a class="xref" href="ch03.en.html#_the_runlevel_management_example" title="3.5.3. The runlevel management example">Section 3.5.3, “The runlevel management example”</a>, <a class="xref" href="ch03.en.html#_the_default_parameter_for_each_init_script" title="3.5.4. The default parameter for each init script">Section 3.5.4, “The default parameter for each init script”</a>, <a class="xref" href="ch04.en.html#_configuration_files_accessed_by_the_pam_and_nss" title="4.5.1. Configuration files accessed by the PAM and NSS">Section 4.5.1, “Configuration files accessed by the PAM and NSS”</a>, <a class="xref" href="ch03.en.html#_network_service_initialization" title="3.5.8. Network service initialization">Section 3.5.8, “Network service initialization”</a>, and <a class="xref" href="ch05.en.html#_netfilter_infrastructure" title="5.9. Netfilter infrastructure">Section 5.9, “Netfilter infrastructure”</a>.</p>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p><a class="ulink" href="http://en.wikipedia.org/wiki/Open_Network_Computing_Remote_Procedure_Call" target="_top">Sun RPC</a> services need to be active for <a class="ulink" href="http://en.wikipedia.org/wiki/Network_File_System_(protocol)" target="_top">NFS</a> and other RPC based programs.</p></td></tr>
</table></div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Tip">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Tip]" src="images/tip.png"></td>
<th align="left">Tip</th>
</tr>
<tr><td align="left" valign="top"><p>If you have problems with remote access in a recent Debian system, comment out offending configuration such as "ALL: PARANOID" in "<code class="literal">/etc/hosts.deny</code>" if it exists. (But you must be careful on security risks involved with this kind of action.)</p></td></tr>
</table></div>
</div>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="_security_of_authentication"></a>4.7. Security of authentication</h2></div></div></div>
<p>The information here may not be sufficient for your security needs but it should be a good start.</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_secure_password_over_the_internet"></a>4.7.1. Secure password over the Internet</h3></div></div></div>
<p>Many popular transportation layer services communicate messages including password authentication in the plain text. It is very bad idea to transmit password in the plain text over the wild Internet where it can be intercepted. You can run these services over "<a class="ulink" href="http://en.wikipedia.org/wiki/Transport_Layer_Security" target="_top">Transport Layer Security</a>" (TLS) or its predecessor, "Secure Sockets Layer" (SSL) to secure entire communication including password by the encryption.</p>
<div class="table">
<a name="listofinsecureanservicesandports"></a><p class="title"><b>Table 4.7. List of insecure and secure services and ports</b></p>
<div class="table-contents"><table summary="List of insecure and secure services and ports" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
insecure service name
</th>
<th align="left">
port
</th>
<th align="left">
secure service name
</th>
<th align="left">
port
</th>
</tr></thead>
<tbody>
<tr>
<td align="left">
www (http)
</td>
<td align="left">
80
</td>
<td align="left">
https
</td>
<td align="left">
443
</td>
</tr>
<tr>
<td align="left">
smtp (mail)
</td>
<td align="left">
25
</td>
<td align="left">
ssmtp (smtps)
</td>
<td align="left">
465
</td>
</tr>
<tr>
<td align="left">
ftp-data
</td>
<td align="left">
20
</td>
<td align="left">
ftps-data
</td>
<td align="left">
989
</td>
</tr>
<tr>
<td align="left">
ftp
</td>
<td align="left">
21
</td>
<td align="left">
ftps
</td>
<td align="left">
990
</td>
</tr>
<tr>
<td align="left">
telnet
</td>
<td align="left">
23
</td>
<td align="left">
telnets
</td>
<td align="left">
992
</td>
</tr>
<tr>
<td align="left">
imap2
</td>
<td align="left">
143
</td>
<td align="left">
imaps
</td>
<td align="left">
993
</td>
</tr>
<tr>
<td align="left">
pop3
</td>
<td align="left">
110
</td>
<td align="left">
pop3s
</td>
<td align="left">
995
</td>
</tr>
<tr>
<td align="left">
ldap
</td>
<td align="left">
389
</td>
<td align="left">
ldaps
</td>
<td align="left">
636
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break"><p>The encryption costs CPU time. As a CPU friendly alternative, you can keep communication in plain text while securing just password with the secure authentication protocol such as "Authenticated Post Office Protocol" (APOP) for POP and "Challenge-Response Authentication Mechanism MD5" (CRAM-MD5) for SMTP and IMAP. (For sending mail messages over the Internet to your mail server from your mail client, it is recently popular to use new message submission port 587 instead of traditional SMTP port 25 to avoid port 25 blocking by the network provider while authenticating yourself with CRAM-MD5.)</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_secure_shell"></a>4.7.2. Secure Shell</h3></div></div></div>
<p>The <a class="ulink" href="http://en.wikipedia.org/wiki/Secure_Shell" target="_top">Secure Shell (SSH)</a> program provides secure encrypted communications between two untrusted hosts over an insecure network with the secure authentication. It consists of the <a class="ulink" href="http://www.openssh.org/" target="_top">OpenSSH</a> client, <span class="citerefentry"><span class="refentrytitle">ssh</span>(1)</span>, and the <a class="ulink" href="http://www.openssh.org/" target="_top">OpenSSH</a> daemon, <span class="citerefentry"><span class="refentrytitle">sshd</span>(8)</span>. This SSH can be used to tunnel the insecure protocol communication such as POP and X securely over the Internet with the port forwarding feature.</p>
<p>The client tries to authenticate itself using host-based authentication, public key authentication, challenge-response authentication, or password authentication. The use of public key authentication enables the remote password-less login. See <a class="xref" href="ch06.en.html#_the_remote_access_server_and_utility_ssh" title="6.9. The remote access server and utility (SSH)">Section 6.9, “The remote access server and utility (SSH)”</a>.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_extra_security_measures_for_the_internet"></a>4.7.3. Extra security measures for the Internet</h3></div></div></div>
<p>Even when you run secure services such as <a class="ulink" href="http://en.wikipedia.org/wiki/Secure_Shell" target="_top">Secure Shell (SSH)</a> and <a class="ulink" href="http://en.wikipedia.org/wiki/Point-to-point_tunneling_protocol" target="_top">Point-to-point tunneling protocol (PPTP)</a> servers, there are still chances for the break-ins using brute force password guessing attack etc. from the Internet. Use of the firewall policy (see <a class="xref" href="ch05.en.html#_netfilter_infrastructure" title="5.9. Netfilter infrastructure">Section 5.9, “Netfilter infrastructure”</a>) together with the following secure tools may improve the security situation.</p>
<div class="table">
<a name="listoftoolstoprosecuritymeasures"></a><p class="title"><b>Table 4.8. List of tools to provide extra security measures</b></p>
<div class="table-contents"><table summary="List of tools to provide extra security measures" border="1">
<colgroup>
<col align="left">
<col align="left">
<col align="left">
<col align="left">
</colgroup>
<thead><tr>
<th align="left">
package
</th>
<th align="left">
popcon
</th>
<th align="left">
size
</th>
<th align="left">
description
</th>
</tr></thead>
<tbody>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/knockd" target="_top">
<code class="literal">knockd</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=knockd" target="_top">http://qa.debian.org/popcon.php?package=knockd</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/k/knockd.html" target="_top">164</a></td>
<td align="left">
small port-knock daemon <span class="citerefentry"><span class="refentrytitle">knockd</span>(1)</span> and client <span class="citerefentry"><span class="refentrytitle">konck</span>(1)</span>
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/denyhosts" target="_top">
<code class="literal">denyhosts</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=denyhosts" target="_top">http://qa.debian.org/popcon.php?package=denyhosts</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/d/denyhosts.html" target="_top">368</a></td>
<td align="left">
utility to help sysadmins thwart ssh hackers
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/fail2ban" target="_top">
<code class="literal">fail2ban</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=fail2ban" target="_top">http://qa.debian.org/popcon.php?package=fail2ban</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/f/fail2ban.html" target="_top">414</a></td>
<td align="left">
ban IPs that cause multiple authentication errors
</td>
</tr>
<tr>
<td align="left"><a class="ulink" href="http://packages.debian.org/sid/libpam-shield" target="_top">
<code class="literal">libpam-shield</code>
</a></td>
<td align="left"><a class="ulink" href="http://qa.debian.org/popcon.php?package=libpam-shield" target="_top">http://qa.debian.org/popcon.php?package=libpam-shield</a></td>
<td align="left"><a class="ulink" href="http://packages.qa.debian.org/libp/libpam-shield.html" target="_top">130</a></td>
<td align="left">
lock out remote attackers trying password guessing
</td>
</tr>
</tbody>
</table></div>
</div>
<br class="table-break">
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="_securing_the_root_password"></a>4.7.4. Securing the root password</h3></div></div></div>
<p>To prevent people to access your machine with root privilege, you need to make following actions.</p>
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
<li class="listitem"><p>
Prevent physical access to the hard disk
</p></li>
<li class="listitem"><p>
Lock BIOS and prevent booting from the removable media
</p></li>
<li class="listitem"><p>
Set password for GRUB interactive session
</p></li>
<li class="listitem"><p>
Lock GRUB menu from editing
</p></li>
</ul></div>
<p>With physical access to hard disk, resetting the password is relatively easy with following steps.</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><p>
Move the hard disk to a PC with CD bootable BIOS.
</p></li>
<li class="listitem"><p>
Boot system with a rescue media (Debian boot disk, Knopix CD, GRUB CD, …).
</p></li>
<li class="listitem"><p>
Mount root partition with read/write access.
</p></li>
<li class="listitem"><p>
Edit "<code class="literal">/etc/passwd</code>" in the root partition and make the second entry for the <code class="literal">root</code> account empty.
</p></li>
</ol></div>
<p>If you have the edit access to the GRUB menu entry (see <a class="xref" href="ch03.en.html#_stage_2_the_boot_loader" title="3.3. Stage 2: the boot loader">Section 3.3, “Stage 2: the boot loader”</a>) for <code class="literal">grub-rescue-pc</code> at the boot time, it is even easier with following steps.</p>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><p>
Boot system with the kernel parameter changed to something like "<code class="literal">root=/dev/hda6 rw init=/bin/sh</code>".
</p></li>
<li class="listitem"><p>
Edit "<code class="literal">/etc/passwd</code>" and make the second entry for the <code class="literal">root</code> account empty.
</p></li>
<li class="listitem"><p>
Reboot system.
</p></li>
</ol></div>
<p>The root shell of the system is now accessible without password.</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><table border="0" summary="Note">
<tr>
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
<th align="left">Note</th>
</tr>
<tr><td align="left" valign="top"><p>Once one has root shell access, he can access everything on the system and reset any passwords on the system. Further more, he may compromise password for all user accounts using brute force password cracking tools such as <code class="literal">john</code> and <code class="literal">crack</code> packages (see <a class="xref" href="ch09.en.html#_system_security_and_integrity_check" title="9.6.11. System security and integrity check">Section 9.6.11, “System security and integrity check”</a>). This cracked password may lead to compromise other systems.</p></td></tr>
</table></div>
<p>The only reasonable software solution to avoid all these concerns is to use software encrypted root partition (or "<code class="literal">/etc</code>" partition) using <a class="ulink" href="http://en.wikipedia.org/wiki/Dm-crypt" target="_top">dm-crypt</a> and initramfs (see <a class="xref" href="ch09.en.html#_data_encryption_tips" title="9.4. Data encryption tips">Section 9.4, “Data encryption tips”</a>). You always need password to boot the system, though.</p>
</div>
</div>
</div>
<div class="navfooter">
<hr>
<table width="100%" summary="Navigation footer">
<tr>
<td width="40%" align="left">
<a accesskey="p" href="ch03.en.html"><img src="images/prev.gif" alt="Prev"></a> </td>
<td width="20%" align="center"> </td>
<td width="40%" align="right"> <a accesskey="n" href="ch05.en.html"><img src="images/next.gif" alt="Next"></a>
</td>
</tr>
<tr>
<td width="40%" align="left" valign="top">Chapter 3. The system initialization </td>
<td width="20%" align="center"><a accesskey="h" href="index.en.html"><img src="images/home.gif" alt="Home"></a></td>
<td width="40%" align="right" valign="top"> Chapter 5. Network setup</td>
</tr>
</table>
</div>
</body>
</html>