maalth wrote:How to integrate Samba (file sharing) using Active Directory for authentication (basic stuff).- Updated 13 Apr 2004.
Alright, I'll have to go on my notes, I did this on Thanksgiving Day, so I may not remember everything I did. Anyway, here goes:
- Active Directory should already be implemented and working. If you need help, there's plenty of help on the net.
- Your Windows system should be secured and patched.
- You have Gentoo Linux installed of course
- With the config files, you need to change example.com to match your domain.
Okay, now the basics are done, let's begin the install process.
Step 1: Emerge openldap. No configuration is necessary. However, AD support will not be compiled into samba without it.
Step 2: Emerge mit-krb5. Configure the file /etc/krb5.conf as follows:
Code: Select all
[libdefaults]
default_realm = EXAMPLE.COM
[realms]
EXAMPLE.COM = {
kdc = adserver.example.com
}
Add this line to /etc/hosts:
Code: Select all
1.2.3.4 adserver.example.com adserver
You need this to make sure you can connect to the AD server, even when DNS is down.
Notes about this config file, do NOT change the case of EXAMPLE.COM because you will get the following error message:
"Cannot find KDC for requested realm while getting initial credentials". Also, do NOT comment the config file because the kerberos client will not read the config file correctly.
Step 3: We will stop here and test kerberos to ensure you can see the AD domain type in this command:
It will ask for the password; if you type in correctly; then you will be returned to the prompt which means it worked. Pat yourself on the back. You've done the easy part!
Step 4: We are now going to emerge samba. You can do this one of two ways:
- Add kerberos and ldap to your USE flags make.conf file. Emerge samba using the following command: OR
- Type in the following command:
IMPORTANT: kerberos and ldap MUST be included, winbind will NOT work without those flags!
Use the command
The resulting line should look similar to this (this is on my system):
Code: Select all
[ebuild R ] net-fs/samba-3.0.2a -acl +cups +kerberos +ldap +mysql -oav +pam +python +readline +xml 127 kb
Simply put, pick option 1 or 2; samba takes a little time to compile and install. Once samba is installed, you need to configure it. You can use this example samba file:
Code: Select all
# Separate domain and username with '+', like DOMAIN+username
[global]
netbios name = SERVERNAME <- I recommend the same name as the server.
socket options = TCP_NODELAY SO_RCVBUF=16384 SO_SNDBUF=16384 <- Tweak this to get the best speed out of your connection
idmap uid = 10000-20000 <- This is for mapping uids between linux server and AD
winbind enum users = yes <- This allows you to bind users.
winbind gid = 10000-20000 <- This is for mapping gids between linux server and AD
workgroup = WORKGROUP <- Change to match the NETBIOS name of the AD domain.
os level = 20 <- This is for the master browser priority.
winbind enum groups = yes <- This allows you to use the Active Directory groups
socket address = 1.2.3.4 <- Change this to match the IP address or remove it to listen to all addresses.
password server = * <- I recommend this if you have more than one server; I do in my case.
preferred master = no <- You do NOT want to be a master browser.
winbind separator = + <- See the first line comment.
max log size = 50 <- In K
log file = /var/log/samba3/log.%m <- This allows logging activities for each machine.
encrypt passwords = yes <- Active directory does NOT accept plaintext passwords.
dns proxy = no <- You don't want anything to do with DNS.
realm = EXAMPLE.COM <- This is for kerberos.
security = ADS <- Active directory server provides security for the shared resources.
wins server = 1.2.3.4 <- Change to IP address of your installed WINS server
wins proxy = no <- You don't want to proxy WINS either.
# Shares section
[mp3] <- Name of the share.
comment = MP3 Repository <- A comment...
writeable = yes <- If you want users to update the directory
path = /home/mp3 <- Where is the share on the linux server
force user = mp3 <- Should be the name of the user who is responsible for the share.
Step 5: Fire up samba; check to make sure it's running.
Step 6: Join your samba server to your domain by typing in this command:
It will ask you for a password, type your password in. If you typed it in correctly, you will see the message that says: Joined 'SERVERNAME' to realm 'EXAMPLE.COM.' If you check your AD server, the machine account for your system will appear under computers.
Step 7: We are going to test winbind to ensure windows authentication does indeed work. Winbind allows you to use Active Directory for user authentication (see link 2 for more info). The steps for using and testing winbind are gleaned from link 2.
You need to edit the file /etc/nsswitch.conf You need to change two lines to look like this (other lines removed to keep this post short as possible):
Code: Select all
passwd: compat winbind
shadow: compat
group: compat winbind
Let's test the winbindd daemon before we make it permanent. Fire up winbindd by typing
You can also make winbindd run as two processes (which is faster; but for these purposes, let's run it as one). Winbindd runs in dual daemon mode by default.
Since there is no visual confirmation whether or not it's running, you can check with ps to ensure it is indeed running.
Code: Select all
ps -ae | grep winbindd
The results should be something similar to this:
13324 ? 00:04:23 winbindd
13325 ? 00:00:00 winbindd
If you get an error message instead of the above, then you didn't compile kerberos and ldap support in and need to do that before anything will work
Let's make sure we can see the contents of Active Directory. Type in this command:
This is the results from my system (changed for integrity), yours should be similar.
Code: Select all
EXAMPLE+test <- test account on AD
EXAMPLE+test2 <- test account on AD
EXAMPLE+Administrator
EXAMPLE+Guest
EXAMPLE+TsInternetUser
EXAMPLE+krbtgt
EXAMPLE+MACHINE1$ <- test machine 1
EXAMPLE+MACHINE2$ <- test machine 2
EXAMPLE+MACHINE3$ <- test machine 3
EXAMPLE+HOST/servername <- samba machine
EXAMPLE+DOMAINCONTROLLER$
To see the groups, use this command:
You should see a result similar to this:u should see a result similar to this:
Code: Select all
EXAMPLE+Domain Computers
EXAMPLE+Domain Controllers
EXAMPLE+Schema Admins
EXAMPLE+Enterprise Admins
EXAMPLE+Cert Publishers
EXAMPLE+Domain Admins
EXAMPLE+Domain Users
EXAMPLE+Domain Guests
EXAMPLE+Group Policy Creator Owners
EXAMPLE+DnsUpdateProxy
We can get a username from both the local linux server and the Active Directory server by typing in this command:
I will not post the results of this command for security reasons, but you should see a list of local users with the Active Directory users appended.
For groups, type in getent group
I will not post the results of this command for security reasons, but you should see a list of local groups with the Active Directory groups appended.
I would suggest reading the info in link 2 for more things you can do with other authentication with AD.
If everything has worked as above, pat yourself on the back! Good job!
Step 8: If you didn't configure a share yet; do so now. You need to restart samba if you created a share.
You should join any machine you want to access the samba resources to your Active Directory Domain. Use a machine that's joined to the AD domain to see if your share appears via network neighborhood.
If you want samba and winbind to run on startup, type in the following commands:
Code: Select all
rc-update add samba default
rc-update add winbind default
That's it for now, any problems, something is unclear, or questions, let me know and I will do my best to help you.
Resources:
The samba/ADS howto:
http://us1.samba.org/samba/docs/man/dom ... ads-member
Helpful info for winbind:
http://us1.samba.org/samba/docs/man/winbind.html[b][/b]