Skip to content

Commit 2e4f5c2

Browse files
noladealandekok
authored andcommitted
docs: update howto/Datastores/Active Directory install/configure instructions
1 parent 9149e9d commit 2e4f5c2

3 files changed

Lines changed: 206 additions & 59 deletions

File tree

doc/antora/modules/howto/pages/datastores/ad/index.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22

33
Microsoft Active Directory (AD) is a directory service that stores and manages user accounts, credentials, and other network resources within a domain. The AD server receives and processes access requests from the FreeRADIUS server. AD provides a centralized location for managing authentications and access by:
44

5+
The services manage network activities by:
6+
57
* authenticating users by verifying their identity and credentials, and
6-
* authorizating resource access to that user by applying policies to restrict access to data.
8+
* authorizating resource use by applying policies to restrict access to data.
79
810
== What is it?
911

1012
When FreeRADIUS is integrated with Active Directory, the AD server functions as an “authentication oracle.” FreeRADIUS doesn’t store user credentials internally, but instead, passes these credentials to AD for verification.
1113

12-
For PAP and MS-CHAP based authentications, FreeRADIUS uses tools such as Samba, including winbind, and the `ntlm_auth` helper program to communicate with the AD server. 
14+
For MS-CHAP based authentications, FreeRADIUS uses tools such as Samba, including winbind and the `ntlm_auth` helper program to communicate with the AD server. 
1315

1416
=== FreeRADIUS Active Directory Authentication Process
1517

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
= Join FreeRADIUS to AD Domain
2+
3+
Some deployments use Active Directory services to use in mschap based authentications. The RADIUS server must alreay be up and running and basic authentication works (pap/chap). For a freeRADIUS server to fully leverage the AD server and relevant services, the RADIUS server must first be configured and then joined to the domain (or samba realm).
4+
5+
6+
== Configuration of variables
7+
8+
Requires the following variables to be set by the including template:
9+
10+
- orch_minion: First orchestrator minion
11+
- orch: Hostname of the orchestrator
12+
- orch_fqdn: FQDN of the orchestrator
13+
- host_exam: Example RADIUS authentication server hostname
14+
- netbios_exam: Example netbios name for auth server host
15+
- realm: Samba realm
16+
- workgroup: Samba workgroup
17+
- domains: List of domains mapping to the Kerberos realm
18+
- dcs: List of AD domain controllers
19+
- preferred: A preferred domain controller.
20+
Default: No preference ("password server = *")
21+
- admin: DC acting as the Kerberos master. Default: First entry in dcs.
22+
- join_user: User privileged to perform domain joins. Optional.
23+
- join_server: DC to use for the join operation. Optional.
24+
25+
26+
== Install packages for AD integration
27+
28+
{%- if g[orch_minion]['os_family'] == 'RedHat' %}
29+
{%- set pkg = 'rpm' %}
30+
{%- elif g[orch_minion]['os_family'] == 'Debian' %}
31+
{%- set pkg = 'deb' %}
32+
{%- endif %}
33+
34+
{%- if admin is not defined or admin == '' %}
35+
{%- set admin = dcs[0] %}
36+
{%- endif %}
37+
38+
{%- if join_user is not defined or join_user == '' %}
39+
{%- set join_user = '[ privileged user ]' %}
40+
{%- endif %}
41+
42+
{%- set join_server_opt = '-S ' ~ join_server if join_server is defined else '' %}
43+
44+
45+
== Domain membership for MS-CHAPv2 based authentication
46+
47+
A prerequisite for authenticating domain users via MS-CHAPv2 is that the RADIUS
48+
authentication servers have been successfully joined to the domain and winbind
49+
configured.
50+
51+
[NOTE]
52+
====
53+
Establishing and maintaining each host's domain membership is the
54+
responsibility of the customer, so only an outline process is provided here.
55+
Configuration varies between organisations and over time, so an organisation's
56+
domain administrator should be consulted for details.
57+
====
58+
59+
Perform the following manual steps on each authentication server...
60+
61+
=== Install winbind as follows:
62+
63+
{% if pkg == 'deb' %}
64+
{{ host_exam }}# apt-get install -y samba winbind krb5-user
65+
{% elif pkg == 'rpm' %}
66+
{{ host_exam }}# yum install -y samba-winbind krb5-workstation
67+
{% else %}
68+
{%- set error = 'No instructions for this OS' + (0/0)|string %}
69+
{% endif %}
70+
71+
== Configure `/etc/krb5.conf` as follows:
72+
73+
```
74+
[libdefaults]
75+
default_realm = {{ realm }}
76+
dns_lookup_realm = false
77+
dns_lookup_kdc = true
78+
79+
[realms]
80+
{{ realm }} = {
81+
{%- for d in dcs %}
82+
kdc = {{ d }}
83+
{%- endfor %}
84+
admin_server = {{ admin }}
85+
}
86+
87+
[domain_realm]
88+
{%- for d in domains %}
89+
.{{ d }} = {{ realm }}
90+
{{ d }} = {{ realm }}
91+
{%- endfor %}
92+
```
93+
94+
=== Configure `/etc/samba/smb.conf` as follows:
95+
96+
```
97+
[global]
98+
netbios name = {{ netbios_exam }}
99+
workgroup = {{ workgroup }}
100+
server string = RADIUS server
101+
dns proxy = no
102+
security = ads
103+
invalid users = root
104+
unix password sync = no
105+
pam password change = no
106+
107+
socket options = TCP_NODELAY
108+
idmap uid = 16777216-33554431
109+
idmap gid = 16777216-33554431
110+
template shell = /bin/sh
111+
112+
winbind use default domain = no
113+
winbind max domain connections = 10
114+
winbind max clients = 1000
115+
{%- if preferred is defined %}
116+
password server = {{ preferred }}, *
117+
{%- else %}
118+
password server = *
119+
{%- endif %}
120+
allow trusted domains = no
121+
realm = {{ realm }}
122+
```
123+
124+
== Join the host to the domain:
125+
126+
radius-auth1# net ads join -U {{ join_user }} {{ join_server_opt }}
127+
128+
[NOTE]
129+
====
130+
It is normal to receive an error message about failure to update DNS.
131+
====
132+
133+
== Restart the winbind service:
134+
135+
radius-auth1# systemctl stop winbind
136+
radius-auth1# systemctl start winbind
137+
138+
A description of how to test and troubleshoot winbind is provided in the
139+
[Operations and troubleshooting guide](/doc/html/ops/operations.html) document.
140+
141+
Authentication must be achieved using the `wbinfo` tool before FreeRADIUS will
142+
be able to successfully authenticate users performing a MS-CHAPv2 based method.
143+
144+
If there are going to be password changes with freeradius ("your password has expired" - type - scenarios) You should probably also configure in /mods-available/mschap:
145+
146+
passchange {
147+
ntlm_auth = "/path/to/ntlm_auth
148+
--helper-protocol=ntlm-change-password-1 --allow-mschapv2
149+
ntlm_auth_username = "username: %{mschap:User-Name}
150+
ntlm_auth_domain = "nt-domain: %{mschap:NT-Domain}"
151+
With the settings above it works correctly, so even if it is unnecessary, it doesn't break anything. It hasn't been tested without this option while denying ntlmv1 overall on the AD DC, but it is thought that it will work without it.
152+
Lines changed: 50 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,11 @@
1-
= Integrating with Active Directory (AD)
1+
== Configuring Authentication with Active Directory (AD)
22

3-
The main steps to integrate FreeRADIUS authentication with Active Directory are:
3+
Once the PAP authentication test has been successful, the next step for sites using Active Directory is to configure the system to perform user authentication against Active Directory. The clear-text passwords are unavailable through Active Directory, so we have to use Samba, and the ntlm_auth helper program. In this configuration, we are using Active Directory as an authentication oracle, and not as an LDAP database.
44

5-
. Install and configure Samba by editing the `smb.conf` file.
6-
. Configure FreeRADIUS by editing the relevent modules such as `ntlm_auth` and ms-chap.
7-
. Join the FreeRADIUS server to the Active Directory domain.
8-
. Configure Samba to authenticate against Active Directory and test authentications using `winbind` and `ntlm`.
9-
. Configure FreeRADIUS to use the `ntlm_auth` module for authentication.
5+
Using ntlm_auth for PAP authentication may not work on recent versions of Samba and Active Directory. If so, just skip to the next section.
106

11-
After the PAP authentication has been successful, the next step for sites using Active Directory is to configure the system to perform user authentication against Active Directory. The clear-text passwords are unavailable through Active Directory, so we use Samba, and the `ntlm_auth` helper program. In this configuration, we are using Active Directory as an authentication oracle, and not as an LDAP database.
7+
Once Samba has been installed on your system, you should edit the smb.conf file, and configure the [global] section to point to your NT server, including hostname and NT domain.
128

13-
Samba uses the SMB protocol along with the winbind module to authenticate users against Active Directory. Users are verified using either the PAP or MS-CHAP authentication methods.
14-
15-
Using `ntlm_auth` for PAP authentication may not work on recent versions of Samba and Active Directory. If you have this issue, proceed to the xref:datastores/ad/configure_ntlm_mschap.adoc[Configuring ntlm] section.
16-
17-
== Configuring Samba
18-
19-
Once Samba has been installed on your system, edit the `smb.conf` file, and update the [global] section to point to your NT server, including hostname and NT domain.
20-
21-
=== Configure `/opt/samba/etc/smb.conf` file
22-
23-
The example snippet shown below needs to be modified with your site parameters which includes updating the workgroup, security, and realm fields.
24-
25-
```
269
# workgroup = NT-Domain-Name
2710
workgroup = MYDOMAIN
2811
...
@@ -33,64 +16,74 @@ The example snippet shown below needs to be modified with your site parameters w
3316
password server = nt-server-hostname.company.com
3417
...
3518
realm = realm.company.com
36-
```
19+
For Samba 4, you also have to set the ntlm authconfiguration variable. It should be set to either yes, or to mschapv2-and-ntlmv2-only. This configuration needs to be set all participating Samba members, and also on (Samba4) AD-DC servers.
3720

38-
Next, update the ntlm authconfiguration variable for Samba 4 to set the authentication protocol used between the FreeRADIUS and AD servers. This variable can be set to either `yes` or to `mschapv2-and-ntlmv2-only`. This configuration needs to be added to all participating Samba members, and also on (Samba4) AD Domain Controller (DC) servers.
39-
```
4021
ntlm auth = mschapv2-and-ntlmv2-only
4122
...
42-
```
43-
=== Configure `/etc/krb5.conf` file
44-
45-
Edit the `/etc/krb5.conf` file by adding an entry to point to the AD server.
23+
You may also have to edit the /etc/krb5.conf file, to add an entry that points to the Active Directory Server. This is often not necessary, as Samba can just "figure it out" when Active Directory is also the main DNS server.
4624

47-
```
4825
[realms]
4926
...
5027
realm.company.com = {
5128
kdc = nt-server-hostname.company.com
5229
}
5330
...
54-
```
5531

56-
If the Active Directory server is also the main DNS server, this previous step isn't necessary. Samba resolves the name from a local dns lookup and therefore may require setting `libdefaults` in the `/etc/krb5.conf` file:
32+
== Start the Samba and Kerberos servers, and as root join the domain:
5733

58-
```
59-
[libdefaults]
60-
default_realm = realm.company.com
61-
dns_lookup_realm = false
62-
dns_lookup_kdc = true
63-
```
34+
$ net join -U Administrator
35+
Enter the administrator password at the prompt.
6436

65-
After all file updates are complete, start the Samba and Kerberos servers.
37+
Next, verify that a user in the domain can be authenticated:
6638

67-
== Join the domain as root:
39+
$ wbinfo -a user%password
40+
You should see a number of lines of text, followed by authentication succeeded. The next step is to try the same login with the ntlm_auth program, which is what FreeRADIUS will be using:
6841

69-
From a terminal window on the FreeRADIUS server, enter the command:
7042

71-
`$ net join -U Administrator`
43+
$ ntlm_auth --request-nt-key --domain=MYDOMAIN --username=user --password=password
44+
If all goes well, you should see authentication succeeding (NT_STATUS_OK). You may also see the NT_KEY output, which is needed in order for FreeRADIUS to perform MS-CHAP authentication.
7245

73-
Enter the administrator password at the prompt.
46+
== Configuring FreeRADIUS to use ntlm_auth
47+
Once you have verified that Samba is installed and working correctly, and that the ntlm_auth program works, you can proceed with configuring FreeRADIUS to use ntlm_auth. For initial testing, we will be using the exec module, and will run the exact command line used above.
7448

75-
== Verify user authentication
49+
Create or edit the ntlm_auth module configuration. In version 2, this file should be saved as raddb/modules/ntlm_auth. In version 3, it should be saved as raddb/mods-enabled/ntlm_auth. The contents of the file are below, with the fields to edit in bold.
7650

77-
Authentication must be achieved using the `wbinfo` tool before FreeRADIUS will
78-
be able to successfully authenticate users performing a MS-CHAPv2 based method.
51+
exec ntlm_auth {
52+
wait = yes
53+
program = "/path/to/ntlm_auth --request-nt-key --domain=MYDOMAIN --username=%{mschap:User-Name} --password=%{User-Password}"
54+
}
55+
This configuration tells the server to run the ntlm_auth program with the user name and password obtained from the Access-Request. You will also have to list ntlm_auth in the authenticate sections of each the raddb/sites-enabled/default file, and of the raddb/sites-enabled/inner-tunnel file:
7956

80-
.Example winbind
81-
```
82-
$ wbinfo -a user%password
83-
```
57+
authenticate {
58+
...
59+
ntlm_auth
60+
...
61+
}
62+
and add the following text for testing purposes only to the top of the users file. In version 3, the "users" file has moved to raddb/mods-config/files/authorize.
8463

85-
If authentication using winbind works, you'll see a number of lines of text, followed by an authentication succeeded message.
64+
DEFAULT Auth-Type = ntlm_auth
65+
This configuration says "for all users, if the authenticate method has not been set, set it to use the ntlm_auth program".
8666

87-
The next step is to try the same login with the ntlm_auth program, which is what FreeRADIUS will be using:
67+
Start the server using radiusd -X, and wait for the debugging text to stop scrolling by. If all goes well, you should see the following text:
8868

89-
.Example ntlm_auth
90-
```
91-
$ ntlm_auth --request-nt-key --domain=MYDOMAIN --username=user --password=password
92-
```
69+
Ready to process requests.
70+
In another terminal window on the same machine, type the following command:
71+
72+
$ radtest user password localhost 0 testing123
73+
If all goes well, you should see the server returning an Access-Accept message, and the window with radtest should print text similar to the following:
74+
75+
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, length=20
76+
This text means that authentication succeeded. A few lines above this text, the debug output will also show the exact command line used to run ntlm_auth.
77+
78+
== Configuring FreeRADIUS to use ntlm_auth for MS-CHAP
79+
Once you have the previous steps working, configuring FreeRADIUS to use ntlm_auth for MS-CHAP is simple. First, delete the testing entry used above from the users file, as leaving it in will break other authentication types. Then, find the mschap module in raddb/modules/mschap file, and look for the line containing ntlm_auth = . It is commented out by default, and should be uncommented, and edited to be as follows. As before, update the fields in bold to match your local configuration.
80+
81+
ntlm_auth = "/path/to/ntlm_auth --request-nt-key --allow-mschapv2 --username=%{mschap:User-Name:-None} --domain=%{%{mschap:NT-Domain}:-MYDOMAIN} --challenge=%{mschap:Challenge:-00} --nt-response=%{mschap:NT-Response:-00}"
82+
Start the server and use radtest to send an MS-CHAP authentication request. You will need to have version 2.1.10 or later for this to work:
83+
84+
$ radtest -t mschap bob hello localhost 0 testing123
85+
If everything goes well, you should see the server returning an Access-Accept message as above.
9386

94-
If authentication using `ntlm` works, you'll see authentication succeeding (NT_STATUS_OK). You may also see the `NT_KEY` output, which is needed in order for FreeRADIUS to perform MS-CHAP authentication.
87+
If it does not work, double-check the password you entered on the supplicant against the password in Active Directory. If it still does not work, it might be a bug in Samba. Change your version of Samba, either by installing a fixed version, or by repeatedly down-grading it (and testing) until it works.
9588

96-
Your next step is to configure FreeRADIUS to use xref:datastores/ad/ntlm_mschap.adoc[ntlm with MS-CHAP] to perform all user authentications.
89+
If it does not work, then it is possible to test authentication with just the ntlm_auth command-line. Look at the FreeRADIUS debug output, and see the arguments passed to ntlm_auth. Copy and paste them to a command-line, and then use that command line for testing. This limited test is often simpler and faster than running a complex test with a full RADIUS server. When this limited test passes, then authentication with FreeRADIUS will work, too.

0 commit comments

Comments
 (0)