The FreeBSD Diary | 
![]()  | 
	(TM) | I remember  | 
| 
 
Samba authentication through PAM with MySQL --- by Randall S. Ehren
31 January 2001
 
     | 
  
| 
	Ed. note: Randall actually wrote this article back in November, but I've only just put
    it on the site today.  Note: this assumes you have Samba, mySQL and pam_mysql already installed and running on FreeBSD 4.0 or greater The following describes how to setup Samba, PAM, and mySQL such that Samba users are authenticated through MySQL using PAM. You can obtain pam_mysql from the link above, or you can install it from the ports:  by: randall s. ehren  | 
  
| 
     Step 1: Configure MySQL 
     | 
  
The following inserts the root user and a sample user both with a password of
    "secretpw". The password encryption is done via MySQL's ENCRYPT function. insert
    the following SQL:
     | 
  
| 
     Step 2: Configure PAM 
     | 
  
pam_mysql has the following configuration options available:(options in parentheses
    are defaults) 
 Append the following to your /etc/pam.conf file samba auth required pam_mysql.so user=root passwd=secretpw -> db=samba_auth table=users usercolumn=login crypt=1 samba account required pam_mysql.so user=root passwd=secretpw -> db=samba_auth table=users usercolumn=login crypt=1 samba password required pam_mysql.so user=root passwd=secretpw -> db=samba_auth table=users usercolumn=login crypt=1 samba session required pam_mysql.so user=root passwd=secretpw -> db=samba_auth table=users usercolumn=login crypt=1  | 
  
| 
     Step 3: Configure Samba 
     | 
  
the following is a sample smb.conf file 
      
     | 
  
| 
     Step 4: Test 
     | 
  
Make sure MySQL and Samba are running. If Samba was running before restart it. Create
    a unix user called "sample" and login to that account. Use smbclient to test by
    doing the following: % smbclient \\\\localhost\\sample smbclient will then ask for a password, use 'secretpw', or whatever you made the password, then see if it works. You should be able to do an 'ls', 'mkdir', or 'cd' when you are in smbclient. You should also test this out on a Windows machine to make sure it works. If you aren't using Windows NT or 2000 make sure you 'log-in' to the machine as 'sample'.  |