Monday, 12 August 2013

Samba 4 Active Directory

Linux On A Server

High Availability, Clustering & Server configuration

Menu
SKIP TO CONTENT
ABOUT
Samba 4 Active Directory – My first (successfully) test
Posted on March 2, 2013 by Christian Gebler • 6 Comments
It’s time to say goodbye Windows-Server Active Directory Domain Controller and please welcome Samba4! Now after six years of the first preview, you can install the first implementation of a free Active-Directory. I tested it at home and show you in the following article what I had to do to make it work…at the end it was possible for me to join the Domain with my Windows 7 computer. :-)
For my tests I used my Raspberry Pi, that means my little tutorial is based on a Debian Linux called “Raspbian”, but I also tested it later successfully on a virtual “Ubuntu 12.04 LTS” server. I assume that you have an advanced knowledge about Linux and the Active-Directory and that you know what you want to do, otherwise I think you would not be here! ;) So I will not explain every step and command in detail!
Part of the Samba4 AD will be:
A basically Network configuration
BIND Server
Kerberos
NTP Server
Okay, let’s join a Samba4 AD Domain!

Step 1 – Network configuration
You need a solid network configuration, at first a static IP:
/etc/network/interfaces
1 auto eth0
2 iface eth0 inet static
3        address 192.168.0.87
4        netmask 255.255.255.0
5        gateway 192.168.0.1
6        dns-nameserver 192.168.0.87
7        dns-search raspberry.local
The best friend of the AD is DNS, so check your resolv.conf file, there should be the local IP adress, BIND will run later on our AD-Server:
/etc/resolv.conf
1 nameserver 192.168.0.87
And add your IP in the hosts file:
/etc/hosts
1 127.0.0.1       localhost
2 192.168.0.87    raspberrypi raspberrypi.raspberry.local

Step 2 – Samba
Install the packages and all the dependencies
1 aptitude install samba4 samba4-clients
Now we are able to build the Active Directory, at first delete or move the default configuration file, otherwise the next command will fail while creating a new one.
1 mv /etc/samba/smb.conf /root/backup/
1 /usr/share/samba/setup/provision --realm=raspberry.local --domain=RASPBERRY --adminpass='Password1' --server-role=dc
Your smb.conf should now look like this:
01 # Global parameters
02 [global]
03        server role = active directory domain controller
04        workgroup = RASPBERRY
05        realm = raspberry.local
06        netbios name = RASPBERRYPI
07        passdb backend = samba4
08        server services = +smb -s3fs
09 [netlogon]
10        path = /var/lib/samba/sysvol/raspberry.local/scripts
11        read only = No
12
13 [sysvol]
14        path = /var/lib/samba/sysvol
15        read only = No
I added the parameters “server role” and “server services”, without these parameters I only get an Error:
1 Connection to localhost failed (Error NT_STATUS_CONNECTION_REFUSED)
Restart Samba
1 /etc/init.d/samba4 restart
And check now the created shares on the server:
1 smbclient -L localhost -U%
The ouptut should look like this:
1 Domain=[RASPBERRY] OS=[Unix] Server=[Samba 4.0.0beta2]
2
3        Sharename       Type      Comment
4        ---------       ----      -------
5        netlogon        Disk    
6        sysvol          Disk    
7        IPC$            IPC       IPC Service

Step 3 – Bind DNS
Active Directory goes hand in hand with DNS, many services need it to run correctly, so it is very very important!
1 aptitude install bind9
The only thing we need to do, is to add the following line in the /etc/bind/named.conf.options
1 tkey-gssapi-keytab "/var/lib/samba/private/dns.keytab";
Clients can now automatically update her DNS entries.
Ubuntu runs withe a security software called “App Armor”, there we have to set some rules:
/etc/apparmor.d/usr.sbin.named
1 /var/lib/samba/private/** rkw,
2 /var/lib/samba/private/dns/** rkw,
3 /usr/lib/arm-linux-gnueabihf/samba/bind9/** rm,
4 /usr/lib/arm-linux-gnueabihf/samba/gensec/** rm,
5 /usr/lib/arm-linux-gnueabihf/ldb/modules/ldb/** rm,
6 /usr/lib/arm-linux-gnueabihf/samba/ldb/** rm,
Restart AppArmor now:
1 service apparmor restart
And start bind:
1 service bind9 start

Step 4 – Authenticate with Kerberos
We need Kerberos as the authentication daemon, install it with:
1 aptitude install krb5-user
Enter your realm and the host, then the config-file /etc/krb5.conf should look like this:
1 [libdefaults]
2        default_realm = raspberry.local
3        dns_lookup_realm = false
4        dns_lookup_kdc = true
To test kerberos execute
1 kinit administrator@RASPBERRY.LOCAL
The Domain name needs to be written in uppercase and you should check your ticket with:
1 klist -e

Step 5 – NTP
At least, install ntp, it’s optional but a nice to have to provide the right time on the hosts:
1 aptitude install ntp
The file /etc/ntp.conf wil have some default server, check your ntp server connection with:
1 ntpq -p

Step 6 – Add a user and join the party
Simply add an user with:
1 samba-tool user add USERNAME

That’s it! Now boot your windows or linux client and join the domain.
Please feel free to post your problems and experiences (especially the samba and kerberos config) with Samba4 as a comment! I had some errors that suddenly where solved and I don’t know why…I could not even reproduce them. It would be also interesting to know whether you use it just to test it or on a real production server. Furthermore, if you find some wrong configurations or mistakes in this article just write me a message!

Thanks for your feedback! :-)

Thursday, 20 December 2012

THOUGHTS OF THE DAY


"THOUGHTS OF THE DAY"
Positive thinking gets you closer to success.
" If you can never manage to be happy with where you are at, you will never be happy wherever you go."
--- Written in 2000 by Phillip Bennett --- Georgia

" Many people fail in life, not for lack of ability or brains or even courage but simply because they have never organized their energies around a goal."
--- Elbert Hubbard ---Submitted by Abhijeet Kurkure --- India
This is quote is for people of all ages. It tells us the importance of goals in our life. It tells us goals are the main part of life. Everything is possible when we set a goals in our life and work hard to achieve them.

" Always say thank you for all the things you asked for. They may be granted and sometimes not, but then, having a cool heart makes you think positive that they will be given to you at the right time."
--- Author Unknown --- Submitted by Helen B. Villarino --- Phillipines
Having a nice temperament makes you believe all things really come, if they're meant to.

" Heroes are mere humans who have taken the resolve to go the extra mile when others decided it's enough. Just that extra shove and extra push and you are a celebrated hero of our time."
--- Written in 2007 by Sheunopa Vushemakota

" Peace is the funeral of terrorism."
--- Written in 2007 by Pankaj Mukati
The whole world want to free from terrorism and join the party of peace.

" If I were 'God' I would have but one rule to live on Earth. Before you rest in peace, my friend, live in peace."
--- Written in 2007 by Nicholas K. --- Wales

" The road to achievement starts with action, the road to the truth does not start with a lie."
--- Written in 2007 by B. Gordon G. --- Australia