简体   繁体   English

通过 Radius (Freeradius) 对 OpenVPN 用户进行身份验证

[英]Authenticate OpenVPN users via Radius (Freeradius)

I have set up OpenVPN server (not the access server, the open source community version) and Freeradius 3 on my ubuntu machine.我已经在我的 ubuntu 机器上设置了 OpenVPN 服务器(不是访问服务器,开源社区版)和 Freeradius 3。 OpenVPN client authentication has been tested for both username/password and certificate/key mechanisms for users generated using Easy-RSA. OpenVPN 客户端身份验证已针对使用 Easy-RSA 生成的用户的用户名/密码和证书/密钥机制进行了测试。 Freeradius user creation and testing have been done by daloradius and ntradping respectively. Freeradius 用户创建和测试分别由 daloradius 和 ntradping 完成。

What I want, is to use RADIUS authentication for my VPN clients.我想要的是对我的 VPN 客户端使用 RADIUS 身份验证。 Basically when the client prompts for username password, I want to login via the credentials I have created in freeradius.基本上,当客户端提示输入用户名密码时,我想通过我在 freeradius 中创建的凭据登录。

There is very little info about it on the official documentation page of OpenVPN in this page 在这个页面的OpenVPN官方文档页面上关于它的信息很少

While following the guide, I have found that the openvpn-auth-pam plugin has been renamed, relocated and now comes prebuilt (if it's not feel free to correct me, I assumed that because the openvpn-plugin-auth-pam.so file was already there) into a different directory在按照指南进行操作时,我发现 openvpn-auth-pam 插件已被重命名、重新定位并且现在已经预构建(如果不能随意纠正我,我认为是因为 openvpn-plugin-auth-pam.so 文件已经在那里)到不同的目录

According to the guide I have to add the following line to my server configuration file.根据指南,我必须将以下行添加到我的服务器配置文件中。

plugin /usr/lib/x86_64-linux-gnu/openvpn/plugins/openvpn-plugin-auth-pam.so [name of the module to be used for authentication] 

So here I need to call for a module that calls freeradius to perform the authentication.所以这里我需要调用一个调用freeradius的模块来执行认证。 The guide uses the "login" PAM module which is located at /etc/pam.d directory, unless I found the wrong thing.该指南使用位于/etc/pam.d目录的“登录”PAM 模块,除非我发现错误。 In the same directory there is also a file named radiusd and the contents of the file are在同一目录下还有一个名为 radiusd 的文件,文件内容为

/* /etc/pam.d/radiusd - PAM configuration for FreeRADIUS */ /* /etc/pam.d/radiusd - FreeRADIUS 的 PAM 配置 */

/* We fall back to the system default in /etc/pam.d/common-* */ /* 我们回退到 /etc/pam.d/common-* 中的系统默认值 */

@include common-auth @include 普通认证

@include common-account @include 普通账户

@include common-password @include 通用密码

@include common-session @include 普通会话

I am not sure what to do next.我不确定下一步该做什么。 Is freeradius's own PAM module even relevant to the operation that I am trying to perform? freeradius 自己的 PAM 模块是否与我尝试执行的操作相关? Or do I need to use some external tools and libraries to integrate freeradius with OpenVPN?或者我是否需要使用一些外部工具和库来将 freeradius 与 OpenVPN 集成? Or I need to create the module file by myself?还是我需要自己创建模块文件? Thanks in advance提前致谢

Use Debian.使用 Debian。 Centos 7 is getting EOL soon. Centos 7 即将停产。 Centos 8+ does not have this plugin in repos, but you can compile it (see end of answer). Centos 8+ 在 repos 中没有这个插件,但你可以编译它(见答案结尾)。

Install RADIUS authentication module and edit openvpn server configuration安装 RADIUS 身份验证模块并编辑 openvpn 服务器配置

apt update
# apt-cache search ".*openvpn.*radius.*"
apt install openvpn-auth-radius
# find / -name "radiusplugin*"
cp /usr/share/doc/openvpn-auth-radius/examples/radiusplugin.cnf /etc/openvpn/radiusplugin.cnf
nano /etc/openvpn/radiusplugin.cnf

Edit next sections in /etc/openvpn/radiusplugin.cnf.编辑 /etc/openvpn/radiusplugin.cnf 中的下一部分。 Rest - leave as is. Rest - 保持原样。

name=ip-of-your-radius
retry=10 # change if needed
wait=600 # change if needed
sharedsecret=paste-here-radius-secret

Server config服务器配置

nano /etc/openvpn/server.conf

Add lines:添加行:

# For auth plugins. Uncomment if needed
# username-as-common-name
 
# RADIUS Auth
plugin /usr/lib/openvpn/radiusplugin.so /etc/openvpn/radiusplugin.cnf

If you want to compile it (I didn't tested):如果你想编译它(我没有测试过):

apt-get install libgcrypt11 libgcrypt11-dev gcc make build-essential
wget http://www.nongnu.org/radiusplugin/radiusplugin_v2.1a_beta1.tar.gz
tar xvfz radiusplugin_v2.1a_beta1.tar.gz
cd radiusplugin_v2.1a_beta1/
make
cp radiusplugin.so /etc/openvpn/
cp radiusplugin.cnf /etc/openvpn/

List of OpenVPN plugins: https://community.openvpn.net/openvpn/wiki/PluginOverview OpenVPN 插件列表: https://community.openvpn.net/openvpn/wiki/PluginOverview

PS: similar algorithm for LDAP integration (find plugin in repo, use example config, add it in main config). PS:LDAP 集成的类似算法(在 repo 中找到插件,使用示例配置,将其添加到主配置中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM