答案1
简而言之,
- 您需要指定密码哈希格式,而不是
Cleartext-Password
, 和 - 您需要将设置
auth_goodpass
为auth_badpass
“否”以防止记录密码。
指定哈希格式
正如所述rlm_pap 手册页,有许多密码哈希设置可以代替Cleartext-Password
。让我们举一个简单的例子,MD5-Password
:
#bob Cleartext-Password := "hello"
bob MD5-Password:= "7d793037a0760186574b0282f2f435e7"
Reply-Message := "Hello, %{User-Name}"
您可以轻松生成 md5 密码哈希,如下所示:
$ echo -n world | md5sum | awk '{print $1}'
7d793037a0760186574b0282f2f435e7
$
当我们在我们的服务器上测试它时,我们看到它通过了身份验证:
$ radtest bob world localhost 1 testing123
Sent Access-Request Id 214 from 0.0.0.0:34920 to 127.0.0.1:1812 length 73
User-Name = "bob"
User-Password = "world"
NAS-IP-Address = 127.0.1.1
NAS-Port = 1
Message-Authenticator = 0x00
Cleartext-Password = "world"
Received Access-Accept Id 214 from 127.0.0.1:1812 to 127.0.0.1:34920 length 32
Reply-Message = "Hello, bob"
您还可以使用通用Password-With-Header
选项指定您的哈希:
#bob Cleartext-Password := "hello"
bob Password-With-Header := "{md5}7d793037a0760186574b0282f2f435e7"
Reply-Message := "Hello, %{User-Name}"
这与版本的效果相同MD5-Password
。可接受的标头列表位于rlm_pap请参阅手册页。
最有趣的标头之一是Crypt-Password
因为它将通过 libcrypt 运行密码哈希,因此可以处理您在 中找到的任何哈希/etc/shadow
。例如,在 Debian 系统上,yescrypt 哈希:
bob Crypt-Password := "$y$j9T$2fOq6bdva3zoX6OfH.JvY0$PbUGbp1U.UXFAnGrkDrYnLZEDK.PXO/HXDsBn4mCsM8"
Reply-Message := "Hello, %{User-Name}"
(本例中的密码是a38sgena
)
禁用密码记录
为了禁用密码记录,请在文件中找到auth_goodpass
和auth_badpass
选择radiusd.conf
:
# Log passwords with the authentication requests.
# auth_badpass - logs password if it's rejected
# auth_goodpass - logs password if it's correct
#
# allowed values: {no, yes}
#
auth_badpass = no
auth_goodpass = no
确保这些设置为“否”,您的日志将停止包含密码。
答案2
以下是与散列方法相对应的属性列表:https://freeradius.org/radiusd/man/rlm_pap.txt
Header Attribute Description
------ --------- -----------
{clear} Cleartext-Password Clear-text passwords
{cleartext} Cleartext-Password Clear-text passwords
{crypt} Crypt-Password Unix-style "crypt"ed passwords
{md5} MD5-Password MD5 hashed passwords
{base64_md5} MD5-Password MD5 hashed passwords
{smd5} SMD5-Password MD5 hashed passwords, with a salt
{sha} SHA-Password SHA1 hashed passwords
SHA1-Password SHA1 hashed passwords
{ssha} SSHA-Password SHA1 hashed passwords, with a salt
{sha2} SHA2-Password SHA2 hashed passwords
{sha224} SHA2-Password SHA2 hashed passwords
{sha256} SHA2-Password SHA2 hashed passwords
{sha384} SHA2-Password SHA2 hashed passwords
{sha512} SHA2-Password SHA2 hashed passwords
{ssha224} SSHA2-224-Password SHA2 hashed passwords, with a salt
{ssha256} SSHA2-256-Password SHA2 hashed passwords, with a salt
{ssha384} SSHA2-384-Password SHA2 hashed passwords, with a salt
{ssha512} SSHA2-512-Password SHA2 hashed passwords, with a salt
{nt} NT-Password Windows NT hashed passwords
{nthash} NT-Password Windows NT hashed passwords
{md4} NT-Password Windows NT hashed passwords
{x-nthash} NT-Password Windows NT hashed passwords
{ns-mta-md5} NS-MTA-MD5-Password Netscape MTA MD5 hashed passwords
{x- orcllmv} LM-Password Windows LANMAN hashed passwords
{X- orclntv} NT-Password Windows NT hashed passwords
不要忘记,您用于验证客户端的协议和方法将影响您可以使用的散列方法。
您可以找到我用于配置 Freeradius 服务器的协议和密码兼容性的表格:http://deployingradius.com/documents/protocols/compatibility.html
为了生成 sha256 加盐密码,我在 github 上使用了以下脚本(您需要编辑最后两行来更改密码和盐):https://gist.github.com/bestrocker221/f506eee8ccadc60cab71d5f633b7cc07