部署要求及环境
freeradius-server-2.1.11
daloradius-0.9-9
Apache + Mysql(5.0 or better) + PHP(5.2 or better)
pam_radius-1.3.17(可选,用来做测试)
RedHat 5.1 x86
安装Freeradius+pam_radius_auth
启用Freeradius sql认证模式
- vi /usr/local/freeradius/etc/raddb/radiusd.conf //搜索 $INCLUDE sql.conf 去掉行首的注释(某些版本可能已经去掉注释了)
- vi /usr/local/freeradius/sites-enabled/default //将authorize{}段中file改为sql,同样accounting{}段中的file也改成sql.示例:
- authorize {
- preprocess
- chap
- mschap
- suffix
- eap
- sql
- pap
- }
- accounting {
- detail
- sql
- }
创建数据库
- mysql -uroot -p //开启一个mysqlshell
- create database radius;
- grant all on radius.* to radius@localhost identified by "radpass";
- exit;
修改mysql连接参数
- vi /usr/local/freeradius/etc/raddb/sql.conf //示例:
- server = "localhost"
- port = 3306
- login = "radius"
- password = "radpass"
安装daloradius
首先安装php、php-gd、php-pear、php-pear-db等rpm包
RHEL5.1中没有php-pear-db rpm包。安装完php-pear之后用pear安装
- pear install DB-1.7.14RC2
完了之后装dolaradius
- tar zxvf daloradius-0.9-9.tar.gz
- cp -r daloradius-0.9-9 /var/www/html/daloradius ///var/www/html是RHEL5上apache的DocumentRoot,我直接拷到它下面。也可以虚拟目录等其他方式,自由发挥吧
- chown -R apache:apache /var/www/html/daloradius //修改文件属主,apache是我的apache运行账户。
导入数据表
- cd /var/www/html/daloradius/contrib/db
- mysql -uroot -pyourpassword < mysql-daloradius.sql
- mysql -uroot -pyourpassword < fr2-mysql-daloradius-and-freeradius.sql
修改dolaradius链接mysql参数
- vi /var/www/html/daloradius/library/daloradius.conf.php //主机、用户名、密码之类的。
安装完成,浏览http://yourip/daloradius
Login:
username: administrator
password: radius
ssh测试
在management中添加一个用户并设置密码,用户名随意,但必须保证ssh主机上有这个用户,没有的话需要手工在ssh主机上建。
接下就可以用在daloradius上设置的密码来登录该用户了。
- ssh steve@localhost //steve是我创建的用户
不出问题的话,成功获得shell。
Troubleshooting
- 提示错误:rlm_sql (sql): Could not link driver rlm_sql_mysql: rlm_sql_mysql.so: cannot open shared object file: No such file or directory
这个错误通常出现编译安装情况下,原因正如他提示的那样找不到mysql驱动.解决方法是:
- 进入freeradius安装目录
- cd src/modules/rlm_sql/drivers/rlm_sql_mysql/
- ./configure --with-mysql-dir=/var/lib/mysql --with-mysql-lib-dir=/usr/lib/mysql
- //--with-mysql-dir 指定mysql的家目录。如果是用rpm或yum的方式安装mysql,这个目录为/var/lib/mysql
- //--with-mysql-lib-dir 指定mysql库文件目录。如果是用rpm或yum的方式安装mysql,这个目录为/usr/lib/mysql
- make
- make install
转载于:https://blog.51cto.com/orzee/620563