Install an RP Proxy on Alpine Linux
On this page you will find instructions on how to set up a Moonshot RP Proxy on Alpine Linux. It also installs and configures the Trust Router client, if you are going to use the Trust Router infrastructure.
Contents
System Preparation
Install Alpine Linux
The first thing that is required is an Alpine Linux machine - this can be physical, virtual or a container.
Tip
We would recommend using LVM when disk partitioning to allow easier partition/disk expansion on a live system.
Warning
After install, you will want to secure/lockdown the server as best practice dictates - for both the server and any extra software installed. This is beyond the remit of this guide but there are many guides available that provide information on how to secure your Alpine servers and applications.
Configure Alpine
Next, there are a few Alpine configuration options that need to be set in advance:
Networking configuration
For production deployments, it is recommended that the machine be assigned a static IP address.
Firewall configuration
The following ports are required to be accessible from the outside world, both in the local firewall and in any external firewalls:
- 2083/tcp (for RadSec connections to other Moonshot entities)
- 12309/tcp (for Trust Router client connections - if using the Trust Router to broker trust relationships between entities)
Here are sample firewall rules that establish incoming and outgoing rules to both the Test and Live (Jisc Assent) Moonshot trust router infrastructures. If you connect to another Trust Router, adjust these rules to suit:
IP Tables sample firewall rules (Jisc Assent)
-A INPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp -s 0/0 --dst <IdP/RP Proxy IP address> --dport 2083 -j ACCEPT
-A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp -s <IdP/RP Proxy IP address> --dst 0/0 --dport 2083 -j ACCEPT
-A INPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp -s 212.219.179.130,212.219.179.131,212.219.179.138,212.219.179.146 --dst <IdP/RP Proxy IP address> --dport 12309 -j ACCEPT
-A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp -s <IdP/RP Proxy IP address> --dst 212.219.179.130,212.219.179.131,212.219.179.138,212.219.179.146 --dport 12309 -j ACCEPT
IP Tables sample firewall rules (Test Network)
-A INPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp -s 0/0 --dst <IdP/RP Proxy IP address> --dport 2083 -j ACCEPT
-A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp -s <IdP/RP Proxy IP address> --dst 0/0 --dport 2083 -j ACCEPT
-A INPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp -s 13.79.134.211,13.79.128.103,52.169.31.104 --dst <IdP/RP Proxy IP address> --dport 12309 -j ACCEPT
-A OUTPUT -m state --state NEW,ESTABLISHED,RELATED -m tcp -p tcp -s <IdP/RP Proxy IP address> --dst 13.79.134.211,13.79.128.103,52.169.31.104 --dport 12309 -j ACCEPT
Add the Required Repositories
Supported versions
At the moment, Alpine 3.11 and Alpine 3.13 (x86_64 and armhf) are supported.
Add the Moonshot Alpine repository to your system. To do this, run the following command (as root, or using sudo):
Install the Moonshot repository RSA key.
curl "https://repository.project-moonshot.org/alpine/moonshot@jisc.ac.uk-5be46530.rsa.pub" > /etc/apk/keys/moonshot@jisc.ac.uk-5be46530.rsa.pub
1. Install the Moonshot RP Proxy
We’re now ready to install the Moonshot software and its required dependencies. Install the software by running the following command:
apk add moonshot trust_router freeradius-abfab freeradius-radclient
2. Configure the Moonshot RP Proxy
Next, we need to configure the Moonshot RP Proxy.
2.1. Configure FreeRADIUS
Certificates
We need to get FreeRADIUS to create some private and public keys to use for its RadSec connections. Create and install the certificates by doing the following (as root).
Change into the
/etc/raddb/certs
directorycd /etc/raddb/certs
Edit the certificate generation properties in client.cnf, server.cnf, and ca.cnf as follows:
- In the
ca.cnf
file:- In the
[ req ]
section, addencrypt_key = no
In the
[CA_default]
section, change the default_days from 60 to a higher number (this is how long the certificates you create will be valid for). When the certificates expire, you will have to recreate them.in the
[ certificate_authority ]
section, change all of the parameters to match those of your organisation. e.g.[certificate_authority] countryName = GB stateOrProvinceName = England localityName = Camford organizationName = Camford University emailAddress = support@camford.ac.uk commonName = "Camford University FR Certificate Authority"
- In the
In the
server.cnf
file:- In the
[ req ]
section, addencrypt_key = no
- In the
[CA_default]
section, change the default_days from 60 to a higher number (this is how long the certificates you create will be valid for). When the certificates expire, you will have to recreate them. in the
[ server ]
section, change all of the parameters to match those of your organisation. e.g.[server] countryName = GB stateOrProvinceName = England localityName = Camford organizationName = Camford University emailAddress = support@camford.ac.uk commonName = "Camford University FR Server Certificate"
When changing passwords in the
[ req ]
section of the server.cnf file, you must also update theprivate_key_password
option in the FreeRADIUSmods-available/eap
file with the same password.We recommend that you do not change these defaults.
- In the
In the
client.cnf
file:- In the
[ req ]
section, addencrypt_key = no
- In the
[CA_default]
section, change the default_days from 60 to a higher number (this is how long the certificates you create will be valid for). When the certificates expire, you will have to recreate them. in the
[ client ]
section, change all of the parameters to match those of your organisation. e.g.[client] countryName = GB stateOrProvinceName = England localityName = Camford organizationName = Camford University emailAddress = support@camford.ac.uk commonName = "Camford University FR Client Certificate"
All of the organisation parameters (countryName
,localityName
, etc) need to match in the three .cnf files but thecommonName
must be unique in each file)
- In the
- In the
Clear out any old certificates in the directory:
make destroycerts
Run the bootstrap script to generate the certificates
./bootstrap
Create a file that is the concatenation of the certificate and private key of the client.
openssl x509 -in client.crt > client.pem ; cat client.key >> client.pem
Because the above command was run as root, the keys and certificates created will not be readable by the FreeRADIUS user by default, and FreeRADIUS will not be able to start. To fix this, reset the group for the files:
chgrp radius client* server* ca* dh*
RadSec
Next, we need to configure RadSec. We do this by creating a file at /etc/radsec.conf
with the following:
realm gss-eap { type = "TLS" cacertfile = "/etc/raddb/certs/ca.pem" certfile = "/etc/raddb/certs/client.pem" certkeyfile = "/etc/raddb/certs/client.key" disable_hostname_check = yes server { hostname = "127.0.0.1" service = "2083" secret = "radsec" } }
Dynamic Realm support
We need to tell your FreeRADIUS server to support dynamic lookup of realms.
- Open
/etc/raddb/proxy.conf
for editing:- Towards the top of the file is a stanza beginning "
proxy server {
". Find this. Below this, add
dynamic = yes
, like so:proxy server { dynamic = yes
- Towards the top of the file is a stanza beginning "
2.1.1. Channel Binding Support
We next need to configure your FreeRADIUS server to support channel bindings.
- Open
/etc/raddb/sites-available/abfab-tls
for editing:- Scroll to the
client default
stanza at the bottom of the file Edit the stanza to match the below:
client default { ipaddr = 0.0.0.0/0 proto = tls gss_acceptor_realm_name = "your RP realm here" trust_router_coi = ov-apc.moonshot.ja.net }
gss_acceptor_realm_name
For simple deployments, specify the same RP realm as in the
rp_realm
option in Section 4.1 below. For simple deployments, this usually matches your IDP Realm. For extended pilots or production environments, you should specify a realm value that will match all the hosts you will be connecting to your RP Proxy.- If you have any other client definitions here, for example to distinguish between internal and external clients, also apply the change to them.
- Scroll to the
3. Configure the Trust Router Client
If you are going to connect your Moonshot RP Proxy to a Trust Router network, then the next step involves configuring the Trust Router client software and configuring its connection to a Trust Router.
Configure FreeRADIUS to use Trust Router
Configuring FreeRADIUS realm lookup
We need to configure the community and rp_realm appropriate for your Moonshot service, and the Trust Router that it will connect to.
- Open the
/etc/raddb/mods-enabled/realm
for editing. - Find the "realm suffix {" configuration directive, and fill out the fields as appropriate.
- Repeat this for the "realm bangpath {" configuration directive.
For the default Jisc Assent Trust Router this will look like the following:
realm suffix { format = suffix delimiter = "@" default_community = "ov-apc.moonshot.ja.net" rp_realm = "Your service realm as registered in the Jisc Assent Portal" trust_router = "tr.moonshot.ja.net" rekey_enabled = yes } realm bangpath { format = prefix delimiter = "!" default_community = "ov-apc.moonshot.ja.net" rp_realm = "Your service realm as registered in the Jisc Assent Portal" trust_router = "tr.moonshot.ja.net" rekey_enabled = yes }
Example
Camford University has a Moonshot service registered in the Jisc Assent Portal at the service realm of moonshot.camford.ac.uk, so its realm file would look like this:
realm suffix { format = suffix delimiter = "@" default_community = "ov-apc.moonshot.ja.net" rp_realm = "moonshot.camford.ac.uk" trust_router = "tr.moonshot.ja.net" rekey_enabled = yes } realm bangpath { format = prefix delimiter = "!" default_community = "ov-apc.moonshot.ja.net" rp_realm = "moonshot.camford.ac.uk" trust_router = "tr.moonshot.ja.net" rekey_enabled = yes }
Register your Trust Router client with a Trust Router
At this point, the Moonshot service needs to be associated with a Trust Router. To do this, you need to contact the operator of a Trust Router you wish to join for their specific instructions on how to do this.
Once you have joined the Trust Router service, you will be issued with an Organisation credential file in XML file format.
Jisc Assent service instructions
The below instructions are specific to the world's first Trust Router service, Jisc Assent, operated by Jisc in the United Kingdom:
- If you are not signed up to Assent, sign up to Assent first. This step may take a day or two while your organisation details are verified and you are invited to join the portal.
If you are signed up to Assent, log into the Assent portal and follow instructions on how to do it https://assent.jisc.ac.uk/help/organization#manage-credentials
- Download an Organisation credential under the 'Credential' section of your organisation in the portal (in the form of an XML file). Keep this file safe!
You must import the issued credential file using the
moonshot-webp
command as theradiusd
user:su - --shell=/bin/bash radius moonshot-webp -f [path to credential file]
Check that the credential has been correctly imported, by starting the UI and checking the credential has been correctly imported:
moonshot
- If the file exists, the credential file's contents should be present in the file.
4. Testing
Now that we have the Moonshot RP Proxy installed and configured, we're now ready to test!
Tip
At this point you probably want two consoles open on the server, so that you can manually run various components separately.
4.1. Testing FreeRADIUS locally
The first test is to check whether FreeRADIUS is working in its most basic manner.
In window 1, run (as the radius user)
su -s /bin/sh radius radiusd -fxx -l stdout
Check that no errors are output.
4.2. Testing the Trust Router connection
To test the connection to Trust Router, we use the Temporary Identity Client (TIDC) software.
4.2.1. Testing using the Temporary Identity Client (TIDC)
In window 2, (as the radius user) run the tidc command:
su -s /bin/sh radius tidc tr.moonshot.ja.net [your rp-realm] ov-apc.moonshot.ja.net ov-apc.moonshot.ja.net
This uses the "tidc" binary which is used in the following way - tidc [hostname-of-trust-router] [rp-realm] [hostname-of-apc-server] [apc-name]
If the Trust Router connection was successful, you should see something like the following:
In window 2 - TIDC outputTIDC Client: Server = tr.moonshot.ja.net, rp_realm = moonshot-idp.camford.ac.uk, target_realm = ov-apc.moonshot.ja.net, community = ov-apc.moonshot.ja.net connecting to host 'tr.moonshot.ja.net' on port 12309 CTRL-EVENT-EAP-STARTED EAP authentication started CTRL-EVENT-EAP-PROPOSED-METHOD vendor=0 method=21 CTRL-EVENT-EAP-METHOD EAP vendor 0 method 21 (TTLS) selected CTRL-EVENT-EAP-PEER-CERT [...] CTRL-EVENT-EAP-SUCCESS EAP authentication completed successfully tidc_fwd_request: Sending TID request: [...] tr_msg_decode_tidresp(): Success! result = success. tr_msg_decode_servers(): Number of servers = 1. Response received! Realm = ov-apc.moonshot.ja.net, Community = ov-apc.moonshot.ja.net. Client Key Generated (len = 256): [...]
5. Next Steps
At this point, you now have a Moonshot RP Proxy that is working and registered with a Trust Router. Now for the next steps:
5.1. Automatically start the software
To automatically start FreeRADIUS, issue the following command (as root):
rc-update add radiusd rc-service radiusd start
If this is working correctly, you should see FreeRADIUS running as a daemon process.
5.2. Configure clients
The next step is to configure the Moonshot RP Proxy to Talk to Applications/Services.