Return to site

How To Install Freeradius 2 On Centos 6

broken image


This is a how to install FreeRADIUS and Daloradius on CentOS 7 RADIUS, which stands for 'Remote Authentication Dial In User Service', is a network protocol – a system that defines rules and conventions for communication between network devices – for remote user authentication and accounting. How to install OpenVPN on CentOS By admin On 23 May 2015 In CentOS, Genral Linux, Linux, Proxy Servers, Radius Description: In this tutorial we'll guide you step by step how to install OpenVPN on CentOS 5 and 6.

Updated article as of October 2017 and using the open source FreeIPA the upstream project for Red Hat Identity Manager (IdM) instead of Microsoft Active Directory can be at the URL below.

Last revised July 2016

Objective

The primary objective of this article is to provide a free two-factor authentication solution for use with VPN solutions.

Prerequisites

Before beginning, you will need to complete a minimal installation of CentOS 7 build 1503 or RHEL 7.1 and yum update. You can use my GUIDE found at the URL below. Note the instructions to configure Extra Packages for Enterprise Linux (EPEL) repository is not a requirement and can be ignored.

https://github.com/rharmonson/richtech/wiki/CentOS-7-Minimal-x86_64-Base-Installation-Guide

In addition, consistent and accurate time is a key requirement for the operation of the proposed solution. The FreeRADIUS host will be utilizing SSSD integration with Active Directory and as such both must have the same time. In addition, Google Authenticator service and the device with the Google Authenticator App must have consistent time as well if using time based One Time Passwords (OTP). If problems occur during this tutorial with either SSSD or Google Authenticator, verify the time is correct.

Architecture Overview

FreeRADIUS Components

  • CentOS 7 (1503) or Red Hat Enterprise Linux 7.1 Minimal
  • FreeRADIUS
  • System Security Services Daemon (SSSD)
  • Google Authenticator Pam Library, Service, & APP
  • Pluggable Authentication Module (PAM)

Firewall Requirements

User to NAS

  • TCP 443; SSL VPN

NAS to RADIUS

  • UDP 1812; RADIUS

RADIUS to Active Directory

  • UDP 53; DNS
  • UDP 123; NTP
  • TCP 88; Kerberos
  • TCP 389; LDAP
  • TCP 3268 Global Catalog

Installation Overview

  1. Base CentOS 7 installation
  2. FreeRADIUS Installation
  3. Test FreeRADIUS local Unix account
  4. SSSD Installation
  5. Test FreeRADIUS using SSSD account
  6. Google Authentication Compile & Installation
  7. Configure PAM
  8. Configure SELinux
  9. Test FreeRADIUS using SSSD & Google Authentication
  10. Configure Firewall
  11. Configure your NAS (not covered)
  12. Test FreeRADIUS & NAS
  13. Tidy Up! (optional)

FreeRADIUS

Install FreeRADIUS

Results with

Configure FreeRADIUS

Note!

This solution's use of FreeRADIUS must run as root to access the .google_authenticator in the user's home directory. Verified by changing user back to radiusd breaks authentication on May 21, 2015. Ick!

Edit radiusd.conf

Locate user and group

Update

Edit sites-enabled/default

Locate pam

Update

Enable pam module

Results with

Configure clients.conf

Add the following above 'client localhost {' where the IP address is the client or VPN solution, e.g. Juniper SSL or SoftEther. Don't use my example 'secret123' but a shared secret with 12 to 16 upper and lower case characters, numbers, and symbols.

Configure 'users'

Locate the following

Update as follows

Test FreeRADIUS with an UNIX account

Start radiusd in debug mode

Open a additional shell or SSH.

Create user

Use radtest from radiusd-util package using the local unix account, raduser.

Received Access-Accept should be the response, otherwise you will receive a reject. If so, backup and check your work and correct errors before proceeding.

SSSD

How To Install Freeradius 2 On Centos 64

Install SSSD

Results with

How To Install Freeradius 2 On Centos 6 0

Join host, 2fcosrad7, to the domain 2factor.net. You can also use -U to specify an administrator account. Use man realm to review options including specifying the OU to create the computer object versus the default 'Computers' OU.

After you provide valid credentials with the appropriate privileges, a computer object and DDNS record are created.

It is a good idea to limit what users cans access using a Active Directory user credentials through the use of a Active Directory security group. I created a group called vpnusers and added richard@2factor.net as a memember.

Specify an existing Active Directory group, e.g. vpnusers.

Alternatively, you use --group versus -g

Test SSSD

Utilize a group member, richard, of vpnusers to login at the console or SSH.

Test FreeRADIUS with a SSSD account

Start FreeRADIUS in debug mode

Open another shell and use the radtest utility and use an Active Directory user that is a member of the group vpnusers.

Results should containt Access-Accept otherwise, backup and check your work.

Success results with 'Received Access-Accept.' Use 'ctrl+c' to kill the radiusd daemon.

Google Authenticator

Install compile requirements

Results with

Obtain Source

Install Magento 2 On Centos 7

Note the current directory is root's home or ~

Results with

Build Binaries

Build the libpam found in /google-authenticator/libpam.

Results with

Install binaries

Results with:

Setup User

On-board the user using su and google-authenticator command.

Responding with y to queries results with

The secret key is required to configure the Google Authenticator App so note and secure it in a safe place. The emergency codes are evil but great for testing so copy/paste for initial testing.

PAM

The /etc/pam.d/radiusd file needs to be configured to utilize both SSSD and Google Authenticator.

Below is the default radiusd pam.d file

Edit and save the file

Note

Alternative configuration is to remove 'pam_sss.so' and set 'auth required pam_google_authenticator.so' (no forward_pass or use_first_pass) as required. This results in being prompted for the token only. When integrating with applications, you would chain authentication for different authentication sources. For example, a VPN solution could query Active Directory (AD) for user credentials, pass forward the user account and prompt for the token.

Account lock-outs need to be taken into consideration. For example, if querying AD first, if you don't take precautions to set thresholds lower than AD, the user account could be locked. Results with the user unable to use their AD credentials to access any services utilizing AD credential during the lock out period, e.g. fifteen minutes.

SELinux = permissive

By default SELinux is set to 'enforcing' which will prevent access for the FreeRadius service, radiusd, accessing user directories. However, radiusd needs access to ~/.google_authenticator and as such we need to change from 'enforcing' to 'permissive.'

View current SELinux mode using getenforce

or alternatively using sestatus

To set SELinux to 'permissive' execute the command below but it will revert to enforcing next reboot.

Edit /etc/selinux/config to set SELinux's mode to permissive which will be persistent across system reboot.

Update SELINUX = enforcing to permissive

Test FreeRADIUS with SSSD & Google Authenticator

Using the radtest utility, enter the user richard@2factor.net which is a member of vpnusers followed with both.

In my case

Results with

Use 'ctrl+c' to kill the radiusd process.

Firewall

The assumption is you have not disabled or stopped the firewall. If you have, execute the following two command.

Determine default zone.

List current rules for public zone.

List available services. Note 'radius.'

Permit Radius ports and protocols for public zone.

Reload rules otherwise the above command will not take effect without a reboot.

List rules for the default zone, public. Note the addition of 'radius' for --list-service or, alternatively, --list-all.

References:

Radiusd service

Need to enable and start the radiusd service. You killed your prior instances of radiusd using ctrl+c for testing, right?

Install Google Authenticator App

Obtain Google Authenticator App for your mobile device via Google Play Store and setup using your secret key, e.g. FRL4H7J4OOCY4QGA.

Test FreeRADIUS with NAS

For the purpose of this tutorial, my Network Access Server (NAS) is PulseSecure SSL VPN solution, formerly known as Juniper, and its IP address is 172.16.1.23. Above we created the connection under the section titled 'FreeRADIUS configuration' using configuration file clients.conf.

After configuration of the NAS--I will not illustrate the configuration, but, obviously, use 'radius,' connect to the login portal.

Log-in process

  1. For user, enter richard@2factor.net
  2. For password, enter [+] or Password1437247

If all goes well, you should successfully login.

Done?!

At this point, we have completed the basic build. The next section 'Tidy Up!' provides a number of additional suggestions, but are not requirements.

Tidy Up!

Delete local test user, raduser

Update clients.conf

Update the /etc/raddb/clients.conf file with an appropriate password for all secrets including the localhost connection. For example, change the default localhost from 'testing123' to a secret with 12 to 16 upper and lower case characters, numbers, and symbols.

Move FreeRADIUS Computer Object

Ask your Active Directory administrator to move the computer object for your FreeRADIUS host from 'Computers' to the correct Active Directory Organization Unit (OU). It's probably not 'Computers' and share it is a Linux host for she or he may create a new OU for Linux hosts.

Enable FreeRADIUS Logs

By default, logs are not enabled.

Update the sites-enabled/default to log accounting information.

From the authorize section in /etc/raddb/sites-enabled/default file:

Update to

From the post-auth section in /etc/raddb/sites-enabled/default file:

Update to

There is a dependency on the /etc/raddb/mods-enabled/detail.log, however, by default no changes need to be made. After auth_log and reply_log changes are made, it just works.

Restart FreeRADIUS

Login via you NAS, SSL VPN, and verify logs are generated.

SELinux Access Vector Cache (AVC) Denies

The process below will successfully create a module to resolve radiusd 'avc' errors in /var/log/audit/audit.log, however, SELinux will continue to prevent access to .google_authenticator file--I am still working to resolve (May, 22, 2015). As such, SELinux will continue to be in permissive mode, but we can remove 'avc' errors and benefit when doing analysis of the audit.log.

Install SELinux utilities

Results with

With our previous testing and SELinux set to 'permissive,' we have audit entries in audit.log. If you disabled SELinux, you will need to set to permissive, login using Google Authentication via radiusd, then follow the example below.

Alternatively, you can use grep to filter for specific events

Results with

Activate the policy package

That is it. You should receive no further avc errors.

Information

Disabling or enabling a module use -d or -e, respectively.

Removing a module use -r to remove a module

Packet Capture

Once I have a working solution, I feel it is invaluable to capture a user login via tcpdump for comparison when things break in the future. This is how I do it.

Display available adapters

Capture the transactions and write to file.

Note the ^C above which is ctrl+c to stop the tcpdump process.

Now using scp or winscp, copy the capture to a workstation for analysis using Wireshark or you favorite packet analysis tool then archive it for future use.

Introduction

This guide will tell you how to install a daloRADIUS & FreeRADIUS Server. As TechTarget says, a RADIUS server is:

Remote Authentication Dial-In User Service (RADIUS) is a client/server protocol and software that enables remote access servers to communicate with a central server to authenticate dial-in users and authorize their access to the requested system or service. RADIUS allows a company to maintain user profiles in a central database that all remote servers can share. It provides better security, allowing a company to set up a policy that can be applied at a single administered network point. Having a central service also means that it's easier to track usage for billing and for keeping network statistics. Created by Livingston (now owned by Lucent), RADIUS is a de facto industry standard used by a number of network product companies and is a proposed IETF standard.

daloRADIUS is free to use software and works as the front-end. FreeRADIUS works as the back-end. Both are free and do not require any purchase.

Prepartions

Before we start the installation of daloRADIUS. We need to make sure we have the following:

  • An operating system as Ubuntu, Debian or Raspbian. Other operating systems can be used, but please keep in mind the commands used might not work on your OS. So if needed, tweak them a bit for the corresponding OS.
  • This software requires you to have a static IP address on your device. Citricks created a guide to do so on CentOS. See other guides for how to set a static IP address on your device.
  • Basic knowledge about how Linux operating system work is recommended, but not needed. It will help you to better understand what's going on.
  • Time: around 30 minutes – 1 hour!

Dependencies

Dependencies is software that is required to make another software work. To make daloRADIUS work we need to run the following command:

<p>Optionally I will move the files from the temporary folder to the root folder and delete the temporary folder.</p><div><textarea wrap='soft' readonly='>sudo mv /var/www/daloradius-0.9-9/* /var/www/ sudo rmdir -rf daloradius-0.9-9
2
sudo rmdir-rf daloradius-0.9-9

Configuring MySQL for daloRADIUS

daloRADIUS is using a database to store its content. So we need to configure a database user, database and set it up for dalo. Log-in to MySQL with the correct credentials:

Once you're in, create a database:

2
quit
Install

Now we need to import the .sql script into the database. The .sql file is located in the ‘/contrib/db/' folder. If you didn't install daloRADIUS in the root destination, you might need to change the location of the .sql down below. To import the file run:

<div><textarea wrap='soft' readonly='>mysql -u root -p CREATE USER radius@localhost; SET PASSWORD FOR radius@localhost = PASSWORD('CHANGEYOURPASSWORDHERE'); GRANT ALL ON radius.* to radius@localhost; quit
2
4
CREATE USER radius@localhost;
SET PASSWORD FORradius@localhost=PASSWORD('CHANGEYOURPASSWORDHERE');
quit

You've now created a new user with your own password and granted the new user access to the newly created database and all its tables.

How To Install Usr Bin Python3 5 2 On Centos

Configure daloRADIUS

First we will configure daloRADIUS so it points to the database. To do so we need to edit a configuration file found on ‘./www/library/daloradius.conf.php'. For editing text on the CLI I prefer to use nano. Edit the file by running:

Change the following values to your own credentials:

</div><table><tbody><tr><td><div><div>2</div><div>4</div></div></td><td><div><div><span>$</span><span>configValues</span><span>[</span><span>'CONFIG_DB_PORT'</span><span>]</span><span>=</span><span>'3306'</span><span>;</span></div><div><span>$</span><span>configValues</span><span>[</span><span>'CONFIG_DB_PASS'</span><span>]</span><span>=</span><span>'YOURPASSWORDSHOULDGOHERE!'</span><span>;</span></div></div></td></tr></tbody></table><p>Press ‘CTRL-O' to save your file, following with ‘CTRL-X' to close the document.</p><h2>Configure FreeRADIUS</h2><p>Just like daloRADIUS, we need FreeRADIUS to point to our database. We need to change the config file(s) again. With FreeRADIUS we also need to edit another file which allows the software to check the database. This config file is located in ‘/etc/freeradius'. To edit the file run:</p><p>Remove the ‘#' from the following lines, don't remove anything else:</p><div><textarea wrap='soft' readonly='># $INCLUDE sql.conf # $INCLUDE sql/mysql/counter.conf
2
# $INCLUDE sql/mysql/counter.conf

Once you're done editing press ‘CTRL-O' to save the document and press ‘CTRL-X' to close.

Because the database doesn't know how to connect to the correct database, we need to change the configuration file so he will be able to do so. Edit the ‘sql.conf' file located in the same folder by running:

How to install usr bin python3 5 2 on centos

Now we need to import the .sql script into the database. The .sql file is located in the ‘/contrib/db/' folder. If you didn't install daloRADIUS in the root destination, you might need to change the location of the .sql down below. To import the file run:

<div><textarea wrap='soft' readonly='>mysql -u root -p CREATE USER radius@localhost; SET PASSWORD FOR radius@localhost = PASSWORD('CHANGEYOURPASSWORDHERE'); GRANT ALL ON radius.* to radius@localhost; quit
2
4
CREATE USER radius@localhost;
SET PASSWORD FORradius@localhost=PASSWORD('CHANGEYOURPASSWORDHERE');
quit

You've now created a new user with your own password and granted the new user access to the newly created database and all its tables.

How To Install Usr Bin Python3 5 2 On Centos

Configure daloRADIUS

First we will configure daloRADIUS so it points to the database. To do so we need to edit a configuration file found on ‘./www/library/daloradius.conf.php'. For editing text on the CLI I prefer to use nano. Edit the file by running:

Change the following values to your own credentials:

</div><table><tbody><tr><td><div><div>2</div><div>4</div></div></td><td><div><div><span>$</span><span>configValues</span><span>[</span><span>'CONFIG_DB_PORT'</span><span>]</span><span>=</span><span>'3306'</span><span>;</span></div><div><span>$</span><span>configValues</span><span>[</span><span>'CONFIG_DB_PASS'</span><span>]</span><span>=</span><span>'YOURPASSWORDSHOULDGOHERE!'</span><span>;</span></div></div></td></tr></tbody></table><p>Press ‘CTRL-O' to save your file, following with ‘CTRL-X' to close the document.</p><h2>Configure FreeRADIUS</h2><p>Just like daloRADIUS, we need FreeRADIUS to point to our database. We need to change the config file(s) again. With FreeRADIUS we also need to edit another file which allows the software to check the database. This config file is located in ‘/etc/freeradius'. To edit the file run:</p><p>Remove the ‘#' from the following lines, don't remove anything else:</p><div><textarea wrap='soft' readonly='># $INCLUDE sql.conf # $INCLUDE sql/mysql/counter.conf
2
# $INCLUDE sql/mysql/counter.conf

Once you're done editing press ‘CTRL-O' to save the document and press ‘CTRL-X' to close.

Because the database doesn't know how to connect to the correct database, we need to change the configuration file so he will be able to do so. Edit the ‘sql.conf' file located in the same folder by running:

How To Install Freeradius 2 On Centos 6 7

Remove the ‘#' in font of ‘port' and change the following information to your database settings:

</div><table><tbody><tr><td><div><div>2</div><div>4</div><div>6</div><div>8</div></div></td><td><div><div><span>server</span><span>=</span><span>'localhost'</span></div><div><span>login</span><span>=</span><span>'radius'</span></div><div><span># Database table configuration for everything except Oracle</span></div></div></td></tr></tbody></table><p>Once done, save and close your document.</p><p>To start using FreeRADIUS we need to enable a user. This line is blocked out in the config file so we need to unblock it. The configuration file is located in ‘/etc/freeradius'. To edit the file run:</p><p>Delete the ‘#' on the last two lines shown in the above picture. This means the line with ‘John Doe' and ‘Reply-Message'. If you can't find these lines, press ‘CTRL-W' to search the current document. Once edited press ‘CTRL-O' to save the document and press ‘CTRL-X' to close.</p><p>Now open the ‘default' config file located at ‘/etc/freeradius/sites-enabled/' by running:</p><p>Now remove every ‘#' in front of every sql row in the following sections:</p><table><tbody><tr><td><div><div>2</div><div>4</div></div></td><td><div><div><span>accounting</span></div><div><span>post</span><span>-</span><span>auth</span></div></div></td></tr></tbody></table><p>To make sure everything is applied correctly, we will reboot our system:</p><p>Your RADIUS server is now up and running! Please leave a comment down below if you have any questions or suggestions.</p><br><br><br><br>
broken image