个人工具

UbuntuHelp:ADAuthentication

来自Ubuntu中文

Wikibot讨论 | 贡献2008年10月19日 (日) 04:05的版本 (新页面: {{From|https://help.ubuntu.com/community/ADAuthentication}} {{Languages|UbuntuHelp:ADAuthentication}} === Goal === To configure a Linux box (in this case Ubuntu 8.04) to authenticate user...)

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航, 搜索

Goal

To configure a Linux box (in this case Ubuntu 8.04) to authenticate user logins and samba users via a separate Active Directory server (in this case tested with Win2K3). This is the process as was used to get a Ubuntu Samba box playing nice-nice with "adserver".

Assumptions

Observe that there's the assumption here that the DNS hostname of your Active Directory box is adserver.example.local and has an ip 192.168.1.2. So naturally, this means you should swap out what I'm calling it here for whatever you've got. Also note that the caps names such as EXAMPLE.LOCAL are required. I forget why, but I'm pretty sure it's explained in one of the reference docs.

Packages

sudo apt-get install krb5-user winbind samba ntp

Edit Config Files

/etc/krb5.conf

[logging]
	default = FILE:/var/log/krb5.log

[libdefaults]
	default_realm = EXAMPLE.LOCAL
	kdc_timesync = 1
	ccache_type = 4
	forwardable = true
	proxiable = true

[realms]
	EXAMPLE.LOCAL = {
		kdc = adserver.example.local
		admin_server = adserver.example.local
		default_domain = EXAMPLE.LOCAL
	}

[domain_realm]
	.adserver.example.local = EXAMPLE.LOCAL
	adserver.example.local = EXAMPLE.LOCAL

smb.conf

[global]
	security = ads
	realm = EXAMPLE.LOCAL
	password server = 192.168.1.2
	workgroup = WORKGROUP
	use kerberos keytab = true
	idmap uid = 10000-20000
	idmap gid = 10000-20000
	winbind enum users = yes
	winbind enum groups = yes
	template homedir = /home/%D/%U
	template shell = /bin/bash
	client use spnego = yes
	client ntlmv2 auth = yes
	encrypt passwords = true
	winbind use default domain = yes
	restrict anonymous = 2

;Communal Files
[files]
   comment = Shared Files Stuff
   path = /Storage/
   writable = yes

;Individual Files - sym link /home/%D to /Storage/ 

nsswitch.conf

passwd:         compat	winbind
group:          compat	winbind
shadow:         compat

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4 wins
networks:       files

protocols:      db files
services:       db files
ethers:         db files
rpc:            db files

netgroup:       nis

ntp.conf

Set time server to the active directory server - sufficiently large clock skews can mess with authentication

...
   server    adserver
...

/etc/pam.d/common-account

account sufficient	pam_winbind.so
account	required	pam_unix.so

/etc/pam.d/common-auth

auth	sufficient	pam_winbind.so
auth	required	pam_unix.so nullok_secure use_first_pass

/etc/pam.d/common-password

password	required	pam_unix.so nullok obscure min=4 max=50 md5
password	optional	pam_smbpass.so nullok use_authtok use_first_pass missingok

/etc/pam.d/common-session

session	required	pam_mkhomedir.so umask=0022 skel=/etc/skel

Make User Home Dir

mkdir /home/WORKGROUP

Work around potential DNS pitfalls

Edit /etc/hosts to contain:

192.168.1.2	 adserver.example.local example.local adserver
'''<local ip>'''	'''<hostname>'''.example.local '''<hostname>'''

Test Kerberos

kinit '''<your username>'''@EXAMPLE.LOCAL

Check that a ticket was issued:

klist

Join the Active Directory Domain

net ads join -U [email protected]

Note that any domain administrator user could be used instead of administrator

Restart key services

/etc/init.d/samba stop
/etc/init.d/winbind stop
/etc/init.d/samba start
/etc/init.d/winbind start

Restart ssh and test login

/etc/init.d/ssh restart

ssh '''<your username>'''@'''<smb server>'''

Allowing sudo for some users

One approach is to add the Active Directory group name of sudoer users to the /etc/sudoers file (of course, you may have to create said group) Example /etc/sudoers:

%BUILTIN\administrators ALL=(ALL) ALL
%"domain admins" ALL=(ALL) ALL

References

Largely derived from: [| this page]

What's next

Once this is working Apache2 user authentication via Active Directory can quite easily be added on. Check out the page here.