Install a Trust Router on Alpine Linux

On this page you will find instructions on how to set up a Trust Router on Alpine Linux.

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.

  1. Add the Moonshot Alpine repository to your system. To do this, run the following command (as root, or using sudo):

    Alpine 3.13
    echo "https://repository.project-moonshot.org/alpine/v3.13" >> /etc/apk/repositories
    echo "@moonshot https://repository.project-moonshot.org/alpine/v3.13" >> /etc/apk/repositories
    Alpine 3.15
    echo "https://repository.project-moonshot.org/alpine/v3.15" >> /etc/apk/repositories
    echo "@moonshot https://repository.project-moonshot.org/alpine/v3.15" >> /etc/apk/repositories
  2. 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 Trust Router

We’re now ready to install the Trust Router software and its required dependencies. Install the software by running the following command:

apk add trust_router moonshot

2. Configure Trust Router

Next, we need to configure the Trust Router.

2.1. RadSec

2.1.1. APC TLS

First, you will need a copy of a client key and certificate (and appropriate CA) from the APC(s) that your Trust Router serves. Copy them onto the filesystem.

You can put these files anywhere on the file system, but this guide assumes you put them in /etc/pki/certs and /etc/pki/private. If you place them in a different location you will need to change the locations below as appropriate.

2.1.2. Connection to APC

Next, we need to configure the RadSec configuration for the APC. We do this by creating a file at /etc/radsec.conf with the following:

realm gss-eap {
	type = "TLS"
	cacertfile = "/etc/pki/certs/tr-ca.pem"
	certfile = "/etc/pki/certs/tr-client.pem"
	certkeyfile = "/etc/pki/private/tr-client.key"
	disable_hostname_check = yes
	server {
		hostname = "YOUR_APC_HOSTNAME"
		service = "2083"
		secret = "radsec"
	}
}

Then check the file and the certificates can be read by the Trust Router user:

sudo -u trustrouter cat /etc/radsec.conf  /etc/pki/certs/tr-*.* /etc/pki/private/tr-*.*

2.2. Trust Router

2.2.1. Daemon Configuration

Your Trust Router will need to have a few core configuration items set. To do this:

  1. Open the default instance's main configuration file at /etc/trust_router/default-internal.cfg for editing.
    1. Change the hostname to the (fully qualified) hostname of your Trust Router.
If the /etc/trust_router directory does not exist, you may need to create it yourself, along with the subdirectories mentioned.

2.2.2. Moonshot Configuration

Moonshot, you say? Yes, Trust Router uses Moonshot to authenticate and secure all communications between Trust Router clients and servers. So, you will need to configure the trust router user to make use of the Moonshot flatstore (i.e. telling Moonshot that this is a special system account, not a regular user account), and you will need to import a set of credentials for your Trust Router to use.

  1. Import it using the moonshot-webp command (as the trustrouter user):

    su - --shell=/bin/bash trustrouter
    moonshot-webp -f [path to credential file]

    The credentials file will be given to you by the administrator of the APC.

2.2.3. Default Peer

If your Trust Router is going to run in its own, standalone, trust network, then skip this step.

If your Trust Router is going to run in a wider trust network, then you can configure your Trust Router's default peer - i.e. the Trust Router it sends its clients to when they ask it to locate a Moonshot entity that your Trust Router doesn't know about. To do this:

  1. Open /etc/trust_router/peering.cfg for editing. Change the content as follows:

    {
    "default_servers": [
     "[hostname of trust router]"
     ]
    }

    Example

    If you were configuring your default Trust Router peer to be Janet's Trust Router at tr.moonshot.ja.net, its peering.cfg file would look like this:

    {
    "default_servers": [
     "tr.moonshot.ja.net"
     ]
    }

2.2.4. Configure your Trust Router

A trust router requires a trust configuration to function correctly. See the trust configuration file for more information.

Place an appropriate trusts.cfg file info the /etc/trust_router directory and symbolically link it into the default configuration directory:

You can find a Trust Router configuration suitable for a Trust Router connecting to tr.moonshot.ja.net at sample Trust Router Client configuration

2.2.5. Start your Trust Router

You are now ready to restart your Trust Router and test it. To do this:

  1. As root, start the Trust Router daemon:

    rc-service trust_router start

3. Testing

To test your trust router, you should attempt a TIDC request on a Moonshot service connected to your trust router. If you have defined a default peer, the TIDC request may take a little longer, but it should succeed.

If it fails, please contact us.

4. Next Steps

At this point, you now have a Trust Router.

4.1. Automatically start the software

4.1.1. Trust Router

To automatically start Trust Router, issue the following command (as root):

rc-update add trust_router
rc-service trust_router start

If this is working correctly, you should see trust_router running as a daemon process.