21
2025
04
21:34:32

ToughRADIUS 快速安装指南 - 搭建开源用户认证

ToughRADIUS 快速安装指南

ToughRADIUS 是一种健壮、高性能、易于扩展的开源 RADIUS 服务器。本指南将引导您快速地在您的系统上安装和配置 ToughRADIUS 服务。当前版本是基于Go语言开发的。

开源项目地址:https://github.com/talkincode/toughradius

官方文档:https://www.toughradius.net/docs/documents

编译安装

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
dnf install golang -y

# 以Rocky Linux为例,安装golang

go install github.com/talkincode/toughradius/v8@v8.0.8

# 执行自动编译,指定库和版本。

go install github.com/talkincode/toughradius/v8@latest


# 执行自动编译,使用最新源码。



tree -L 3 ./go
go/
├── bin
│   └── toughradius
└── pkg
   ├── mod
   │   ├── cache
   │   ├── github.com
   │   ├── go.etcd.io
   │   ├── golang.org
   │   ├── gonum.org
   │   ├── google.golang.org
   │   ├── gopkg.in
   │   ├── gorm.io
   │   ├── go.uber.org
   │   └── layeh.com
   └── sumdb
       └── sum.golang.org

# 查看编译后的目录,bin下为编译好的二进制文件
TEXT

PS:安装参考二进制安装,直接执行toughradius -install 即可,可配置为服务,并安装。

快速安装

通过 curl 或 wget 执行shell脚本安装 (自动化编译和注册服务)

您可以使用 curl 或 wget 工具来快速安装 ToughRADIUS。根据您的喜好选择以下命令之一执行即可。

使用 curl 安装:

1
sudo bash -c "$(curl -fsSL https://raw.githubusercontent.com/talkincode/toughradius/main/installer.sh)"
BASH

使用 wget 安装:

1
sudo bash -c "$(wget https://raw.githubusercontent.com/talkincode/toughradius/main/installer.sh -O -)"
BASH

二进制安装

我们以 v8.0.8 版本为例进行安装说明。请依据以下步骤进行:

  • 从 Releases 页面 下载软件发行版。

  • 如果您具备一定的开发能力,您也可以选择自行编译版本。

使用 curl 下载 ToughRADIUS 并进行安装:

1
2
3
curl https://github.com/talkincode/toughradius/releases/download/v8.0.8/toughradius_amd64 -O /tmp/toughradius

chmod +x /tmp/toughradius && /tmp/toughradius -install
BASH

系统环境依赖

在开始安装之前,请确保您的系统满足以下条件:

  • 操作系统:支持跨平台部署(Linux、Windows、MacOS 等)

  • 数据库服务器:PostgreSQL 14 或更高版本


PG数据库实例安装


以Rocky Linux为例,安装PG 16


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
dnf module install postgresql:16 -y

# 指定安装16版本

postgresql-setup --initdb
# 初始化数据库

vim /var/lib/pgsql/data/pg_hba.conf


# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            scram-sha-256
# IPv6 local connections:
host    all             all             ::1/128                 scram-sha-256

# 将主机连接的加密方式将ident改为scram-sha-256即可。

systemctl enable --now postgresql


systemctl restart postgresql

systemctl status postgresql

# 配置开机启动,查看状态


TEXT


ToughRADIUS数据库初始化


在进行 ToughRADIUS 的安装和配置之前,请确保您的数据库服务器已经正确安装并且正在运行。下面是数据库的初始化步骤:

运行数据库创建脚本并创建一个专用用户:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
sudo -u postgres psql

# 登录到PostgreSQL shell


CREATE USER toughradius WITH PASSWORD 'songxwn.com';

# 创建用户toughradius,指定密码songxwn.com

CREATE DATABASE toughradius WITH OWNER toughradius;

# 创建数据库toughradius

GRANT ALL PRIVILEGES ON DATABASE toughradius TO toughradius;

# 授权用户数据库权限

\q

# 退出pg shell
SQL

请将 toughradius 替换成您想要设置的密码。

  • 在继续操作之前,请确保您已经创建了相应的数据库,并确保数据库服务器正在运行。

  • 修改配置文件 /etc/toughradius.yml


修改toughradius配置文件接入数据库


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
vim /etc/toughradius.yml


database:
   type: postgres
   host: 127.0.0.1
   port: 5432
   name: toughradius
   user: toughradius
   passwd: songxwn.com
   max_conn: 100
   idle_conn: 10
   debug: false

# 配置数据库连接信息。
TEXT

启动服务

安装完成后,您可以通过以下命令启动 ToughRADIUS 服务,并设置为开机自启:

1
2
systemctl enable toughradius
systemctl start toughradius
BASH

控制台" style="box-sizing: border-box; margin-top: 2em; margin-bottom: 0.75em; line-height: 1.25; font-size: 1.25em; color: rgb(196, 198, 201); transition: color 0.2s ease-in-out 0s, border-bottom-color 0.2s ease-in-out 0s; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"; letter-spacing: 0.32px; text-wrap: wrap; background-color: rgb(37, 45, 56);">访问控制台

打开您的网络浏览器,输入 URL:http://服务器IP:1816。请将 “服务器IP” 替换成您的服务器实际的 IP 地址。

默认的用户名和密码是:admin/toughradius

至此,ToughRADIUS 的安装和基本配置已经完成。您现在可以开始配置您的 RADIUS 服务器,并管理您的用户认证和账户计费。

PS:若数据库为空,则也会提示密码错误。如果出现此问题可以尝试重启服务,或检查数据库配置。




推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

本文链接:https://hqyman.cn/post/10648.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: