Kerberos Windows Interoperability
Kerberos allows single sign and can assist with Windows and Linux interoperability. The basic goal is to get systems attached to an AD domain to be able to access servers using pass through authentication. Although I have entitled the page Windows Interop, its really AD integration. Linux clients using the various non server related bits can then join in - if that's your requirement.
For example, start up a browser and point it at an Apache webserver. The web server allows access to the browser user because they have been authenticated in the background via Kerberos.
The setup here is designed to use Samba to manage the Kerberos keytab side of things for servers like Squid, Apache and sshd. As is often the case there are other ways to do it but these notes provide an approach that seems to work with minimal maintenance once set up.
This guide does not cover setting up a Key Distribution Centre (MIT or otherwise) nor does it cover all of the other Samba features that you may be interested in. This is just the Kerberos related stuff. Be prepared to put some effort in - this is not a simple copy and paste effort.
Before you start this you must ensure that the clock on your system agrees with the Windows DC that holds the "PDC Emulator" FSMO role. Realistically any of them will do not just that one but that DC is the time source for the whole AD. You must also make sure that DNS is set up correctly. If you can resolve the name of the AD domain, then that is a good start. If either time or DNS go astray then you will get some tricky errors to debug. Always check them both first.
On Gentoo enabling the
kerberos USE flag should pull in app-crypt/mit-krb5. Configuration for a simple setup (set your realm):
[libdefaults] default_realm = EXAMPLE.CO.UK kdc_timesync = 1 ccache_type = 4 forwardable = true proxiable = true fcc-mit-ticketflags = true default_keytab_name = FILE:/etc/krb5.keytab
You may want to create a realm to domain mapping section [realms]. This is especially useful for Apache when the system may have a different external domain to its internal one.
Do not create the file /etc/krb5.keytab - Samba will give an error if it can't create the keytab file.
The following command will grab a Kerberos ticket for the currently logged in user. <user> can actually be any valid Kerberized user account, if omitted then the current Unix username is used. If the default realm is already specified in krb5.conf then it can be also be omitted.
If the realm is already set and the ticket is for a username that matches the Unix user then simply run kinit and enter a password.
It is not always possible to use supplementary groups with some daemons eg Squid. The following will add additional ACLs to the Kerberos keytab file file to allow the processes to read the keytab. This assumes that you have ACL support on the system. If not then you will need some other method of allowing the daemons to access the single keytab. Failing that you will have to create separate keytabs for each application and get them set up manually - web search for that. Only do this bit after getting Samba to create the file, otherwise you will get errors.
setfacl -m u:squid:r /etc/krb5.keytab
setfacl -m u:apache:r /etc/krb5.keytab
file: etc/krb5.keytab owner: root group: root user::rwx user:squid:r-- user:apache:r-- group::r-- mask::r-- other::---
Make sure you have a reasonably recent Samba release installed (eg 3.5 or 3.6+)
- Set Samba to allow access via both secrets (winbind and local passwd) and Kerberos. There are many more options that you might want to configure when joining an AD domain but here we only consider Kerberos related ones.
[global] realm = EXAMPLE.CO.UK kerberos method = secrets and keytab winbind refresh tickets = yes
- Tell winbind to setup a ticket cache for a logged in user.
[global] krb5_auth = yes krb5_ccache_type = FILE
- Join the domain
net ads join -U <admin user>
- Start or restart Samba. Make sure that /etc/conf.d/samba has winbind included in the list of daemons.
- emerge www-apache/mod_auth_kerb
-D AUTH_KERBto /etc/conf.d/apache2
- Edit the module config or add it into your vhost configuration
<IfDefine AUTH_KERB> LoadModule auth_kerb_module modules/mod_auth_kerb.so #LogLevel Debug <Location "/"> AuthType Kerberos AuthName "Kerberos Login" Krb5Keytab /etc/krb5.keytab KrbAuthRealms EXAMPLE.CO.UK KrbMethodNegotiate On KrbMethodK5Passwd Off Require valid-user </Location> </IfDefine>
KrbMethodK5Passwd on to get prompted for authentication. I suggest you only use this over SSL/TLS (https) for obvious reasons.
- Use Samba to set the service principle(s) for Apache (HTTP):
net ads keytab add HTTP -U <a_domain_admin>
net ads keytab add HTTP/<another_SPN>@EXAMPLE.CO.UK -U <a_domain_admin>
net ads keytab list
Note the format in the second command. This will get non default Service Principle Names into the keytab, eg for externally facing vhosts. Remember to set the [realms] section in krb5.conf if you need an external domain to map to an internal realm (or AD domain as MS call them!) The second command also seems to need the SPN added to AD using setspn.exe (on a Windows machine with Domain Admin rights and probably an elevated command prompt on server 2008+):
c:\>setspn.exe -A HTTP/<another SPN> <computer account>
Test it with this index.php in the web server's htdocs somewhere (assuming you have PHP installed and configured):
<?php echo "You have logged in as <b>" . $_SERVER['REMOTE_USER'] . "</b>;"; ?>
Errors like this in errors_log means that the keytab can't be read - check the permissions on it for the apache user:
gss_acquire_cred() failed: Unspecified GSS failure. Minor code may provide more information (, Permission denied)
Use Samba to get the service principle for SSHD - "host". Just to spell it out in case of confusion: use the word host in your command. It is not part of an example, only change the bits between < and >.
net ads keytab add host -U <a_domain_admin>
KerberosAuthentication yes KerberosOrLocalPasswd yes KerberosTicketCleanup yes GSSAPIAuthentication yes GSSAPICleanupCredentials yes UsePAM no
When you turn off PAM you obviously wont be able to get it to make a home directory for a new user. So another method will be needed to do this. Winbindd can do this - see the docs for it if you need this.
Squid also seems to use "HTTP" as its service name like Apache. This will probably need a Squid 3.1.x release.
auth_param negotiate program /usr/libexec/squid/squid_kerb_auth -d auth_param negotiate children 10 auth_param negotiate keep_alive on acl AUTHENTICATED proxy_auth REQUIRED http_access allow AUTHENTICATED http_access deny all
Add the file services role to Windows 2008(R2) and include services for NFS. To add NFS support on a folder, right click it and set it up on the NFS tab. NFS shares do not seem to appear in the Server Manager under Share and Storage Management. The Services for Network File System MMC snap in is a bit random as well.
Check Service Principle Names:
c:\>setspn.exe -l <account_name>
net ads keytab
Check a Samba maintained keytab like this:
net ads keytab list
ktutil and klist
Check keytabs like this:
klist -ke /etc/krb5.keytab
negotiateinto the filter
- Additional domains (eg short names) can be added separated by commas: e.g.
- (On Linux only) at a user shell prompt type
kinitand enter your AD password to authenticate and get a ticket from the KDC (This is not needed if you set up /etc/security/pam_winbind.conf)
Start Chrome with
--auth-server-whitelist="*.example.co.uk" --auth-negotiate-delegate-whitelist="*.example.co.uk". You can edit /usr/share/applications/chrome.desktop to add this. Not needed on Windows.
Does single signon out of the box. IE 7+. Don't use <=6!
For the SSH client on Linux. This can go in the system wide configuration or in a user specific configuration:
host *.example.co.uk GSSAPIAuthentication yes
You can connect to Exchange via Evolution EWS and provided that autodiscover is set up correctly it will work out of the box. I have found that adding additional SPNs to the client access server's machine account can assist with getting Kerberos instead of NTLM working. eg:
c:\>setspn.exe -S HTTP/exchange.example.co.uk EXCHCAS
To determine what names are needed, switch Evolution to using Kerberos and have Wireshark or tcpdump running and look out for the name that Evolution tries to contact the server with. You should see a flurry of DNS lookups followed by Kerberos related packets. One of the fields will show the host name that your client is trying to use.
If everything is in place (winbind etc) then you simply start Evolution up, add a new account, fill in your name and set the type to ews and then press the lookup button after filling in your email address
- Get hold of a development snapshot until it is in the core release.
- Connection -> Data, select Use system username (your name)
- Connection -> SSH -> Auth -> GSSAPI, make sure Attempt GSSAPI authentication is selected