Caveat
freeradius is a bit baffling to get a full grasp on and I don’t pretend to be an expert. My goals were two-fold – radius users authenticate against pam (rlm_pam
) with two-factor google authenticator and ensure freeradius doesn’t have to run as root.
Logistically, The two-factor code will come in AFTER (no space, enter, etc) the user’s password like:
1 2 |
|
Radius Files
By default, freeradius config files will be found in /etc/raddb
. From the start you will be concerned with:
radiusd.conf
– lists all the relevant paths of radius files. sets radiusd permissionssites-enabled/default
– default site configuration parameters specified. Lists enabled modules for aaaclients.conf
– This file defines radius clients by IP or subnet that are allowed to connect, client specific parameters, and where you will indicate the secret shared key.users
– You can list users in this file if you want and define parameters of groups. This is an optional file technically which is enabled by default thanks to the ‘files’ parameter listed in the ‘default’ sites file./etc/pam.d/radiusd
– pam parameters to run for the radiusd rlm_pam module
In radiusd.conf
, modified the following under the authenticate section (used to be pap):
1 2 3 |
|
So, I wanted to allow users on the local system that are in the switchuser
group and also a user named rancid. Everyone else should fail out. My rancid user is used for scraping configs and doesn’t have full command rights. Part of this setup involves configuring the privilege level commands on the IOS device itself. I set some system specific Appended the following to users
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Google Authenticator Pam “Hack”
I use the term “hack” very very loosely. I merely just commented out a line really. Okay, 4 lines. ahem Anyways…
If you run radiusd without root permissions, you’ll have problems trying to use the google auth pam module. This is because it wants to change uid/gid to the incoming user by default. I did three things to get around this:
- I set the
secret=/var/run/user/${USER}/.google_authenticator
parameter. Will need all users to copy their files here and chown this folder to the same user that will be running radiusd - I forced the user with the
user=radiusd
- I re-compiled the source for the google pam module and commented out a fail value when it tries to change group id. (see below)
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 |
|
My /etc/pam.d/radiusd
now looks like:
1 2 3 4 5 6 7 |
|
forward_pass
produces the functionality explained at the top (google code follows password).
Fire!
Start up the server in debug mode with:
1
|
|
Start firing packets at your instance with:
1
|
|
shared_key
is a value found in the clients file