Debian Codegraph @

doc/howto/AuthFiles.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD: Using AuthUserFiles</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center><h2><b><i>ProFTPD: Using <code>AuthUserFile</code>s</i></b></h2></center>
11 <hr>
12
13 <p>
14 The FTP protocol is old, stemming from the days of Telnet, before security
15 came to be the relevant issue it is today. One of the protocol's biggest flaws,
16 in today's security-conscious world, is the transmission of passwords &quot;in
17 the clear&quot;, unencrypted, easily visible to network sniffers. There
18 are several ways of attempting to deal with this flaw.
19
20 <p>
21 ProFTPD allows for the definition of &quot;virtual&quot; users: users who
22 do not have accounts on the host machine, whose account information is defined
23 in other sources. The passwords for these users are then specific only to
24 FTP access, and thus do not expose shell access (<code>ssh</code>, hopefully) to
25 unauthorized users. These alternative account information sources include SQL
26 tables (via <code>mod_sql</code>), LDAP servers (via <code>mod_ldap</code>),
27 and other system files (via the
28 <a href="http://www.proftpd.org/docs/modules/mod_auth_file.html#AuthUserFile"><code>AuthUserFile</code></a> and
29 <a href="http://www.proftpd.org/docs/modules/mod_auth_file.html#AuthGroupFile"><code>AuthGroupFile</code></a>
30 configuration directives). The <code>proftpd</code> server can be configured
31 to use multiple account information sources simultaneously as well,
32 allowing for flexible support of a range of environments.
33
34 <p>
35 This document focuses on the use of the <code>AuthUserFile</code> and
36 <code>AuthGroupFile</code> directives. Several questions often arise
37 about the use of these directives. In general, the answers to those questions
38 apply to other authentication/account sources, too.
39
40 <p>
41 <b>Formats</b><br>
42 Any configured <code>AuthUserFile</code> is used <b>in addition to</b>
43 <code>/etc/passwd</code>, not <b>instead of</b> it (prior to 1.2.8rc1, however,
44 an <code>AuthUserFile</code> was used instead of <code>/etc/passwd</code>);
45 similarly for <code>AuthGroupFile</code> and <code>/etc/group</code>. The
46 <a href="Authentication.html#order"><code>AuthOrder</code></a> directive can be used if you want <code>proftpd</code> to use only the <code>AuthUserFile</code>.
47 The format of an <code>AuthUserFile</code> is the same as
48 <code>/etc/passwd</code> (<code>man passwd(5)</code>), and the format of an
49 <code>AuthGroupFile</code> is the same as <code>/etc/group</code> (<code>man
50 group(5)</code>). There is an <a href="../contrib/ftpasswd.html"><code>ftpasswd</code></a> script available that can be used to create and update
51 these files.
52
53 <p>
54 It is important to note here that not all flavors of Unix use these formats;
55 one notable exception is FreeBSD. With FreeBSD, user account information is
56 stored in binary database files as opposed to ASCII files. The C library on
57 this platform also lacks the functions necessary for making the
58 <code>AuthUserFile</code> and <code>AuthGroupFile</code> directives work
59 properly. In this case, <code>proftpd</code> uses an internal implementation
60 of the missing functions to read <code>AuthUserFile</code>s and
61 <code>AuthGroupFile</code>s. This internal implementation requires that
62 <code>AuthUserFile</code>s have the traditional <code>passwd(5)</code> format:
63 <pre>
64 username:password:uid:gid:gecos:homedir:shell
65 </pre>
66 and that <code>AuthGroupFile</code>s have this format:
67 <pre>
68 groupname:grouppasswd:gid:member1,member2,...member<i>N</i>
69 </pre>
70 The <a href="../contrib/ftpasswd.html"><code>ftpasswd</code></a> script
71 mentioned creates files in these required formats.
72
73 <p>
74 <b>Choice of IDs</b><br>
75 The choice of IDs for your users is important; the operating system does not
76 deal with user processes in terms of their user names, it knows only of the
77 numeric identity of a process. In general, it is best if each user has
78 a unique <i>positive</i> user ID (negative IDs are an ugly hack, and
79 <code>proftpd</code> will complain if they are used).
80
81 <p>
82 However, in some mass-hosting environments such as ISPs, the number of users
83 is greater than the number of IDs available. In these cases, you can give
84 each user the same ID; additional steps should then be taken to make sure
85 that each user is isolated from affecting other users' files. These additional
86 steps are to make sure each user has a unique home directory, and then
87 to restrict each user to their respective home directories by having
88 <pre>
89 DefaultRoot ~
90 </pre>
91 in your <code>proftpd.conf</code>.
92
93 <p>
94 <b>Shadow passwords</b><br>
95 There really is no need for an <code>AuthShadowFile</code> directive. The
96 purpose of a shadow file is separate sensitive information
97 (<i>e.g.</i> passwords) from other account information
98 (username/<code>UID</code>/<code>GID</code>, <i>etc</i>). Programs like
99 <code>/bin/ls</code> often reference the passwd file in order to display
100 user/group names rather than numbers; these programs do not really need that
101 sensitive information. Rather than relying on programs like
102 <code>/bin/ls</code> to ignore the sensitive information, libraries were
103 developed to split the information into <code>/etc/passwd</code>,
104 <code>/etc/shadow</code> (and similarly for <code>/etc/group</code>, but very
105 few administrators use group passwords anymore). Some operating systems, most
106 notably FreeBSD, though, chose a different form of information separation.
107 Since FreeBSD maintains account information in binary database files, the
108 shadow libraries mentioned above are not used. Instead, FreeBSD returns the
109 sensitive information to the calling program only if it has sufficient
110 (<i>i.e.</i> superuser) privileges.
111
112 <p>
113 When <code>proftpd</code> uses an <code>AuthUserFile</code>, it is looking for
114 all of the account information, including the password. And since
115 <code>AuthUserFile</code>s are specific to <code>proftpd</code>, there is no
116 need to split any passwords out of an <code>AuthUserFile</code> into an
117 <code>AuthShadowFile</code>. As the documentation states, an
118 <code>AuthUserFile</code> need not reside inside a <code>chroot()</code>
119 filesystem, which means that users can be effectively isolated from having
120 access to that <code>AuthUserFile</code>. At that point, the only
121 consideration is making sure that the permissions on the
122 <code>AuthUserFile</code> are sufficient for the server to have access, but
123 no other users.
124
125 <p>
126 <b>Permissions</b><br>
127 As the <code>AuthUserFile</code> and <code>AuthGroupFile</code> files are
128 meant to be drop-in replacements for their system cousins, there are a few
129 caveats. <code>/etc/passwd</code> and <code>/etc/group</code> are normally
130 world-readable on modern Unix systems. This allows programs like
131 <code>/bin/ls</code> to map system ID numbers to more legible names; sensitive
132 information in the <code>/etc/passwd</code> and <code>/etc/group</code>
133 is normally stored elsewhere, in restricted shadow files. The
134 <code>proftpd</code> server thus assumes that it will not need special
135 privileges to read an <code>AuthUserFile</code> or an
136 <code>AuthGroupFile</code>. The process will access any
137 <code>AuthUserFile</code>s and <code>AuthGroupFile</code>s with the credentials
138 of the user and group configured via the <code>User</code> and
139 <code>Group</code> directives. The files may contain sensitive information, so
140 they <b>should not</b> have as open of permissions as <code>/etc/passwd</code>
141 and <code>/etc/group</code>. The most paranoid setting will have
142 user-read-only permissions for those files, and have the files be owned by the
143 user configured for the relevant server via the <code>User</code> directive.
144 Hopefully the server administrator has created a new account on the system just
145 for the ftpd daemon.
146
147 <p>
148 <b>ID-to-name mapping</b><br>
149 A consequence of which to be aware when using an <code>AuthUserFile</code>
150 is the difference between that <code>AuthUserFile</code>'s mapping of
151 system IDs to names, and the mapping in <code>/etc/passwd</code>. This
152 may catch some system administrators unawares when they go to check the
153 ownership of files uploaded by some user whose account is defined in an
154 <code>AuthUserFile</code>, and find those files being reported as being
155 owned by different users and/or groups by <code>/bin/ls</code>. Keep in
156 mind that <code>/bin/ls</code> is using <code>/etc/passwd</code>, not
157 the <code>AuthUserFile</code>. This issue crops up with any alternative
158 account information source, not just <code>AuthUserFile</code>s.
159
160 <p>
161 If you are using the same UID/GID for your users, <i>e.g.</i> in a mass
162 hosting environment, one trick you might like to do is make all of the files,
163 as listed by the server, appear to be owned by the logged in user. This is
164 done using the <a href="http://www.proftpd.org/docs/modules/mod_ls.html#DirFakeUser"><code>DirFakeUser</code></a> and <a href="http://www.proftpd.org/docs/modules/mod_ls.html#DirFakeGroup"><code>DirFakeGroup</code></a> directives, like this:
165 <pre>
166 # make listed files appear to be owned by the logged-in user
167 DirFakeUser on ~
168 DirFakeGroup on ~
169 </pre>
170 As noted in the documentation, these directives are purely cosmetic, and in
171 no way change the real ownership of files. This may cause some confusion on
172 the client side in some cases, if the user sees a file that is reported to be
173 owned by them, and the permissions on the file show user access is allowed, and
174 yet the client is unable to access the file. <a href="http://www.proftpd.org/docs/modules/mod_core.html#HideNoAccess"><code>HideNoAccess</code></a>
175 can help in situations like this.
176
177 <p>
178 <hr>
179 <font size=2><b><i>
180 &copy; Copyright 2017-2023 The ProFTPD Project<br>
181 All Rights Reserved<br>
182 </i></b></font>
183 <hr>
184
185 </body>
186 </html>