FreeIPA FreeRadius FreeOTP 实现双因素认证登录

FreeIPA FreeRadius FreeOTP 实现双因素认证登录


前言

FreeIPA 是一款开源的身份认证系统
FreeRadius是一款开源的Radius认证系统
FreeOTP是一款软令牌客户端
本文将在CentOS 8上部署FreeIPA和FreeRadius,从而实现双因素登录设备以及双因素认证登录。


一、安装先决条件

1.CentOS8
2.dns server(WindowsServer)
3.VPN GW(Checkpoint)
4.Iphone/Android

二、安装FreeIPA步骤

1.安装前准备

命令如下:

###设置主机名###
hostnamectl set-hostname freeipa.unite-puxi.local
###修改hosts文件###
nano /etc/hosts
###添加以下行,保存并退出###
172.18.1.163 freeipa.unite-puxi.local
###默认情况下,FreeIPA软件包在CentOS标准存储库中不可用###
###启用idm:DL1存储库###
dnf module enable idm:DL1
###同步存储库###
dnf distro-sync

2.安装配置FreeIPA Server

###安装###
dnf install ipa-server ipa-server-dns -y
###配置###
ipa-server-install
#####################以下为配置过程######################
The log file for this installation can be found in /var/log/ipaserver-install.log
==============================================================================
This program will set up the IPA Server.
Version 4.9.6

This includes:
  * Configure a stand-alone CA (dogtag) for certificate management
  * Configure the NTP client (chronyd)
  * Create and configure an instance of Directory Server
  * Create and configure a Kerberos Key Distribution Center (KDC)
  * Configure Apache (httpd)
  * Configure the KDC to enable PKINIT

To accept the default shown in brackets, press the Enter key.

Do you want to configure integrated DNS (BIND)? [no]: no

Enter the fully qualified domain name of the computer
on which you're setting up server software. Using the form
<hostname>.<domainname>
Example: master.example.com.


Server host name [freeipa.unite-puxi.local]: 

The domain name has been determined based on

```bash

```bash
 the host name.

Please confirm the domain name [unite-puxi.local]: 

The kerberos protocol requires a Realm name to be defined.
This is typically the domain name converted to uppercase.

Please provide a realm name [UNITE-PUXI.LOCAL]: 
Certain directory server operations require an administrative user.
This user is referred to as the Directory Manager and has full access
to the Directory for system management tasks and will be added to the
instance of directory server created for IPA.
The password must be at least 8 characters long.

Directory Manager password: 
Password (confirm): 

The IPA server requires an administrative user, named 'admin'.
This user is a regular system account used for IPA server administration.

IPA admin password: 
Password (confirm): 

Do you want to configure chrony with NTP server or pool address? [no]: no

The IPA Master Server will be configured with:
Hostname:       freeipa.unite-puxi.local
IP address(es): 172.18.1.163
Domain name:    unite-puxi.local
Realm name:     UNITE-PUXI.LOCAL

The CA will be configured with:
Subject DN:   CN=Certificate Authority,O=UNITE-PUXI.LOCAL
Subject base: O=UNITE-PUXI.LOCAL
Chaining:     self-signed

Continue to configure the system with these values? [no]: yes

###############################################################

.安装成功
在这里插入图片描述

###开启防火墙策略###
firewall-cmd --add-service={http,https,dns,ntp,freeipa-ldap,freeipa-ldaps} --permanent
firewall-cmd --reload
###取消SELinux###
nano /etc/selinux/config
找到以下行:
SELINUX=enforcing
并且,将其替换为以下行:
SELINUX=permissive
保存并关闭文件。然后,重新启动系统以应用更改:

三、访问FreeIPA

1.登录DNS server,添加DNS A记录

在这里插入图片描述

2.使用浏览器访问freeipa域名

https://freeipa.unite-puxi.local
用户名:admin
密码:ipa-server-install 设置的admin 密码

在这里插入图片描述

四、配置FreeIPA用户

1.添加用户

在这里插入图片描述

2.关联token

在这里插入图片描述
在这里插入图片描述

3.使用Free OTP 添加软令牌

在这里插入图片描述

4.使用IPHONE扫描二维码

在这里插入图片描述
在这里插入图片描述

5.使用添加用户实现双因素登录

1.修改密码

输入密码以及IPHONE上的OTP数字,用以修改密码
在这里插入图片描述

2.登录账号

输入修改后的密码以及IPHONE上OTP令牌数字

在这里插入图片描述
在这里插入图片描述

5.安装配置FreeRaiuds

####安装freeradius及相关组件####
yum install freeradius freeradius-utils freeradius-ldap freeradius-krb5

####配置Radius认证的客户端网段####
vim /etc/raddb/clients.conf
client localnet { 
        ipaddr = 172.18.1.0/24 
        proto = * 
        secret = somesecret 
        nas_type = none
        limit { 
                max_connections = 30 
                life = 0 
                idle_timeout = 30 
        } 
}
####修改/etc/raddb/sites-enabled/default 中ldap配置,确保认证用户从ldap数据库中获取密码
vim /etc/raddb/sites-enabled/default
        #  The ldap module reads passwords from the LDAP database.
        ldap
        if ((ok || updated) && User-Password) {
            update {
                control:Auth-Type := ldap
            }
        }

####取消以下注释####
#       Auth-Type LDAP {
#               ldap
#       }
####修改/etc/raddb/sites-enabled/inner-tunnel 中ldap配置,确保认证用户从ldap数据库中获取密码
vim /etc/raddb/sites-enabled/inner-tunnel
        #  The ldap module reads passwords from the LDAP database.
        ldap
        if ((ok || updated) && User-Password) {
            update {
                control:Auth-Type := ldap
            }
        }

####取消以下注释####
#       Auth-Type LDAP {
#               ldap
#       }

####添加LDAP到mods-enabled中####
ln -s /etc/raddb/mods-available/ldap /etc/raddb/mods-enabled/

####修改mods-enable中LDAP属性####
vim /etc/raddb/mods-enabled/ldap
server = 'freeipa.unite-puxi.local'
base_dn = 'cn=users,cn=compat,dc=unite-puxi,dc=local'

####开放防火墙策略####
firewall-cmd --permanent --zone=public --add-port=1812/udp --add-port=1813/udp

####重启防火墙服务####
systemctl restart firewalld.service

6.本地测试用户集成状态

1.使用radiusd –X 调试

###打开调试页面###
radiusd –X
......
Listening on auth address * port 1812 bound to server default
Listening on acct address * port 1813 bound to server default
Listening on auth address :: port 1812 bound to server default
Listening on acct address :: port 1813 bound to server default
Listening on auth address 127.0.0.1 port 18120 bound to server inner-tunnel
Listening on proxy address * port 44742
Listening on proxy address :: port 51189
Ready to process requests

####打开测试页面,用户为FreeIPA创建的用户”chenjingwen“####
####密码为“Admin123”,Token为“820521”####
####认证域名”freeipa.unite-puxi.local “,secret为”somesecret“####
radtest chenjingwen Admin123820521 freeipa.unite-puxi.local 1812 somesecret
#####测试结果如下####
Sent Access-Request Id 153 from 0.0.0.0:32890 to 172.18.1.163:1812 length 81
	User-Name = "chenjingwen"
	User-Password = "Admin123820521"
	NAS-IP-Address = 172.18.1.163
	NAS-Port = 1812
	Message-Authenticator = 0x00
	Cleartext-Password = "Admin123820521"
Received Access-Accept Id 153 from 172.18.1.163:1812 to 172.18.1.163:32890 length 20

七、启用FreeRadius

####添加开机启动并开启服务####
systemctl enable radiusd
systemctl start radiusd.service

八、集成Checkpoint,Paloalto设备认证登录

1.集成Checkpoint Gaia Embedded

1> 添加Radius server

在这里插入图片描述

2> 允许用户认证登录从radius进行

在这里插入图片描述

3> 测试登录

在这里插入图片描述
在这里插入图片描述

2.集成Checkpoint Gaia

1> 添加Radius server

在这里插入图片描述

2> 添加Radius 用户权限

目前没有进行radius侧授权的测试,后续展开
在这里插入图片描述

3> 测试登录

在这里插入图片描述
在这里插入图片描述

3.集成PaloAlto WEBUI

1> 添加Radius server

在这里插入图片描述

2> 添加认证授权文件

在这里插入图片描述

3> 添加认证用户

在这里插入图片描述

4> 测试登录

在这里插入图片描述
在这里插入图片描述

4.集成Checkpoint 虚拟专用网络

1> 允许虚拟专用网络用户认证登录从radius进行

在这里插入图片描述

2> 虚拟专用网络用户登录测试

未登录虚拟专用网络前

在这里插入图片描述

登录虚拟专用网络后

在这里插入图片描述

九、部署过程中的一些问题

1.Freeradius 服务启动失败问题

优于证书未生成导致,可执行./bootstrap解决

cd  /etc/raddb/certs
./bootstrap

2.radius认证失败问题

请确认/etc/raddb/mods-available/ldap 中的base dn是否正确

/etc/raddb/mods-available/ldap
        server = 'freeipa.unite-puxi.local'
        base_dn = 'cn=users,cn=compat,dc=unite-puxi,dc=local'

3.参考链接

在Centos7上使用 FreeIPA 和 FreeRadius 实现基于 RADIUS 的软件令牌 OTP 的认证

  • 2
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值