一、服務器要求
Radius服務器:centos6.6、hostname、selinux disabled、stop iptables
AD域服務器:Windows Server 2008 R2 Enterprise、AD-host.example.com(提前搭建好的AD域)
freeradius版本大小:2.2.6
目的:只做用戶名密碼的認證
域名先解析:#vim /etc/hosts
IP AD-host.example.com
IP hostname
二、RADIUS的工作過程
1. 用戶輸入用戶名密碼等信息到客戶端
2. 客戶端產生一個接入請求報文到RADIUS服務器,其中包含了用戶名,密碼,客戶端ID和用戶訪問端口的ID,密碼都是經過MD5加密的。
3. RADIUS服務器對用戶進行認證
4. 如果認證成功,RADIUS服務器想客戶端發送允許接入包,否則就發送拒絕接入包。
5. 若客戶端接受到允許接入包,則為用戶建立連接,對用戶進行授權和提供服務;若接受到拒絕接入包,則拒絕用戶接入請求。
6. 客戶端發送計費請求給RADIUS服務器
7. RADIUS服務器接受到計費請求包后開始計費,並向客戶端回送開始計費的響應包。
8. 用戶斷開連接,客戶端發送停止計費包給RADIUS服務器
9. RADIUS服務器接收到停止計費包后停止計費,並向客戶端發送停止計費響應包,完成該用戶的一次計費,記錄計費信息。
三、安裝freeradius與AD結合需要用的組件
#yum install samba krb5-server freeradius freeradius-utils freeradius-mysql
四、配置samba
samba作為freeradius和AD域溝通的橋梁裝在freeradius服務器上
#vim /etc/samba/smb.conf
[global]
workgroup = example
# ----------------------- Domain Members Options ------------------------
security = ads #ads設置必須在這項里面
realm = example.com
password server = (AD-IP)
samba的ads模式(活動目錄模式):
這是linux系統samba服務器的一種新型工作模式,用於把samba服務器加入到windows服務器活動目錄域中,並具備活動目錄域控制器的功能。這時samba服務器就相當於一台域控制器了,可以自己使用活動目錄中的賬戶數據庫對用戶的訪問進行身份驗證。
#/etc/init.d/smb start
#/etc/init.d/nmb start
#chkconfig nmb on
#chkconfig smb on
五、修改系統賬號驗證
# vim /etc/nsswitch.conf(名字服務切換配置)
此文件規定通過哪些途徑以及按照什么順序通過這些途徑來查找特定類型的信息。還可以指定某個方法奏效或者、失效時系統將采取什么動作。配置格式如下:
Info:method[[action]] [method[[action]]…]
Info指定該行所描述的信息的類型,method位用來查找該信息的方法,action是對前面的method返回狀態的響應。
工作原理:當需要提供nsswitch.conf文件所描述的信息的時候,系統將檢查含有適當info字段的配置行。它按照從左向右的順序開始執行配置中指定的方法。在默認情況下,如果找到期望的信息,系統將停止搜索。如果沒有指定的action,那么當某個方法未能返回結果時,系統就會嘗試下一個動作。有可能搜索結束都沒找到想要的信息。
nsswitch.conf文件末尾添加以下幾行:
passwd: files winbind
shadow: files winbind
group: files winbind
protocols: files winbind
services: files winbind
netgroup: files winbind
automount: files winbind
六、設置kerberos認證機制
#vim /etc/krb5.conf
在配置ads模式samba服務器時/etc/krb5.conf 配置文件是必須配置的。它作為kerberos身份驗證模塊,可以使samba服務器對windows AD域有更好的支持。
[logging]
default = FILE:/var/log/krb5libs.log
kdc = FILE:/var/log/krb5kdc.log
admin_server = FILE:/var/log/kadmind.log
[libdefaults]
default_realm = EXAMPLE.COM
dns_lookup_realm = false
dns_lookup_kdc = false
ticket_lifetime = 24h
renew_lifetime = 7d
forwardable = true
[realms]
EXAMPLE.COM {
kdc = AD-host.example.com
}
[domain_realm]
.example.com = EXAMPLE.COM
example.com = EXAMPLE.COM
七、配置KDC服務
# vim /var/kerberos/krb5kdc/kdc.conf
[realms]
EXAMPLE.COM = {
#master_key_type = aes256-cts
acl_file = /var/kerberos/krb5kdc/kadm5.acl
dict_file = /usr/share/dict/words
admin_keytab = /var/kerberos/krb5kdc/kadm5.keytab
supported_enctypes = aes256-cts:normal aes128-cts:normal des3-hmac-sha1:normal arcfour-hmac:normal des-hmac-sha1:normal des-cbc-md5:normal des-cbc-crc:normal des-cbc-crc:v4 des-cbc-crc:afs3
}
八、測試samba和kdc是否可以正常通信
#kinit administrator@example.com
這一步回車正常情況下是會讓輸入用戶的密碼Password for administrator@example.com:
安裝kerberos軟件后,必須配置KDC服務器。KDC提供頒發憑證的服務。
#/etc/init.d/winbind start
#chkconfig winbind on
九、將freeradius加入域並測試是否同步域賬號
#net rpc join –U administrator
Password:輸入密碼
。。。
Joined domain test
#wbinfo –t 檢查rpc鏈接是否成功
。。。
checking the trust secret via RPC calls succeeded
# wbinfo –u 獲取用戶信息
一堆用戶出現
#wbinfo –g 獲取組信息
一堆組出現
#getent passwd
一堆不知道什么用戶密碼出現
十、freeradius服務配置
freeradius的配置文件幾乎都在/etc/raddb目錄下
#vim /etc/radius.conf 這個文件好像也沒什么好改的
#vim /etc/users
DEFAULT Auth-Type = ntlm_auth 這個要打開
#vim /etc/clients.conf 設置客戶端信息
client IP(anyconnect) {
secret = cisco
shortname = freeRADIUS
nastype = other
}
#vim /etc/raddb/sites-available/default
authorize { ntlm_auth } //最后一行添加
authenticate {Auth-Type ntlm_auth { ntlm_auth } }
#vim /etc/raddb/sites-available/inner-tunnel
authorize { ntlm_auth }
authenticate {Auth-Type ntlm_auth { ntlm_auth } }
#vim /etc/raddb/sites-enabled /default
authorize { ntlm_auth } //最后一行添加
authenticate {Auth-Type ntlm_auth { ntlm_auth } }
#vim /etc/raddb/sites-enabled/inner-tunnel
authorize { ntlm_auth }
authenticate {Auth-Type ntlm_auth { ntlm_auth } }
最后這兩個文件夾的四個文件是映射的關系。但是本服務器未做映射,自便
#/etc/raddb/modules/ldap
ldap {
server = “IP(AD的IP地址)”
identity = "CN=zabbix,ou=特殊賬戶,dc=example,dc=com"
password = "password"
basedn = "DC=example,DC=com"
filter = "(uid=%{%{Stripped-User-Name}:-%{User-Name}})"
}
#vim /etc/raddb/modules/ntlm_auth
exec ntlm_auth {
wait = yes
program = "/usr/bin/ntlm_auth --request-nt-key --domain=EXAMPLE.COM --username=%{mschap:User-Name} --password=%{User-Password}"
}
#vim /etc/raddb/modules/mschap 編輯mschap模塊,使用ntlm_auth做MS_CHAP認證
ntlm_auth = "/usr/bin/ntlm_auth --request-nt-key --username=%{mschap:User-Name:-None} --domain=%{%{mschap:NT-Domain}:-EXAMPLE.COM} --challenge=%{mschap:Challenge:-00} --nt-response=%{mschap:NT-Response:-00}"
#vim /etc/raddb/policy.conf 修改策略
policy {
ntlm_auth.authorize {
if(!control:Auth-Type && User-Paaword){
update control {
Auth-Type := ntlm_auth
}
}
}
}
十一、最終測試
#chown –R root.radiusd /var/lib/samba/winbindd_privileged
#/etc/init.d/winbind restart
#radiusd –X 開啟freeradius的debug模式
#radtest –t mschap 域賬號 ‘密碼’ localhost 0 testing123
用域賬號密碼本地測試,如果收到Access-Accept的回復,說明freeradius和AD域整合成功!
此次整合是為anyconnect vpn做准備,和anyconnect vpn正常通信的因素:
1) 賬號要是域賬號里面存在的
2) freeradius服務器要設置client端信息
3) 認證協議要統一,此次認證使用的協議是ms-chap