1安裝軟件:
yum install freeradius freeradius-ldap freeradius-utils -y
2啟動(dòng)服務(wù)
systemctl start radiusd.service
3開(kāi)機(jī)自動(dòng)啟動(dòng)
systemctl enable radiusd.service
4修改配置文件 /etc/raddb/mods-available/ldap主要是ldap部分,其它都是默認(rèn)
[root@10-57-22-55 mods-available]# cat /etc/raddb/mods-available/ldap | grep -v '#' | grep -v ^$
ldap {
server = 'x.x.8.55' #服務(wù)器
port = 389 #端口
identity = 'CN=opsldap,CN=Users,DC=txxxdxx,DC=me' #連接LDAP帳號(hào)
password =xxxxxxxx #連接LDAP密碼
base_dn = 'DC=txxxdxx,DC=me' #dn
sasl {
}
update {
control:Password-With-Header += 'userPassword'
control: += 'radiusControlAttribute'
request: += 'radiusRequestAttribute'
reply: += 'radiusReplyAttribute'
}
edir = no #修改
user {
base_dn = "${..base_dn}"
filter = "(sAMAccountName=%{%{Stripped-User-Name}:-%{User-Name}})" #修改成sAM
#以下用默認(rèn)
sasl {
}
}
group {
base_dn = "${..base_dn}"
filter = '(objectClass=posixGroup)'
membership_attribute = 'memberOf'
}
profile {
}
client {
base_dn = "${..base_dn}"
filter = '(objectClass=radiusClient)'
template {
}
attribute {
ipaddr = 'radiusClientIdentifier'
secret = 'radiusClientSecret'
}
}
accounting {
reference = "%{tolower:type.%{Acct-Status-Type}}"
type {
start {
update {
description := "Online at %S"
}
}
interim-update {
update {
description := "Last seen at %S"
}
}
stop {
update {
description := "Offline at %S"
}
}
}
}
post-auth {
update {
description := "Authenticated at %S"
}
}
options {
chase_referrals = yes
rebind = yes
res_timeout = 10
srv_timelimit = 3
net_timeout = 1
idle = 60
probes = 3
interval = 3
ldap_debug = 0x0028
}
tls {
}
pool {
start = ${thread[pool].start_servers}
min = ${thread[pool].min_spare_servers}
max = ${thread[pool].max_servers}
spare = ${thread[pool].max_spare_servers}
uses = 0
retry_delay = 30
lifetime = 0
idle_timeout = 60
}
}
5在 mods-enabled/ 下執(zhí)行l(wèi)n 注意后面有點(diǎn)
ln -s ../mods-available/ldap .
6在 sites-available/ 下創(chuàng)建 site_ldap
[root@10-57-22-55 sites-available]# cat site_ldap
server site_ldap {
listen {
ipaddr = 0.0.0.0
port = 1833
type = auth
}
authorize {
update {
control:Auth-Type := ldap
}
}
authenticate {
Auth-Type ldap {
ldap
}
}
post-auth {
Post-Auth-Type Reject {
}
}
}
7在 sites-enabled/ 下執(zhí)行l(wèi)n 注意后面有點(diǎn)
ln -s ../sites-available/site_ldap .
重啟服務(wù)器
systemctl restart radiusd.service
測(cè)試命令如下
radtest user password localhost:1833 0 testing123
以下結(jié)果表示成功:Received Access-Accep(密碼帶特殊字符需要用‘’引號(hào)引起來(lái))
[root@10-57-22-55 sites-available]# radtest shanfu.wu 'xxx!*@Txxxdxx' localhost:1833 0 testing123
Sent Access-Request Id 133 from 0.0.0.0:34144 to 127.0.0.1:1833 length 79
User-Name = "shanfu.wu"
User-Password = "xxxxxx"
NAS-IP-Address = 127.0.0.1
NAS-Port = 0
Message-Authenticator = 0x00
Cleartext-Password = "xxxxxx"
Received Access-Accept Id 133 from 127.0.0.1:1833 to 0.0.0.0:0 length 20
以下為密碼錯(cuò)誤Received Access-Reject
[root@10-57-22-55 sites-available]# radtest shanfu.wu xxxxx localhost:1833 0 testing123
Sent Access-Request Id 114 from 0.0.0.0:37246 to 127.0.0.1:1833 length 95
User-Name = "shanfu.wu"
User-Password = "xxxxx"
NAS-IP-Address = 127.0.0.1
NAS-Port = 0
Message-Authenticator = 0x00
Cleartext-Password = "xxxx"
Received Access-Reject Id 114 from 127.0.0.1:1833 to 0.0.0.0:0 length 20
(0) -: Expected Access-Accept got Access-Reject