ddwrt + Freeradius + LDAP

ddwrt + Freeradius + LDAP

我正在尝试设置一个 LDAP 服务器来验证多个服务器,例如 ftp 和 radius(甚至可能是 ssh?)

我有一台路由器 (ddwrt),我能够在 freeradius 中使用纯文本密码进行身份验证。现在我想使用 ldap 服务器来存储用户和密码

我已经设置了我的 ldap 服务器,并且可以使用以下命令对其进行身份验证:

kevin@kevin-desktop:~$ radtest ldapuser password123 127.0.0.1 2 testing123
Sending Access-Request of id 182 to 127.0.0.1 port 1812
        User-Name = "ldapuser"
        User-Password = "password123"
        NAS-IP-Address = 127.0.1.1
        NAS-Port = 2
        Message-Authenticator = 0x00000000000000000000000000000000
rad_recv: Access-Accept packet from host 127.0.0.1 port 1812, id=182, length=20

但是当我尝试使用 ddwrt -> freeradius 进行身份验证时,我收到以下消息:

rad_recv: Access-Request packet from host 192.168.11.1 port 52101, id=0, length=129
        User-Name = "ldapuser"
        NAS-IP-Address = 192.168.11.1
        Called-Station-Id = "10da43747fcb"
        Calling-Station-Id = "accf8528974e"
        NAS-Identifier = "10da43747fcb"
        NAS-Port = 49
        Framed-MTU = 1400
        NAS-Port-Type = Wireless-802.11
        EAP-Message = 0x0200000d016c64617075736572
        Message-Authenticator = 0x99372f408b0979fc103af5112b81501a
# Executing section authorize from file /etc/freeradius/sites-enabled/default
+group authorize {
++[preprocess] = ok
++[chap] = noop
++[mschap] = noop
++[digest] = noop
[suffix] No '@' in User-Name = "ldapuser", looking up realm NULL
[suffix] No such realm "NULL"
++[suffix] = noop
[eap] EAP packet type response id 0 length 13
[eap] No EAP Start, assuming it's an on-going EAP conversation
++[eap] = updated
[files] users: Matched entry DEFAULT at line 1
++[files] = ok
[ldap] performing user authorization for ldapuser
[ldap]  expand: %{Stripped-User-Name} -> 
[ldap]  ... expanding second conditional
[ldap]  expand: %{User-Name} -> ldapuser
[ldap]  expand: (uid=%{%{Stripped-User-Name}:-%{User-Name}}) -> (uid=ldapuser)
[ldap]  expand: dc=kevin,dc=local -> dc=kevin,dc=local
  [ldap] ldap_get_conn: Checking Id: 0
  [ldap] ldap_get_conn: Got Id: 0
  [ldap] attempting LDAP reconnection
  [ldap] (re)connect to 192.168.11.21:389, authentication 0
  [ldap] bind as cn=admin,dc=kevin,dc=local/pwd to 192.168.11.21:389
  [ldap] waiting for bind result ...
  [ldap] Bind was successful
  [ldap] performing search in dc=kevin,dc=local, with filter (uid=ldapuser)
[ldap] No default NMAS login sequence
[ldap] looking for check items in directory...
  [ldap] userPassword -> User-Password == "{SSHA}fqS7t/ZXimCnTgsXcsGDQF9WP+atmjVG"
  [ldap] userPassword -> Password-With-Header == "{SSHA}fqS7t/ZXimCnTgsXcsGDQF9WP+atmjVG"
[ldap] looking for reply items in directory...
  [ldap] ldap_release_conn: Release Id: 0
++[ldap] = ok
++[expiration] = noop
++[logintime] = noop
[pap] WARNING: Auth-Type already set.  Not setting to PAP
++[pap] = noop
+} # group authorize = updated
Found Auth-Type = LDAP
# Executing group from file /etc/freeradius/sites-enabled/default
+group LDAP {
  [ldap] Attribute "User-Password" is required for authentication.
  You seem to have set "Auth-Type := LDAP" somewhere.
  THAT CONFIGURATION IS WRONG.  DELETE IT.
  YOU ARE PREVENTING THE SERVER FROM WORKING PROPERLY.
++[ldap] = invalid
+} # group LDAP = invalid
Failed to authenticate the user.
Using Post-Auth-Type Reject
# Executing group from file /etc/freeradius/sites-enabled/default
+group REJECT {
[eap] Request was previously rejected, inserting EAP-Failure
++[eap] = updated
[attr_filter.access_reject]     expand: %{User-Name} -> ldapuser
attr_filter: Matched entry DEFAULT at line 11
++[attr_filter.access_reject] = updated
+} # group REJECT = updated
Delaying reject of request 0 for 1 seconds
Going to the next request
Waking up in 0.9 seconds.
Sending delayed reject for request 0
Sending Access-Reject of id 0 to 192.168.11.1 port 52101
        EAP-Message = 0x04000004
        Message-Authenticator = 0x00000000000000000000000000000000
Waking up in 4.9 seconds.
Cleaning up request 0 ID 0 with timestamp +9
Ready to process requests.

如何正确设置 openradius 和 openldap?

答案1

这里的关键信息是:

[ldap] 身份验证需要属性“User-Password”。
您似乎在某处设置了“Auth-Type := LDAP”。该配置有误。删除它。您正在阻止服务器正常工作。

我看不到更新部分,但我敢打赌你要么设置了设置身份验证类型为是,或者第 1 行的条目raddb/users包含类似以下内容:

DEFAULT Auth-Type := LDAP

对于任何一种情况,您都应该删除该条目。

通过设置 Auth-Type,您可以强制服务器执行特定类型的身份验证,但该类型的身份验证可能不适合请求中的属性。

关于服务器如何决定使用哪种身份验证方法的描述可在RADIUS 概念FreeRADIUS 维基

对于 EAP 身份验证(这是 DD-WRT 正在尝试的),您需要将 LDAP 和 PAP 模块添加到 的授权部分sites-available/inner-tunnel,并确保您的带标题的密码属性指向正确的 LDAP 属性。

答案2

显然,您必须将密码以明文形式存储在 ldap 服务器上才能使 PEAP 正常工作。

我遵循了本教程(非常基本的设置): https://www.youtube.com/watch?v=weTfRslHhZY

脚步:

在 /etc/freeradius/modules/ldap 中 修改设置:

server = "server.address"
        identity = "cn=admin,dc=example,dc=com"
        password = admin_password
        basedn = "dc=example,dc=com"

在 /etc/freeradius/sites-available/default 中 授权部分:

comment file
uncomment ldap

在 /etc/freeradius/sites-available/inner-tunnel 中

授权部分:

comment file
uncomment ldap

验证部分:取消注释:

Auth-Type LDAP {
        ldap
}

他们忽略了你必须以明文形式保存密码的事实,我在这里发现了这一点:

http://tech.sybreon.com/2011/01/18/freeradius-openldap-dd-wrt/

显然,您不能从一个简单的组织组创建一个 posix 帐户,您必须从我从这里获得的 posix 组创建它:

http://www.linuxquestions.org/questions/linux-networking-3/can't-create-ldap-entries-with-phpldapadmin-272376/

最后我不得不使用 jxexplore 和 phpldapadmin 来添加我的用户,因为 jxexplore 不喜欢添加纯文本密码。只需在 jxexplore 上创建没有密码的帐户,然后在 phpldapadmin 中将密码添加到用户即可。(有机会时我会更新此内容)

相关内容