FreeRADIUS Beginner's Guide

4. Authentication

认证过程:

  • data link layer -> success -> network layer

认证协议:

  • userpassword:
    • PAP
      • (password Authentication protocal)密码认证协议(p2p)
      • client -> (密码明文) -> NAS -> (加密密码) -> RADIUS SERVER
    • CHAP
      • (challenge-handshake authentication protocal)询问交互认证协议
      • NAS -> 重复发送随机间隔的 challenge -> user -> hash identifiter & 明文密码 -> NAS -> 加密密码 -> radius server
    • MS-CHAP
      • 微软chap协议,增强了功能,如用户修改密码,错误消息等.
      • chapv1 & chapv2
      • user -> 包含微软特殊字段NT-Response + 加密密码 -> NAS
      • EAP协议使用MS-CHAP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[root@localhost raddb]# vi /etc/raddb/users
添加以下2行
"tianfei" Cleartext-Password := "passgo"
Reply-Message = "Hello, %{User-Name}"

[root@localhost raddb]# radtest tianfei passgo 127.0.0.1 100 testing123
Sent Access-Request Id 170 from 0.0.0.0:44098 to 127.0.0.1:1812 length 77
User-Name = "tianfei"
User-Password = "passgo"
NAS-IP-Address = 127.0.0.1
NAS-Port = 100
Message-Authenticator = 0x00
Cleartext-Password = "passgo"
Received Access-Reject Id 170 from 127.0.0.1:1812 to 0.0.0.0:0 length 20
(0) -: Expected Access-Accept got Access-Reject
[root@localhost raddb]# radtest tianfei passgo 127.0.0.1 100 testing123
Sent Access-Request Id 155 from 0.0.0.0:44387 to 127.0.0.1:1812 length 77
User-Name = "tianfei"
User-Password = "passgo"
NAS-IP-Address = 127.0.0.1
NAS-Port = 100
Message-Authenticator = 0x00
Cleartext-Password = "passgo"
Received Access-Accept Id 155 from 127.0.0.1:1812 to 0.0.0.0:0 length 36
Reply-Message = "Hello, tianfei"

服务器日志输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Ready to process requests

(0) Received Access-Request Id 155 from 127.0.0.1:44387 to 127.0.0.1:1812 length 77
(0) User-Name = "tianfei"
(0) User-Password = "passgo"
(0) NAS-IP-Address = 127.0.0.1
(0) NAS-Port = 100
(0) Message-Authenticator = 0x5328ee7e1eaa61d3555baa241acb7582
(0) # Executing section authorize from file /etc/raddb/sites-enabled/default
(0) authorize {
(0) policy filter_username {
(0) if (&User-Name) {
(0) if (&User-Name) -> TRUE
(0) if (&User-Name) {
(0) if (&User-Name =~ / /) {
(0) if (&User-Name =~ / /) -> FALSE
(0) if (&User-Name =~ /@[^@]*@/ ) {
(0) if (&User-Name =~ /@[^@]*@/ ) -> FALSE
(0) if (&User-Name =~ /\.\./ ) {
(0) if (&User-Name =~ /\.\./ ) -> FALSE
(0) if ((&User-Name =~ /@/) && (&User-Name !~ /@(.+)\.(.+)$/)) {
(0) if ((&User-Name =~ /@/) && (&User-Name !~ /@(.+)\.(.+)$/)) -> FALSE
(0) if (&User-Name =~ /\.$/) {
(0) if (&User-Name =~ /\.$/) -> FALSE
(0) if (&User-Name =~ /@\./) {
(0) if (&User-Name =~ /@\./) -> FALSE
(0) } # if (&User-Name) = notfound
(0) } # policy filter_username = notfound
(0) [preprocess] = ok
(0) [chap] = noop
(0) [mschap] = noop
(0) [digest] = noop
(0) suffix: Checking for suffix after "@"
(0) suffix: No '@' in User-Name = "tianfei", looking up realm NULL
(0) suffix: No such realm "NULL"
(0) [suffix] = noop
(0) eap: No EAP-Message, not doing EAP
(0) [eap] = noop
(0) files: users: Matched entry tianfei at line 1
(0) files: EXPAND Hello, %{User-Name}
(0) files: --> Hello, tianfei
(0) [files] = ok
(0) [expiration] = noop
(0) [logintime] = noop
(0) [pap] = updated
(0) } # authorize = updated
(0) Found Auth-Type = PAP
(0) # Executing group from file /etc/raddb/sites-enabled/default
(0) Auth-Type PAP {
(0) pap: Login attempt with password
(0) pap: Comparing with "known good" Cleartext-Password
(0) pap: User authenticated successfully
(0) [pap] = ok
(0) } # Auth-Type PAP = ok
(0) # Executing section post-auth from file /etc/raddb/sites-enabled/default
(0) post-auth {
(0) update {
(0) No attributes updated
(0) } # update = noop
(0) [exec] = noop
(0) policy remove_reply_message_if_eap {
(0) if (&reply:EAP-Message && &reply:Reply-Message) {
(0) if (&reply:EAP-Message && &reply:Reply-Message) -> FALSE
(0) else {
(0) [noop] = noop
(0) } # else = noop
(0) } # policy remove_reply_message_if_eap = noop
(0) } # post-auth = noop
(0) Sent Access-Accept Id 155 from 127.0.0.1:1812 to 127.0.0.1:44387 length 0
(0) Reply-Message = "Hello, tianfei"
(0) Finished request
Waking up in 4.9 seconds.
(0) Cleaning up request packet ID 155 with timestamp +6
Ready to process requests
坚持原创技术分享,您的支持将鼓励我继续创作!