Using Samba on Debian Linux
Posted by ltackmann on Thu 26 Jan 2006 at 10:29
This article will show you how to install Samba 3.X on Debian Linux 3.1 (Sarge) and make it authenticate against a Windows server running Active Directory. It is not intended on replacing the actual official Samba 3 manual - which is a quite good read anyway.
Core software
I will show two ways of installing Samba: using apt or directly from source in either case make sure apt's package index files are synchronized:apt-get update apt-get upgradeTo install from apt run:
apt-get install samba smbclient winbind krb5-doc krb5-user \ krb5-configTo compile Samba yourself you need to have MIT Kerberos and OpenLDAP installed:
apt-get install libkrb53 libcupsys2-gnutls10 libldap2 \ libldap2-dev libkrb5-dev krb5-doc krb5-user \ krb5-configThen grap the latest version of the Samba source (for this article we will use samba-3.0.9.tar.gz), and do:
tar zxvf samba-3.0.9.tar.gz -C /tmp/ cd /tmp/samba-3.0.9/source ./configure \ --prefix=/usr \ --localstatedir=/var \ --with-configdir=/etc/samba \ --with-privatedir=/etc/samba \ --with-fhs \ --with-quotas \ --with-smbmount \ --with-pam \ --with-pam_smbpass \ --with-syslog \ --with-utmp \ --with-sambabook=/usr/share/swat/using_samba \ --with-swatdir=/usr/share/swat \ --with-shared-modules=idmap_rid \ --with-libsmbclient \ --with-automount \ --with-msdfs \ --with-ads \ --with-winbind \ --with-winbind-auth-challenge \ --with-manpages-langs=en \ --with-idmap \ --with-acl-support \ --with-ldap make make install
Windows server setup
Install a Windows server and make it act as a domain controller (see this guide for pointers on setting up a domain controller). I will use the followng server setup:- Domain administrator acount on Windows server: administrator>
- Domain name: testdomain
- Fully qualified domain name: testdomain.local
- Hostname of Windows domain controller: win2003test
- IP address of Windows domain controller: 192.168.1.101
Network setup
We need to make sure that DNS is working properly on the server running Samba, this is done by making the Windows Domain controller the default DNS server. To do this I substitute my DNS configuration in /etc/resolve.conf with the folowing:search testdomain.local nameserver 192.168.1.101If you have more than one DNS server in your domain, then also add them here. Test DNS using:
nslookup win2003test > Server: 192.168.1.101 > Address: 192.168.1.101 > Name: win2003test.testdomain.local > Address: 192.168.1.101Test reverse lookup using:
host 192.168.1.101 > 101.1.168.192.in-addr.arpa domain name pointer > win2003test.testdomain.local.If for some reason any of these two test fails, then go through your network setup and this section again. Your DNS must be correctly configured in order to run Samba successfully with Active Directory.
Kerberos setup
We will have to configure Kerberos (or you could avoid this by setting the password server in /etc/samba/smb.conf, to the PDC emulator but then you would be talking old school NTLM with the domain controller). To get real AD working add the folowing lines to /etc/krb5.conf:
[realms]
TESTDOMAIN.LOCAL = {
kdc = win2003test.testdomain.local
admin_server = win2003test.testdomain.local
}
Then do:
kinit administrator@TESTDOMAIN.LOCALThe syntax is kinit user@REALM, where REALM is your Active Directory domain name and must be all uppercase. If you do not use all uppercase for the realm, you'll either receive this error: kinit(v5): Cannot find KDC for requested realm while getting initial credentials or this error: kinit(v5): KDC reply did not match expectations while getting initial credentials. You can test your kerberos setup by issuing
klistIf it reports that you have no keys in the cache then something is wrong. In the event that you recive: kinit(v5): Clock skew too great while getting initial credentials then make sure that the clock synchronisation between your Windows Server and your Linux server is within five minutes. If the time is off by more then the two servers will unable send ticket information to each other.
Optional: Use a NTP Server
One way to solve the clock synchronisation problem is to use a time server (you might even want to use your active directory server(s)). Using a NTP server is optional and not strictly required in order to run a Samba in an AD, but anyway here is how it is done. First install the required ntp packages:apt-get install ntpdateThen add your favorite time server(s) to '''/etc/ntp.conf''', and execute:
/etc/init.d/ntpdate restart
Samba setup
To connect up to your domain create: /etc/samba/smb.conf and add:[global] security = ads password server = win2003test encrypt passwords = yes workgroup = testdomain realm = TESTDOMAIN.LOCAL netbios name = temporay idmap uid = 10000-20000 idmap gid = 10000-20000 winbind enum users = yes winbind enum groups = yes winbind use default domain = YesIn workgroup insert the domain name, realm should be set to the fully qualified domain name (uppercase). Insert the name of the Windows server to authenticate against in the password server field. We are now ready to start the needed services:
smbd nmbdTo join the domain in the default organisation unit do:
net ads join -W testdomain -S win2003test -U administratoror use another unit like this:
net ads join Denmark\/Copenhagen\/Computers -W testdomain \ -S win2003test -U administratorNow check if everything works by issuing the folowing commands:
- Test domain computer account: net ads testjoin.
- Test winbindd: wbinfo -u to list AD users and wbinfo -g for groups.
- Test connection to a remote Windows server from the Samba server: smbclient -L //win2003test -k.
- Run wbinfo -t it should return: checking the trust secret via RPC calls succeeded, otherwise you have done somthing wrong (use testparm -v to check your Samba configuration).
I just discovered some batly formated html (the Windows admin account is "administrator" not "administrator>") and a couple of spelling mistakes. I have fixed them in the version I originally posted on my blog, but have been unable to update the one here.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
deb http://www.backports.org/debian/ sarge-backports main contrib non-free
and just install latest samba from backports
#aptitude update
#aptitude install samba
wbr, eugene v. samusev
[ Parent | Reply to this comment ]
Sarge is shipped with version 3.0.14a and on samba.org there is version 3.0.21a available.
Thanks
Markus
[ Parent | Reply to this comment ]
Regards.
Lars Roland
[ Parent | Reply to this comment ]
thanks for the clarification.
Which bugs are in the sarge samba version?
Do they taint the ADS connectivity?
Greets
Markus
[ Parent | Reply to this comment ]
Regards
Lars Roland
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
checking the trust secret via RPC calls failed
error code was NT_STATUS_INTERNAL_ERROR (0xc00000e5)
Could not check secret
[ Parent | Reply to this comment ]
wbinfo -t
checking the trust secret via RPC calls failed
error code was (0x0)
Could not check secret
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
setenforce 0 on bin/bash shell
and then restart winbind servies.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Fredy Gonzales P.
fredyg@negosat.com
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Everything works fine but when I open \\myserver from Windows it asks for Username and Password but I want it to authenticate against my ADS.
But its a very nice and easy to untderstand Tutorial, thanks a lot!
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
We find this article very useful in installing samba on debian system.
But we have faced a problem while installing, that is when we issue apt-get to install the required debian packages, due to a dependancy it automatically installs postgresql-7.5. But we are already using postgresql-7.4 and we need to install samba keeping our existing postgresql-7.4 version. If somebody has the packages which can work with postgresql-7.4, please share that information with us.
Thanks in advance,
Amal.
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
[ Send Message | View debstar's Scratchpad | View Weblogs ]
Good article. I read the fine manual but your article is straightforward.
For me, I had to set :
winbind separator = +
to avoid some errors from winbind. However, when I want to mount some shares I got this error message :
cli_negprot: SMB signing is mandatory and we have disabled it.
even if I set :
client signing = mandatory
Do you have an advice for this?
NMC
RATOANDROMANANA Nirina Michel
[ Parent | Reply to this comment ]
regards
Ethan
[ Parent | Reply to this comment ]
First of are the PAM configs /etc/pam.d/common-*, there are a few entries you need to make,
in each of the common-* config files add the following lines,
auth sufficient pam_winbind.so use_first_pass
account sufficient pam_winbind.so
The next thing to update is the /etc/nsswitch.conf
passwd: winbind compat
shadow: winbind compat
group: winbind compat
The last thing I found I needed to do was to use the `chgrp` to change the group ownership of the share, i.e., the path in the share in the smb.conf file, to use an AD group.
This one was took me a little longer to figure out, but there are two ways this can look depending on the smb.conf entries.
If winbind use default domain = Yes then your AD groups are as they appear when browsing through AD. So I used
chgrp "Domain Admins" /home/adminshare
If winbind use default domain = NO then your AD groups may need the domain prefixed to the group, assuming your domain is TEST.COM
chgrp "TEST+Domain Admins" /home/adminshare
If you are unsure of how winbind reads or browses the AD you can simply just use wbinfo -g and the list is returns is the format you should use.
You may get an error that the user or group doesn't exist. This means that the PAM and nsswitch are not set up properly.
The last thing to make sure all works it to use, again assuming TEST.COM,
smbclient //[server]/[share] -U test/joe
this should promt for a password and when successful show smb:>.
I received two different types of errors,
NT_STATUS_LOGON FAILURE, this was when it was not able to find the user in AD. It was usually caused by a syntax error on my part. It means it either can't connect or it can't find the user.
NT_STATUS_ACCESS_DENIED, this was when I didn't have access to the share. This was a good error because it meant everything was working correctly with AD and it became a permissions issue.
I may have left something out, I wrote this from memory mostly. Let me know if it helps.
Peter
[ Parent | Reply to this comment ]
aptitude install libpam-dev
another advance seems to be the ability to automatically update dns entries on the ms dns server if you use the brandnew :) 3.0.25 samba release.
./configure --with-dnsupdate
thanx alot for the great tutorial!
ben
[ Parent | Reply to this comment ]
aptitude install uuid-dev
cheers
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
I got an error message after tar the package.
configure: error: expected an absolute directory for --localstatedir: var.
Could you give me a hand?
Thanks!
Xinkang
[ Parent | Reply to this comment ]
[ Parent | Reply to this comment ]
Especially the fact that it's just a full-Debian-compliant-howto is fantastic. Thanks for it!
For people interested, I wrote a Add a Debian Linux Samba 3 server to your Windows NT4 domain HOWTO. For the good, old, (and still running) NT4 domains, the Debian way ;)
[ Parent | Reply to this comment ]