| 1 |
Kerberos |
| 2 |
======== |
| 3 |
|
| 4 |
Presentation |
| 5 |
------------ |
| 6 |
|
| 7 |
This page is about obtaining all the prerequisites for Kerberos to work in your |
| 8 |
network. In order to configure LemonLDAP::NG to use Kerberos, refer to the |
| 9 |
:doc:`Kerberos authentication module documentation <authkerberos>` |
| 10 |
|
| 11 |
Prerequisites |
| 12 |
------------- |
| 13 |
|
| 14 |
Example values |
| 15 |
~~~~~~~~~~~~~~ |
| 16 |
|
| 17 |
We will use the following values in our examples |
| 18 |
|
| 19 |
- **EXAMPLE.COM**: First AD domain |
| 20 |
- **ACME.COM**: Second AD domain (optional, in case of a cross-domain trust) |
| 21 |
- **auth.example.com**: DNS of the LL::NG portal |
| 22 |
- **KERB_AUTH**: AD account to generate the keytab for LL::NG server |
| 23 |
|
| 24 |
Service Account |
| 25 |
~~~~~~~~~~~~~~~ |
| 26 |
|
| 27 |
A service account must be created on the AD server. It must be a user account and not a computer account. |
| 28 |
|
| 29 |
Be sure to set the following options on it: |
| 30 |
|
| 31 |
* Password never expires |
| 32 |
* This account supports Kerberos AES encryption (128/256bits) |
| 33 |
|
| 34 |
The second option is required if you are using recent Linux versions, where RC4 is no longer available. |
| 35 |
|
| 36 |
Server time |
| 37 |
~~~~~~~~~~~ |
| 38 |
|
| 39 |
It is mandatory that LL::NG servers and AD servers have the same time. |
| 40 |
It is recommended to use NTP to do this. |
| 41 |
|
| 42 |
DNS |
| 43 |
~~~ |
| 44 |
|
| 45 |
In our experience, we have observed the following limitations when using Kerberos for web applications in an Active Directory environment |
| 46 |
|
| 47 |
* ``auth.example.com`` should be registered in the DNS server as a ``A`` record. ``CNAME`` usually do not work |
| 48 |
* The reverse DNS (``PTR``) for ``auth.example.com``'s IP address should point back to ``auth.example.com`` |
| 49 |
|
| 50 |
.. tip:: |
| 51 |
|
| 52 |
If you have a SSO cluster, you must setup a Virtual IP in |
| 53 |
cluster and register this IP in DNS. |
| 54 |
|
| 55 |
.. tip:: |
| 56 |
|
| 57 |
If you cannot configure the PTR record to point to the portal's hostname, it |
| 58 |
may help to run the following command. Assuming that ``proxy.example.com`` is |
| 59 |
the PTR record of the portal's IP address :: |
| 60 |
|
| 61 |
setspn -s HTTP/proxy.example.com keytab-account |
| 62 |
|
| 63 |
SSL |
| 64 |
~~~ |
| 65 |
|
| 66 |
SSL is not mandatory, but it is strongly recommended. Your portal URL |
| 67 |
should be https://auth.example.com. |
| 68 |
|
| 69 |
Web server configuration |
| 70 |
~~~~~~~~~~~~~~~~~~~~~~~~ |
| 71 |
|
| 72 |
Apache |
| 73 |
^^^^^^ |
| 74 |
|
| 75 |
Some Kerberos tickets, especially generated by Active Directory, can get too big for Apache's default header size limit, especially for users with a lot of groups. |
| 76 |
|
| 77 |
Increase it in the global `httpd.conf` configuration :: |
| 78 |
|
| 79 |
LimitRequestFieldSize 16384 |
| 80 |
|
| 81 |
|
| 82 |
Nginx |
| 83 |
^^^^^ |
| 84 |
|
| 85 |
Some Kerberos tickets, especially generated by Active Directory, can get too big for Apache's default header size limit, especially for users with a lot of groups. |
| 86 |
|
| 87 |
Increase it in your `portal-nginx.conf` configuration :: |
| 88 |
|
| 89 |
large_client_header_buffers 4 16k; |
| 90 |
|
| 91 |
Web browser configuration |
| 92 |
~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 93 |
|
| 94 |
Firefox |
| 95 |
^^^^^^^ |
| 96 |
|
| 97 |
Type ``about:config`` in a tab and search for ``trusted``. Then edit the |
| 98 |
property ``network.negotiate-auth.trusted-uris`` and set value |
| 99 |
``example.com``. |
| 100 |
|
| 101 |
Internet Explorer / Edge / Chrome |
| 102 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 103 |
|
| 104 |
Add ``https://auth.example.com`` as trusted site. |
| 105 |
|
| 106 |
Check into security parameters that Kerberos authentication is allowed. |
| 107 |
|
| 108 |
Obtain keytab file |
| 109 |
------------------ |
| 110 |
|
| 111 |
Standard case |
| 112 |
~~~~~~~~~~~~~ |
| 113 |
|
| 114 |
You have to run this command on Active Directory: |
| 115 |
|
| 116 |
:: |
| 117 |
|
| 118 |
ktpass -princ HTTP/[email protected] -mapuser [email protected] -crypto All -ptype KRB5_NT_PRINCIPAL -mapOp set -pass <PASSWORD> -out c:\auth.keytab |
| 119 |
|
| 120 |
|
| 121 |
.. attention:: |
| 122 |
|
| 123 |
You must use the UPPERCASE value of the domain name when generating the keytab |
| 124 |
|
| 125 |
The file ``auth.keytab`` should then be copied (with a secure media) to |
| 126 |
the Linux server (for example in ``/etc/lemonldap-ng``). |
| 127 |
|
| 128 |
Change rights on keytab file: |
| 129 |
|
| 130 |
:: |
| 131 |
|
| 132 |
chown apache /etc/lemonldap-ng/auth.keytab |
| 133 |
chmod 600 /etc/lemonldap-ng/auth.keytab |
| 134 |
# If you use SELinux |
| 135 |
restorecon /etc/lemonldap-ng/auth.keytab |
| 136 |
|
| 137 |
Special case: multiple AD domains |
| 138 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 139 |
|
| 140 |
You need to obtain a keytab for each node on each domain. This means the |
| 141 |
ktpass commands should be run on both AD. |
| 142 |
|
| 143 |
Then you will have 2 keytab files for each node, for example: |
| 144 |
|
| 145 |
- node1-example.keytab |
| 146 |
- node1-acme.keytab |
| 147 |
|
| 148 |
You need to concatenate the keytab files, thanks to ``ktutil`` command: |
| 149 |
|
| 150 |
:: |
| 151 |
|
| 152 |
ktutil |
| 153 |
ktutil: read_kt node1-example.keytab |
| 154 |
ktutil: read_kt node1-acme.keytab |
| 155 |
ktutil: write_kt /etc/lemonldap-ng/auth.keytab |
| 156 |
ktutil: quit |
| 157 |
|
| 158 |
You can then remove the original keytab files and protect the final |
| 159 |
keytab file: |
| 160 |
|
| 161 |
:: |
| 162 |
|
| 163 |
chown apache /etc/lemonldap-ng/auth.keytab |
| 164 |
chmod 600 /etc/lemonldap-ng/auth.keytab |
| 165 |
|
| 166 |
Testing your setup |
| 167 |
------------------ |
| 168 |
|
| 169 |
This is only needed if your Kerberos configuration is not working and you don't understand why. It explains how request a Kerbeors ticket from a GNU/Linux station (which could be the LL::NG server if you don't have other one). |
| 170 |
|
| 171 |
Of course it requires a valid user account on AD to be able to otbain the Kerberos ticket. |
| 172 |
|
| 173 |
Client Kerberos configuration |
| 174 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 175 |
|
| 176 |
Edit ``/etc/krb5.conf``: |
| 177 |
|
| 178 |
.. code-block:: ini |
| 179 |
|
| 180 |
[libdefaults] |
| 181 |
default_realm = EXAMPLE.COM |
| 182 |
dns_lookup_kdc = false |
| 183 |
dns_lookup_realm = no |
| 184 |
ticket_lifetime = 24h |
| 185 |
forwardable = yes |
| 186 |
renewable = true |
| 187 |
|
| 188 |
[realms] |
| 189 |
EXAMPLE.COM = { |
| 190 |
kdc = ad.example.com |
| 191 |
admin_server = ad.example.com |
| 192 |
} |
| 193 |
|
| 194 |
[domain_realm] |
| 195 |
.example.com = EXAMPLE.COM |
| 196 |
example.com = EXAMPLE.COM |
| 197 |
|
| 198 |
Getting a Kerberos ticket |
| 199 |
~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 200 |
|
| 201 |
You can check the validity of the keytab file by trying to request a |
| 202 |
service ticket, and compare the result with the keytab content. |
| 203 |
|
| 204 |
Open a Kerberos session: |
| 205 |
|
| 206 |
:: |
| 207 |
|
| 208 |
kinit [email protected] |
| 209 |
|
| 210 |
Request a service ticket: |
| 211 |
|
| 212 |
:: |
| 213 |
|
| 214 |
kvno HTTP/[email protected] |
| 215 |
|
| 216 |
The result of the command should be: |
| 217 |
|
| 218 |
:: |
| 219 |
|
| 220 |
HTTP/[email protected]: kvno = 3 |
| 221 |
|
| 222 |
Read the service ticket: |
| 223 |
|
| 224 |
:: |
| 225 |
|
| 226 |
klist -e |
| 227 |
|
| 228 |
You should see this kind of ticket: |
| 229 |
|
| 230 |
:: |
| 231 |
|
| 232 |
06/04/15 16:28:49 06/05/15 02:28:11 HTTP/[email protected] |
| 233 |
renew until 06/05/15 16:28:07, Etype (skey, tkt): arcfour-hmac, arcfour-hmac |
| 234 |
|
| 235 |
You can close the Kerberos session: |
| 236 |
|
| 237 |
:: |
| 238 |
|
| 239 |
kdestroy |
| 240 |
|
| 241 |
Checking the keytab |
| 242 |
~~~~~~~~~~~~~~~~~~~ |
| 243 |
|
| 244 |
Now you can compare the above result with the same request done through |
| 245 |
the keytab file on LL::NG server: |
| 246 |
|
| 247 |
:: |
| 248 |
|
| 249 |
klist -e -k -t /etc/lemonldap-ng/auth.keytab |
| 250 |
|
| 251 |
The result of the command should be: |
| 252 |
|
| 253 |
:: |
| 254 |
|
| 255 |
Keytab name: FILE:/etc/lemonldap-ng/auth.keytab |
| 256 |
KVNO Timestamp Principal |
| 257 |
---- ------------------- ------------------------------------------------------ |
| 258 |
3 01/01/1970 01:00:00 HTTP/[email protected] (DEPRECATED:des-cbc-crc) |
| 259 |
3 01/01/1970 01:00:00 HTTP/[email protected] (DEPRECATED:des-cbc-md5) |
| 260 |
3 01/01/1970 01:00:00 HTTP/[email protected] (DEPRECATED:arcfour-hmac) |
| 261 |
3 01/01/1970 01:00:00 HTTP/[email protected] (aes256-cts-hmac-sha1-96) |
| 262 |
3 01/01/1970 01:00:00 HTTP/[email protected] (aes128-cts-hmac-sha1-96) |
| 263 |
|
| 264 |
|
| 265 |
The important things to check are: |
| 266 |
|
| 267 |
- KVNO must be the same |
| 268 |
- Principal names must be the same |
| 269 |
- Encryption types must be the same |
| 270 |
|
| 271 |
|
| 272 |
Multiple AD domains |
| 273 |
~~~~~~~~~~~~~~~~~~~ |
| 274 |
|
| 275 |
The two domains must be defined in ``/etc/krb5.conf``: |
| 276 |
|
| 277 |
.. code-block:: ini |
| 278 |
|
| 279 |
[libdefaults] |
| 280 |
default_realm = EXAMPLE.COM |
| 281 |
dns_lookup_kdc = false |
| 282 |
dns_lookup_realm = no |
| 283 |
ticket_lifetime = 24h |
| 284 |
forwardable = yes |
| 285 |
renewable = true |
| 286 |
|
| 287 |
[realms] |
| 288 |
EXAMPLE.COM = { |
| 289 |
kdc = ad.example.com |
| 290 |
admin_server = ad.example.com |
| 291 |
default_domain = EXAMPLE.COM |
| 292 |
} |
| 293 |
ACME.COM = { |
| 294 |
kdc = ad.acme.com |
| 295 |
admin_server = ad.acme.com |
| 296 |
} |
| 297 |
|
| 298 |
[domain_realm] |
| 299 |
.example.com = EXAMPLE.COM |
| 300 |
example.com = EXAMPLE.COM |
| 301 |
.acme.com = ACME.COM |
| 302 |
acme.com = ACME.COM |
| 303 |
|
| 304 |
You should then be able to open a Kerberos session on each domain: |
| 305 |
|
| 306 |
:: |
| 307 |
|
| 308 |
kinit [email protected] |
| 309 |
klist -e |
| 310 |
kdestroy |
| 311 |
|
| 312 |
:: |
| 313 |
|
| 314 |
kinit [email protected] |
| 315 |
klist -e |
| 316 |
kdestroy |
| 317 |
|
| 318 |
You can then check the tickets and the keytab. |