# Using Samba as an AFS gateway Recently I've been researching methods of using Samba as an AFS gateway. Below are my findings so far. Please feel free to add/correct stuff. -- Daniel Clark - 04 Aug 2002 ## Plain text passwords sent over network In these solutions the plain text password is sent over the network. This requires [[EnablePlainTextPassword]] be set on your Windows hosts. Plain text passwords are necessary with stock Samba because the method that SMB uses for secure authentication is not compatible with Kerberos. Therefore the Samba server must have your plain text password so it can in turn get you AFS tokens using your password. Advantages: - No new software needs to be installed on clients - Only required change on clients is to set a registry key Disadvantages: - Passwords sent in plain text over the network - Clients may initially try to use plain text passwords to login to SMB servers other than the AFS gateway - Client gets no warning before AFS tokens expire - To get new tokens, client must unmap and then remap the drive letter corresponding to the AFS gateway ### Compile Samba 2 --with-pam This causes Samba to use pluggable authentication modules (PAM) for authentication. PAM is available on many Unix variants, notably Linux and Solaris. There are PAM modules for the various Kerberos implementations that work with AFS; the module for the default kaserver comes with [[OpenAFS]]. For some more info on PAM see the [Samba doc](http://de.samba.org/samba/ftp/docs/htmldocs/Samba-HOWTO-Collection.html#PAM). Many precompiled versions of Samba are built with this option (i.e. Redhat's Samba RPMs) Advantages: - The only method that is integrated into Samba core and pretty much guaranteed to be maintained and work with all future Samba releases, as it is generally useful to people for purposes other then using Samba as an AFS gateway. There seem to be no people on the Samba core team that have an active interest in AFS. Disadvantages: - Doesn't work with operating systems that do not support PAM. ### Compile Samba 2 --with-afs This links Samba against AFS authentication code directly. Advantages: - May work with systems that do not support PAM. Disadvantages: - Not actively maintained. Author states the option may be suffering from bit rot. - Several people have mentioned difficulty getting the library and header paths right, mentioning conflicts between [[OpenAFS]], [[OpenSSL]] and non-AFS Kerberos libraries and header files. It is unclear if this code is works with the latest Samba and [[OpenAFS]] releases at all. - May need to hunt around on the internet for a patch to make this work against a specific OS type and Samba version, and then use that older Samba version. - Patch for AIX / Samba 2.0.4b: ## No plain text passwords sent over network These are methods that avoid sending plain text passwords over the network. Advantages: - Increased security Disadvantages: - Requires modifications to stock Samba distribution - Requires additional infrastructure beyond Samba - All are primarily internal projects that people did for their employers, support may be minimal to nonexistent. ### kSAMBA kSamba is used for AFS translation in University of Michigan Campus sites. It also allows Windows workstations to authenticate and connect to UNIX SMB (Server Message Block) servers via a Kerberos out-of-band negotiation. This allows users to connect without entering a SMB password. A version of Samba 2.0.6 modified to support AFS and Kerberos is implemented on the server side.
URL http://rsug.itd.umich.edu/software/ksamba.html
Email ifs.via.samba@umich.edu
Advantages: - Very good security. Plain text passwords are not required to be sent over the network or kept on the Samba server. - Has been in active use by a good number of clients for several years. - Looks like it might have an interface to manipulate AFS permissions - see Disadvantages: - Seems to be pretty specific to UMich's site - unclear if anyone else is using it. - Requires each Windows client to install some software - Windows client software doesn't seem to be open source - Windows client software won't install on Windows 2000 or XP - Looks like it may be tied to a specific Kerberos implementation - Must run Samba 2.0.6 or do some porting to newer version ### SMBKlog SMBKlog uses out-of-band authentication over SSL. The server sends the client an RSA public key - the client encrypts the password with the public key and sends it to the server, which then decrypts it. There is an email explaining it at .
URL http://www22.brinkster.com/jvrobert
Email Jason Robertson jason.v.robertson@intel.com
Advantages: - Password not sent over network in plain text - Not specific to any particular Kerberos/AFS implementation [ Transarc/OpenAFS OK ] - Uses [[OpenSSL]] so probably relatively easy to write new Windows clients - Successfully used at Intel to comply with corporate security requirements Disadvantages: - Password exists in plain text form on Samba server, at least in memory, for some period of time (Samba server decrypts password to plaintext form and uses that to get AFS tokens) - Requires each Windows client to install some software - Windows client software dies on Windows 2000 and XP [ May be fixed in current version ] - Must run specific Samba version or do some porting to newer version [ Should be straightforward ] - Not under heavy active development. Updates: - Frank Cameron () updated Jason's smbklog patches to work with Samba 2.2.7 - [[samba-2.2.7-afstoken.patch]]: Updated smbklog patch for Samba 2.2.7 - Also available is a patch to compile Samba 2.2.7 on [[RedHat]] 8 - [[samba-2.2.7_afstoken.spec]]: Spec file to build Samba 2.2.7 w/ SMBKlog on RH 8 ### FOKSTRAUT **Fokstraut and Samba - Dealing with Authentication and Performance Issues On A Large Scale Samba Service** Robert Beck & Steve Holstead, _University of Alberta_ **Abstract** At the University of Alberta, we have approximately 55,000 user id's using central services authenticated by Kerberos. We use AFS for central file service. We use Samba to provide Windows compatible access to much of our central file service. Samba contains a number of useful features for Microsoft Windows compatibility, including a kludge to deal with the problem of Windows sending an all uppercase version of a user's password. We observed that when Windows connects to a share, it frequently attempts many incorrect passwords repeatedly before trying the correct one. This created a very heavy authentication load on our central Samba service when users would connect every morning and authenticate. We observed this load and noticed that most of our problems were caused by repeated attempts to authenticate, and the high cost of checking these attempts. To help reduce the load due to authentication, we implemented FOKSTRAUT, a set of modifications to Samba to cache recent password failures and successes in a DBM database built by the Samba server as it runs. By caching the recent failures we avoid expensive re-checks of the (many) other passwords Windows likes to send us. We also cache the correct case of the real password, and by doing so we avoid the expensive overhead of "cracking" an all uppercase password When Windows decides to send one. We also use FOKSTRAUT to cache the NT and LanMan password hashes of a users password once we see a successful authentication. This then allows us to use the newer Windows NT password hash after the user has connected once, without having to centrally convert and maintain a large SMB password file, and while maintaining the ability of our server to access services such as AFS which can not be authenticated against using the Windows password hash alone. Performance on our service has been drastically improved since the implementation of FOKSTRAUT.
URL http://www.usenix.org/events/lisa2000/full_papers/beck/beck_html/
  http://www.ualberta.ca/~sholstea/patches.tar Patches against Samba 2.2.4
Email Steve Holstead Steve.Holstead@ualberta.ca
  Robert Beck beck@bofh.ucs.ualberta.ca or beck@obtuse.com
Advantages: - Password not sent over network in plain text - In use for several years with a large number of clients - Has advantages other than secure AFS login - Seems to be under active development - Support for automatic reauthentication before token lifetime ends recently added - Requires no changes to Windows Clients. This is a unique feature of this method. - Everything is under BSD style license terms Disadvantages: - Requires some out-of-band secure infrastructure for users to change their passwords. - Authors mention using a simple script on a login server in which a user can make an SMB connect and authenticate themselves. Unsure of the security of this solution. - Another possibility would be a web application behind an SSL server running on the same host as the Samba server. - Passwords must be stored in cleartext on the Samba server. ## New: More secure options ### Samba 3 built-in AFS support It looks like Samba 3.0.4 has built-in AFS support (perhaps only for the Kerberos 4 kaserver on GNU/Linux with [[OpenAFS]] however). The relevant configure option looks like: --with-fake-kaserver Include AFS fake-kaserver support (default=no) References: - - - - [http://marc.theaimsgroup.com/?l=samba&m=108238783519493&w=2](http://marc.theaimsgroup.com/?l=samba&m=108238783519493&w=2) - [http://marc.theaimsgroup.com/?l=samba&m=108119099330691&w=2](http://marc.theaimsgroup.com/?l=samba&m=108119099330691&w=2) - Also based on it looks like Samba 3.0.5 will have support to display and set AFS acls via the NT security editor. Here are some relevant comments from the Samba 3.0.4 code (author's homepage is at ): ./source/lib/afs.c: /* This routine takes a radical approach completely bypassing the Kerberos idea of security and using AFS simply as an intelligent file backend. Samba has persuaded itself somehow that the user is actually correctly identified and then we create a ticket that the AFS server hopefully accepts using its KeyFile that the admin has kindly stored to our secrets.tdb. Thanks to the book "Network Security -- PRIVATE Communication in a PUBLIC World" by Charlie Kaufman, Radia Perlman and Mike Speciner Kerberos 4 tickets are not really hard to construct. For the comments "Alice" is the User to be auth'ed, and "Bob" is the AFS server. */ ./source/lib/afs_settoken.c: /* Put an AFS token into the Kernel so that it can authenticate against the AFS server. This assumes correct local uid settings. This is currently highly Linux and OpenAFS-specific. The correct API call for this would be ktc_SetToken. But to do that we would have to import a REALLY big bunch of libraries which I would currently like to avoid. */ ### kimpersonate The major problem when exporting the AFS filespace read-write to SMB (Windows fileshareing) using Samba is the transfer of the user token to the smb-server. The simple may is to use clear-text password between the Windows client and the samba-server, and then to get tokens for the user with this password. This solution is clearly not acceptable for security aware AFS administrators. On solution is to use \`kimpersonate' + store afs key on fileserver. To obtain the kimersonate code contact "Love H�rnquist-�strand" < lha () stacken ! kth ! se > Here are some references to this technique: - - - - Here is the kimpersonate **README**: kimpersonate ============ kimpersonate takes a keytab/srvtab/AFS KeyFile and impersonates kerberos credental case for a user. See manpage for documentation. Very useful when using with samba. Using kimpersonate with SAMBA ============================= entry in smb.conf root preexec = /usr/samba/bin/su-user-login '%u' Also see the su-user-login file, note that this file contains hacks that parses the %u for samba 3.0-alpha22 something using domain logins. Check that is matches your usage. You need to make sure that somehow the samba does a afs setpag call before calling afslog/aklog. See the patch samba-setpag-patch-linux-and-freebsd above. Here is a text rendition the kimpersonate-1.0 **man page**: KERBEROS(SECTION) LOCAL KERBEROS(SECTION) NAME kimpersonate - impersonate a user when there exist a srvtab, keyfile or KeyFile SYNOPSIS kimpersonate [-s string | --server=string] [-c string | --client=string] [-k string | --keytab=string] [-4 | --krb4] [-5 | --krb5] [-e integer | --expire-time=integer] [-a string | --client-address=string] [-t string | --enc-type=string] [-f string | --ticket-flags=string] [--verbose] [--version] [--help] DESCRIPTION The kimpersonate program create a "fake" ticket using the service-key of the service, the service key can be read from a Kerberos 5 keytab, AFS KeyFile or (if compiled with support for Kerberos 4) a Kerberos 4 srvtab. Supported options: -s string, --server=string name of server principal -c string, --client=string name of client principal -k string, --keytab=string name of keytab file -4, --krb4 create a kerberos 4 ticket -5, --krb5 create a kerberos 5 ticket -e integer, --expire-time=integer lifetime of ticket in seconds -a string, --client-address=string address of client -t string, --enc-type=string encryption type -f string, --ticket-flags=string ticket flags for krb5 ticket --verbose Verbose output --version Print version --help FILES Uses /etc/krb5.keytab, /etc/srvtab and /usr/afs/etc/KeyFile when avalible and the the -k is used with appropriate prefix. EXAMPLES kimpersonate can be used in samba root preexec option or for debugging. kimpersonate -s host/hummel.e.kth.se@E.KTH.SE -c lha@E.KTH.SE -5 --no- krb4 will create a Kerberos 5 ticket for lha@E.KTH.SE for the host hum- mel.e.kth.se if there exist a keytab entry for it in /etc/krb5.keytab kimpersonate -k krb4:/etc/srvtab -s host/hummel.e.kth.se@E.KTH.SE -c lha@E.KTH.SE --no-krb5 -4 will create a Kerberos 4 ticket for lha@E.KTH.SE for the host hummel.e.kth.se if there exist a srvtab entry for it in /etc/srvtab Note the Kerberos 5 syntax of the server. SEE ALSO kinit(1) AUTHORS Love H�rnquist-�strand < lha () stacken ! kth ! se > Heimdal July 30, 2000 Heimdal ## Random Links - 2002-05 discussion on samba-technical: [http://marc.theaimsgroup.com/?l=samba-technical&m=102214554108308&w=2](http://marc.theaimsgroup.com/?l=samba-technical&m=102214554108308&w=2) - 2004 Samba XP Conference talk - "08 - Volker Lendecke (Samba Team / [[SerNet]]): Samba AFS extensions [30:40 min]" - ## Attachments [[samba-2.2.7-afstoken.patch]] [[samba-2.2.7_afstoken.spec]]