Debian Codegraph @

doc/howto/Radius.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>ProFTPD: RADIUS</title>
5 </head>
6
7 <body bgcolor=white>
8
9 <hr>
10 <center><h2><b>ProFTPD: RADIUS</b></h2></center>
11 <hr>
12 Some sites use the <a href="http://en.wikipedia.org/wiki/RADIUS">RADIUS</a>
13 protocol for authenticating users. For these sites, there is the
14 <a href="../contrib/mod_radius.html"><code>mod_radius</code></a> ProFTPD module.
15
16 <p>
17 <b>Common Configurations</b></br>
18 First, let's start with the most basic <code>mod_radius</code> configuration,
19 where we want to use the RADIUS server <b>only</b> for validating the user's
20 password:
21 <pre>
22 &lt;IfModule mod_radius.c&gt;
23 AuthOrder mod_radius.c mod_auth_unix.c mod_auth_file.c
24
25 RadiusEngine on
26 RadiusAuthServer localhost:1812 testing123 5
27 RadiusLog /etc/proftpd/radius.log
28 &lt;/IfModule&gt;
29 </pre>
30 Here, we have told <code>mod_radius</code> the IP address of the RADIUS
31 server via the <a href="../contrib/mod_radius.html#RadiusAuthServer"><code>RadiusAuthServer</code></a> directive, which includes the port, shared secret,
32 and default timeout value (in seconds).
33
34 <p>
35 Since this configuration only uses the RADIUS server for validating the
36 password, we still need to get the user's UID, GID, home directory, group
37 membership, <i>etc</i> from somewhere. Thus we need the <code>AuthOrder</code>
38 directive to tell <code>proftpd</code> to use the
39 <a href="../modules/mod_auth_unix.html"><code>mod_auth_unix</code></a> and
40 <a href="../modules/mod_auth_file.html"><code>mod_auth_file</code></a> modules
41 as well.
42
43 <p>
44 Using the above configuration, when a client connects and sends the
45 <code>USER</code> and <code>PASS</code> FTP commands, the
46 <code>mod_radius</code> module will send an <code>Access-Request</code> RADIUS
47 packet to the RADIUS server, which will include the following attributes:
48 <pre>
49 <b>Service-Type 8</b> (<i>i.e.</i> Authenticate-Only)
50 User-Name <em>username</em>
51 User-Password <em>password</em>
52 NAS-Identifier "ftp"
53 NAS-IP-Address (<i>or</i> NAS-IPv6-Address) <em>server-ip-address</em>
54 NAS-Port <em>server-port</em>
55 NAS-Port-Type 5 (<i>i.e.</i> Virtual)
56 Calling-Station-Id <em>client-ip-address</em>
57 Acct-Session-Id <em>session-pid</em>
58 Message-Authenticator <em>mac</em>
59 </pre>
60 If the RADIUS server responds with an <code>Access-Accept</code> packet, then
61 the login succeeds, and the FTP session is establish. If, on the other hand,
62 the RADIUS server responds with <code>Access-Reject</code>, the login fails.
63 (The <code>mod_radius</code> module does not currently support the
64 <code>Access-Challenge</code> packet type.)
65
66 <p>
67 Now, let's examine a slightly more complex configuration, which enables the
68 use of RADIUS accounting:
69 <pre>
70 &lt;IfModule mod_radius.c&gt;
71 AuthOrder mod_radius.c mod_auth_unix.c mod_auth_file.c
72
73 RadiusEngine on
74 RadiusAuthServer localhost:1812 testing123 5
75 RadiusAcctServer localhost:1813 testing123 5
76 RadiusLog /etc/proftpd/radius.log
77 &lt;/IfModule&gt;
78 </pre>
79 The additional directive here is the <a href="../contrib/mod_radius.html#RadiusAcctServer"><code>RadiusAcctSerer</code></a> directive, which is quite similar
80 to the <code>RadiusAuthServer</code> directive. The use of the
81 <code>RadiusAcctServer</code> directive instructs <code>mod_radius</code> to
82 use RADIUS accounting.
83
84 <p>
85 With this configuration, <code>mod_radius</code> will do the same as before.
86 In addition, once the login has succeeded, <code>mod_radius</code> will send
87 an <code>Accounting-Request</code> packet to the RADIUS accounting server
88 which includes:
89 <pre>
90 User-Name <em>username</em>
91 <b>Acct-Status-Type 1</b> (<i>i.e.</i> Start)
92 Acct-Session-Id <em>session-pid</em>
93 Acct-Authentic 1 (<i>i.e.</i> Local)
94 Event-Timestamp <em>timestamp</em>
95 </pre>
96 Then, when the client disconnects, <code>mod_radius</code> sends another
97 <code>Accounting-Request</code> packet, this time with a lot of information
98 about the just-ended session:
99 <pre>
100 User-Name <em>username</em>
101 <b>Acct-Status-Type 2</b> (<i>i.e.</i> Stop)
102 Acct-Session-Id <em>session-pid</em>
103 Acct-Authentic 1 (<i>i.e.</i> Local)
104 Acct-Session-Time <em>session-duration</em>
105 Acct-Input-Octets <em>bytes-in</em>
106 Acct-Output-Octets <em>bytes-out</em>
107 Acct-Terminate-Cause <em>cause</em>
108 Event-Timestamp <em>timestamp</em>
109 Class <em>class</em> (if provided in <code>Access-Accept</code>)
110 </pre>
111
112 <p>
113 The above configurations are the most common, as RADIUS is normally used
114 only as way of checking whether a client should be allowed to connect, based
115 on username/password.
116
117 <p>
118 <b>Sophisticated Configurations</b></br>
119 It is possible to use RADIUS as the sole means of user authentication, rather
120 than just validating passwords. The <code>mod_radius</code> configuration
121 to do so would look like:
122 <pre>
123 &lt;IfModule mod_radius.c&gt;
124 AuthOrder mod_radius.c
125
126 RadiusEngine on
127 RadiusAuthServer localhost:1812 testing123 5
128 RadiusAcctServer localhost:1813 testing123 5
129 RadiusLog /etc/proftpd/radius.log
130
131 # Use RADIUS Vendor-Specific Attributes (VSAs) for user details
132 RadiusVendor Unix 4
133 RadiusUserInfo $(10:1000) $(11:1000) $(12:/tmp) $(13:/bin/bash)
134 RadiusGroupInfo $(14:users,ftpd) $(15:500,501)
135 &lt;/IfModule&gt;
136 </pre>
137 The key difference here is the use of the <a href="../contrib/mod_radius.html#RadiusUserInfo"><code>RadiusUserInfo</code></a> directive. Its appearance within
138 the configuration is what instructs <code>mod_radius</code> to do more than
139 just password validation. The <code>RadiusUserInfo</code> and <a href="../contrib/mod_radius.html#RadiusGroupInfo"><code>RadiusGroupInfo</code></a> directives
140 together tell <code>mod_radius</code> where to find the necessary information
141 about a user, such as the UID, GID, home directory, group membership,
142 <i>etc</i> in the response packets from the RADIUS server.
143
144 <p>
145 To let the RADIUS server know that we are expecting it do more than just
146 validate the password, the <code>Access-Request</code> packet will use a
147 different <code>Service-Type</code> attribute. Now the packet will look like:
148 <pre>
149 <b>Service-Type 1</b> (<i>i.e.</i> Login)
150 User-Name <em>username</em>
151 User-Password <em>password</em>
152 NAS-Identifier "ftp"
153 NAS-IP-Address (<i>or</i> NAS-IPv6-Address) <em>server-ip-address</em>
154 NAS-Port <em>server-port</em>
155 NAS-Port-Type 5 (<i>i.e.</i> Virtual)
156 Calling-Station-Id <em>client-ip-address</em>
157 Acct-Session-Id <em>session-pid</em>
158 Message-Authenticator <em>mac</em>
159 </pre>
160
161 <p>
162 Upon receiving the <code>Access-Accept</code> packet, <code>mod_radius</code>
163 will now look for specific <a href="http://en.wikipedia.org/wiki/RADIUS#Attribute_value_pairs">attributes</a>, bearing user details, within the packet.
164 What attributes does it look for? Answer: <a href="http://en.wikipedia.org/wiki/RADIUS#Vendor-specific_attributes">Vendor-Specific Attributes</a> (commonly
165 called "VSAs").
166
167 <p>
168 Every VSA is prefixed with a vendor ID, followed by an attribute ID/value which
169 are defined by that vendor. For example, Cisco has a vendor ID of 9,
170 Microsoft has a vendor ID of 311, and "Unix" has a vendor ID of 4. (For the
171 curious, these vendor IDs, per <a href="http://tools.ietf.org/search/rfc2865#section-5.26">RFC 2865, Section 5.26</a>, come from the <a href="http://www.iana.org/assignments/enterprise-numbers/enterprise-numbers">IANA Enterprise Numbers</a> registry.)
172
173 <p>
174 With this background, we can explain the <code>RadiusUserInfo</code> and
175 <code>RadiusGroupInfo</code> directives in detail. Notice that we tell
176 <code>mod_radius</code> the vendor ID to look for, using the
177 <a href="../contrib/mod_radius.html#RadiusVendor"><code>RadiusVendor</code></a>
178 directive:
179 <pre>
180 RadiusVendor Unix 4
181 </pre>
182 The above is actually not necessary; <code>mod_radius</code> will look for
183 VSAs for vendor ID 4 (Unix) by default. It is useful, though, to make it
184 explicitly visible in the configuration.
185
186 <p>
187 Let's now see just what the <code>RadiusUserInfo</code> parameters are doing:
188 <pre>
189 RadiusUserInfo $(10:1000) $(11:1000) $(12:/tmp) $(13:/bin/bash)
190 </pre>
191 In order for <code>proftpd</code> to log a user in, it needs to know that
192 user's UID, GID, home directory, and shell. And the <code>RadiusUserInfo</code>
193 parameters say where to find those values, in that order.
194
195 <p>
196 For UIDs, &quot;$(10:<em>1000</em>)&quot; says to look for a vendor-specific
197 attribute ID of 10. If we find such an attribute, use the attribute value as
198 the UID. Otherwise, use <em>1000</em> as the UID for the user logging in.
199
200 <p>
201 For GIDs, &quot;$(11:<em>1000</em>)&quot; says to look for a vendor-specific
202 attribute ID of 11. If we find such an attribute, use the attribute value as
203 the GID. Otherwise, use <em>1000</em> as the GID for the user logging in.
204
205 <p>
206 For home directories, &quot;$(12:<em>/tmp</em>)&quot; says to look for a
207 vendor-specific attribute ID of 12. If we find such an attribute, use the
208 attribute value as the home directory. Otherwise, use <em>/tmp</em> as the
209 home directory for the user logging in.
210
211 <p>
212 And for the shell, &quot;$(13:<em>/bin/bash</em>)&quot; says to look for a
213 vendor-specific attribute ID of 13. If we find such an attribute, use the
214 attribute value as the shell. Otherwise, use <em>/bin/bash</em> as the shell
215 for the user logging in.
216
217 <p>
218 The <code>RadiusGroupInfo</code> directive is very similar: it tells
219 <code>mod_radius</code> which VSAs will contain the group membership, both
220 in terms of group IDs and group names, for the logging in user:
221 <pre>
222 RadiusGroupInfo $(14:users,ftpd) $(15:500,501)
223 </pre>
224
225 <p>
226 For group names, &quot;$(14:<em>users,ftpd</em>)&quot; says to look for a
227 vendor-specific attribute ID of 14. If we find such an attribute, use the
228 attribute value as the comma-separated list of supplemental group names.
229 Otherwise, use <em>users,ftpd</em> as the group names for the user logging in.
230
231 <p>
232 For group IDs, &quot;$(15:<em>500,501</em>)&quot; says to look for a
233 vendor-specific attribute ID of 15. If we find such an attribute, use the
234 attribute value as the comma-separated list of supplemental group IDs.
235 Otherwise, use <em>500,501</em> as the group IDs for the user logging in.
236
237 <p>
238 <b>FreeRADIUS Configuration</b><br>
239 To help demonstrate how you would configure and use VSAs, I will show the
240 <a href="http://freeradius.org/">FreeRADIUS</a> configuration that I used for
241 development and testing.
242
243 <p>
244 Here is the FreeRADIUS <code>dictionary.unix</code> file I used (slightly
245 modified from the stock <code>dictionary.unix</code> file distributed with
246 FreeRADIUS); this file defines the attributes supported for the "Unix"
247 vendor:
248 <pre>
249 VENDOR Unix 4
250
251 BEGIN-VENDOR Unix
252
253 ATTRIBUTE Unix-User-UID 10 integer
254 ATTRIBUTE Unix-User-GID 11 integer
255 ATTRIBUTE Unix-User-Home 12 string
256 ATTRIBUTE Unix-User-Shell 13 string
257 ATTRIBUTE Unix-User-Group-Names 14 string
258 ATTRIBUTE Unix-User-Group-Ids 15 string
259
260 END-VENDOR Unix
261 </pre>
262 You can see how:
263 <pre>
264 VENDOR Unix 4
265 </pre>
266 here corresponds to the <code>mod_radius</code> configuration line:
267 <pre>
268 RadiusVendor Unix 4
269 </pre>
270
271 <p>
272 The following attribute IDs are what we use in our <code>mod_radius</code>
273 directives:
274 <pre>
275 ATTRIBUTE Unix-User-UID <b><i>10</i></b> integer
276 ATTRIBUTE Unix-User-GID <b><i>11</i></b> integer
277 ATTRIBUTE Unix-User-Home <b><i>12</i></b> string
278 ATTRIBUTE Unix-User-Shell <b><i>13</i></b> string
279 </pre>
280 which match up with our <code>RadiusUserInfo</code> parameters:
281 <pre>
282 RadiusUserInfo $(<b><i>10</i></b>:1000) $(<b><i>11</i></b>:1000) $(<b><i>12</i></b>:/tmp) $(<b><i>13</i></b>:/bin/bash)
283 </pre>
284
285 <p>
286 Similarly for the group membership attributes, <code>dictionary.unix</code>
287 has:
288 <pre>
289 ATTRIBUTE Unix-User-Group-Names <b><i>14</i></b> string
290 ATTRIBUTE Unix-User-Group-Ids <b><i>15</i></b> string
291 </pre>
292 and our <code>RadiusGroupInfo</code> parameters are:
293 <pre>
294 RadiusGroupInfo $(<b><i>14</i></b>:users,ftpd) $(<b><i>15</i></b>:500,501)
295 </pre>
296
297 <p>
298 Note that only the IDs (numbers) for attributes are used in the RADIUS packets
299 sent between clients/servers. The attribute names are to make the configuration
300 and logging more human-readable.
301
302 <p>
303 Now, in order to tell FreeRADIUS that we want it to <i>include</i> those
304 VSAs in its <code>Access-Accept</code> packet back to <code>mod_radius</code>,
305 we have to modify the FreeRADIUS <code>users</code> file, like so:
306 <pre>
307 DEFAULT Auth-Type := System
308 Unix-User-UID := 500,
309 Unix-User-GID := 500,
310 Unix-User-Home := "/home/tj",
311 Unix-User-Shell := "/bin/bash",
312 Unix-User-Group-Names := "radius,ftpd",
313 Unix-User-Group-Ids := "200,501",
314 Fall-Through = 1
315 </pre>
316 See the FreeRADIUS documentation for the <code>users</code> file format in
317 order to learn how to configure different UID/GID/home/group values for each
318 user in that file.
319
320 <p>
321 <b>Obtaining Quota Information via RADIUS</b><br>
322 If you use the <a href="../contrib/mod_quotatab.html"><code>mod_quotatab</code></a> module for quota support in <code>proftpd</code>, <b>and</b> you use the
323 <code>mod_radius</code> module for authentication, then you might also be
324 interesting in getting your quota information from your RADIUS server, much
325 like you can get user details from the RADIUS server.
326
327 <p>
328 The mechanism is identical that used for user details, <i>i.e.</i>
329 vendor-specific attributes (VSAs). Assuming that you are using FreeRADIUS,
330 you would add the following to your FreeRADIUS <code>dictionary.unix</code>
331 file:
332 <pre>
333 ATTRIBUTE Unix-FTP-Quota-Per-Session <b><i>106</i></b> string
334 ATTRIBUTE Unix-FTP-Quota-Limit-Type <b><i>107</i></b> string
335 ATTRIBUTE Unix-FTP-Quota-Bytes-Upload <b><i>108</i></b> string
336 ATTRIBUTE Unix-FTP-Quota-Bytes-Download <b><i>109</i></b> string
337 ATTRIBUTE Unix-FTP-Quota-Bytes-Transfer <b><i>110</i></b> string
338 ATTRIBUTE Unix-FTP-Quota-Files-Upload <b><i>111</i></b> string
339 ATTRIBUTE Unix-FTP-Quota-Files-Download <b><i>112</i></b> string
340 ATTRIBUTE Unix-FTP-Quota-Files-Transfer <b><i>113</i></b> string
341 </pre>
342 and in the FreeRADIUS <code>users</code> file (assuming the above user-related
343 attributes as well):
344 <pre>
345 DEFAULT Auth-Type := System
346 Unix-User-UID := 500,
347 Unix-User-GID := 500,
348 Unix-User-Home := "/home/tj",
349 Unix-User-Shell := "/bin/bash",
350 Unix-User-Group-Names := "radius,ftpd",
351 Unix-User-Group-Ids := "200,501",
352 Unix-FTP-Quota-Per-Session := "false",
353 Unix-FTP-Quota-Limit-Type := "soft",
354 Unix-FTP-Quota-Bytes-Upload := "1.1",
355 Unix-FTP-Quota-Bytes-Download := "2.2",
356 Unix-FTP-Quota-Bytes-Transfer := "3.3",
357 Unix-FTP-Quota-Files-Upload := "4",
358 Unix-FTP-Quota-Files-Download := "5",
359 Unix-FTP-Quota-Files-Transfer := "6",
360 Fall-Through = 1
361 </pre>
362 and then, to tell <code>mod_radius</code> that it should look for quota-related
363 VSAs in the <code>Access-Accept</code> RADIUS packet, there is the aptly-named
364 <a href="../contrib/mod_radius.html#RadiusQuotaInfo"><code>RadiusQuotaInfo</code></a> directive:
365 <pre>
366 RadiusQuotaInfo $(<b><i>106</i></b>:false) $(<b><i>107</i></b>:hard) $(<b><i>108</i></b>:40.0) $(<b><i>109</i></b>:0.0) $(<b><i>110</i></b>:0.0) $(<b><i>111</i></b>:0) $(<b><i>112</i></b>:0) $(<b><i>113</i></b>:0)
367 </pre>
368
369 <p><a name="FAQ">
370 <b>Frequently Asked Questions</b><br>
371 <font color=red>Question</font>: Do I have to configure my RADIUS server to
372 return VSAs in order to use <code>mod_radius</code>?<br>
373 <font color=blue>Answer</font>: No. As shown above, <code>mod_radius</code>
374 is usually used just for validating user credentials.
375
376 <p>
377 It is also possible to use only <code>mod_radius</code> for user authentication,
378 without needing VSAs. For example, using a configuration like this will
379 do what you need:
380 <pre>
381 &lt;IfModule mod_radius.c&gt;
382 AuthOrder mod_radius.c
383
384 RadiusEngine on
385 RadiusAuthServer localhost:1812 testing123 5
386 RadiusAcctServer localhost:1813 testing123 5
387 RadiusLog /etc/proftpd/radius.log
388
389 RadiusUserInfo 1000 1000 /tmp /bin/bash
390 RadiusGroupInfo ftpd 1000
391 &lt;/IfModule&gt;
392 </pre>
393 Notice how the <code>RadiusUserInfo</code> and <code>RadiusGroupInfo</code>
394 directives do not use the "$(<i>N</i>:<i>M</i>)" syntax? That means that
395 we are not telling <code>mod_radius</code> what vendor ID and attribute IDs
396 to look for. Instead, we are telling <code>mod_radius</code> to <b>always</b>
397 use the configured UID, GID, home directory, shell, group membership values.
398
399 <p>
400 <b>Note</b> that this means that all of your logged-in users will have the
401 exact same UID, GID, and home directory. For some sites, this is ideal. Other
402 sites need to have different UID/GID/homes for each users, and thus they will
403 use the VSA support.
404
405 <p><a name="RadiusAndSSH">
406 <font color=red>Question</font>: Can I use <code>mod_radius</code> for SFTP
407 connections?<br>
408 <font color=blue>Answer</font>: Yes. However, there are some caveats. The
409 main issue that clients which want to use SSH publickey authentication
410 <b>cannot</b> use RADIUS, since the RADIUS protocol does not define any means
411 of conveying the public key information from the connecting client to the
412 RADIUS server. So only password-based SSH authentication can be supported
413 using <code>mod_radius</code>.
414
415 <p>
416 <hr>
417 <font size=2><b><i>
418 &copy; Copyright 2017 The ProFTPD Project<br>
419 All Rights Reserved<br>
420 </i></b></font>
421 <hr>
422
423 </body>
424 </html>