部署要求及环境
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 
参考 http://orzee.blog.51cto.com/3105498/618098
 
启用Freeradius sql认证模式
   
   
   
   
  1. vi /usr/local/freeradius/etc/raddb/radiusd.conf  //搜索 $INCLUDE sql.conf 去掉行首的注释(某些版本可能已经去掉注释了) 
  2. vi /usr/local/freeradius/sites-enabled/default //将authorize{}段中file改为sql,同样accounting{}段中的file也改成sql.示例: 
  3. authorize { 
  4.           preprocess 
  5.           chap 
  6.           mschap 
  7.           suffix 
  8.           eap 
  9.           sql 
  10.           pap 
  11. accounting { 
  12.           detail 
  13.           sql 
创建数据库
   
   
   
   
  1. mysql -uroot -p //开启一个mysqlshell 
  2. create database radius; 
  3. grant all on radius.* to radius@localhost identified by "radpass"; 
  4. exit; 
修改mysql连接参数
   
   
   
   
  1. vi /usr/local/freeradius/etc/raddb/sql.conf //示例: 
  2.         server = "localhost" 
  3.         port = 3306 
  4.         login = "radius" 
  5.         password = "radpass" 
安装daloradius
首先安装php、php-gd、php-pear、php-pear-db等rpm包
RHEL5.1中没有php-pear-db rpm包。安装完php-pear之后用pear安装
   
   
   
   
  1. pear install DB-1.7.14RC2 
完了之后装dolaradius
   
   
   
   
  1. tar zxvf daloradius-0.9-9.tar.gz 
  2. cp -r daloradius-0.9-9 /var/www/html/daloradius ///var/www/html是RHEL5上apache的DocumentRoot,我直接拷到它下面。也可以虚拟目录等其他方式,自由发挥吧 
  3. chown -R apache:apache /var/www/html/daloradius //修改文件属主,apache是我的apache运行账户。 
导入数据表
   
   
   
   
  1. cd /var/www/html/daloradius/contrib/db 
  2. mysql -uroot -pyourpassword < mysql-daloradius.sql 
  3. mysql -uroot -pyourpassword < fr2-mysql-daloradius-and-freeradius.sql 
修改dolaradius链接mysql参数
   
   
   
   
  1. vi /var/www/html/daloradius/library/daloradius.conf.php //主机、用户名、密码之类的。 
安装完成,浏览http://yourip/daloradius
    Login:
                username: administrator
                password: radius
ssh测试
在management中添加一个用户并设置密码,用户名随意,但必须保证ssh主机上有这个用户,没有的话需要手工在ssh主机上建。
接下就可以用在daloradius上设置的密码来登录该用户了。
   
   
   
   
  1. ssh steve@localhost //steve是我创建的用户 
不出问题的话,成功获得shell。
 

Troubleshooting

   
   
   
   
  1. 提示错误: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驱动.解决方法是:

   
   
   
   
  1. 进入freeradius安装目录 
  2. cd src/modules/rlm_sql/drivers/rlm_sql_mysql/ 
  3. ./configure --with-mysql-dir=/var/lib/mysql --with-mysql-lib-dir=/usr/lib/mysql 
  4. //--with-mysql-dir 指定mysql的家目录。如果是用rpm或yum的方式安装mysql,这个目录为/var/lib/mysql 
  5. //--with-mysql-lib-dir 指定mysql库文件目录。如果是用rpm或yum的方式安装mysql,这个目录为/usr/lib/mysql 
  6. make 
  7. make install