How to add and remove users from the FreeRADIUS Database

This guide assumes you have full root access to your MySQL installation via the command line, which is needed to run these commands. It’s a straightforward task and will help you manage your users via the command line.

To set up FreeRADIUS with MySQL, please refer to this guide here

Adding a username to ‘radcheck’ the FreeRADIUS user table:

First, connect to your MySQL instance:

mysql -uroot -p

Switch to the radius database you added per our FreeRADIUS guide:

use radius;

Now let’s add a user to the user table “radcheck”:

INSERT INTO radcheck (id, username, attribute, op, value) VALUES (1,'vpnextra','User-Password',':=','test123');

Using the above command, you are adding a user with the below credentials:

Username: vpnextra

Password: test123

Be sure to change the username and password before running the command.

You can double-check that this data was added successfully by running the below command:

SELECT * FROM radcheck;

This will display all data currently in the radcheck table and should output something like the below:

MariaDB [radius]> SELECT * FROM radcheck;
+----+---------------------+------------------+----+----------------+
| id | username            | attribute        | op | value          |
+----+---------------------+------------------+----+----------------+
|  8 | vpnextra | User-Password    | := | test123 |
+----+---------------------+------------------+----+----------------+

Removing a user account from ‘radcheck’ the FreeRADIUS user table:

Removing a user from the FreeRADIUS database is just as easy – use the command below to delete the user by the username:

delete from radcheck where username = 'vpnextra'

Now the username should be removed from the radcheck table; you can double-check by running the below command:

SELECT * FROM radcheck;

This will display all data currently in the radcheck table from which you can verify the data has been removed.

Add Simultaneous-Use Session Limit to FreeRADIUS User:

Assuming you have enabled simultaneous-use checking from our FreeRADIUS installation guide, you can add a session limit for each user using a simple command.

The below command adds a session limit of 6 for the username ‘vpnextra’:

INSERT INTO radcheck (username,attribute,value,op) VALUES ('vpnextra','Simultaneous-Use','6',':=');

This restricts the user from having more than six active sessions open simultaneously.

If you have any questions, please feel free to contact us.

Leave a reply:

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.