Matomo: Impressive and Useful

I discussed migrating from Google Analytics and Jetpack to Matomo in a previous post. However, I haven’t used it for a significant amount of time. I am finding it very useful.

There are two ways you can self-host Matomo. As a plugin for WordPress or as an independent web application. The WordPress plugin is the most accessible and most straightforward option for analytics on one WordPress installation. However, if you administer more than one website, the dedicated web application is a better option.

The only real difficulty I ran into was getting GeoIP working. That is due primarily to a lack of Debian packages for the correct PHP extension and no clear subheadings for system managed updates of the GeoIP databases.

#Assuming Matomo installed at /var/www/html/matomo
#Assuming geoipupdate places the databases in /usr/share/GeoIP/
cd /var/www/html/matomo/misc/
for DB in `ls /usr/share/GeoIP/*.mmdb`
do
ln -s /usr/share/GeoIP/$DB ./
done
#All .mmdb databases are now linked to the system databases updated by geoipupdate.

–Robert

Automatically Starting Exactly One ssh-agent

I use SSH keys to protect all of my SSH logins. The following shell code starts only one ssh-agent and adds all ssh-keys to that agent. I recommend adding it to your ~/.bashrc file, so the proper environment variables are set up.

if [ `ps -C ssh-agent | wc -l` -ne 2 ]; then
  ssh-agent -a $HOME/.ssh/agent.sock > $HOME/.ssh/agent.env
  source $HOME/.ssh/agent.env
  for key in $HOME/.ssh/*.pub; do
    pkey=`basename -s .pub $key`
    ssh-add $HOME/.ssh/$pkey
  done
fi

Upgrade WordPress’ Password Hashing

WordPress and several other pieces of web software written in PHP are notorious for using old and broken algorithms for securing passwords. If you are using a PHP version of 5.5 or newer, you should get okay security by default. However, even phpass’ developers recommend not using their software if you can use PHP 5.5 or newer. I strongly suggest installing and enabling the PHP Native password hash plugin, especially if your WordPress install was ever run on any of the PHP 5 family. The plugin’s two most significant advantages are it actually gets updated to include new, more robust algorithms, and it automatically migrates passwords to the newer algorithms on login.

Update to TLS 1.3 with Apache

I moved this site to TLS 1.3 a few weeks ago. So far, it has been working great if I use a web browser. Unfortunately, no one has updated Curl to work with TLS 1.3. The second issue is that Curl is the HTTP client library du jour for C or languages that use C’s Foreign Function Interface. Unfortunately, TLS 1.3 only breaks nearly all applications that use a web callback or WordPress’ APIs.

To add TLS 1.2 back as an option

#Add below the SSLCipherSuite for TLSv1.3
SSLCipherSuite ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384

#Add +TLSv1.2 to the end of the SSLProtocol line
SSLProtocol -all +TLSv1.3 +TLSv1.2

Use Apache’s mod_usertrack to get analytics without sharing data

First a major caveat, I still have Jetpack installed to simplify a few tasks like reducing comment spam. Until I have a replacement for everything it does, it will still track visitors.

You need to know how many people are interacting with your site and where they are interacting with it. Without some form of visitor tracking, I couldn’t be sure what my most visited post types are.

However, right now, website analytics is dominated by a group of companies that view everyone as a product, not the customer. Google, Facebook, and others all offer analytics for site owners, but you, the site owner, don’t control the data, they do. So how do you respect your visitors’ privacy and get useful analytical data for your website? The answer is to host your own. I haven’t made the full jump to a self-hosted analytics software yet, but I am choosing to log some extra data that will make that move easier in the future.

The most basic information I use for analytics is the access logs that Apache makes. The “combined” log format logs the remote IP address, the timestamp of the request, the final response code, the size of its response, the referer, and the user-agent. Apache also includes a couple of extra items for backward compatibility. There are two pieces of information that would complete the analytics picture, which vhost responded, and a cookie to tell if one client made multiple requests.

Apache’s mod_usertrack adds the cookie and adding the vhost is simple. I also decided to add mod_unique_id as well.

To make these changes, you need to enable those modules. For Ubuntu version 18.04 and later sudo a2enmod unique_id usertrack; sudo systemctl reload apache2 will do the trick and reload Apache, so the changes take effect. If you aren’t using Ubuntu, double-check how to enable Apache modules on the Linux distribution that you are using.

After mod_usertrack and mod_unique_id are enabled, they need to be activated and attached to the logs. The following configuration snippet will do that.

#Add configuration for user tracking to the log file
<IfModule mod_usertrack.c>
	CookieDomain .www.rrbrussell.com
	CookieExpires "2 weeks"
	#Requires >=2.4.42
	#CookieHTTPOnly on
	#CookieSameSite Strict
	#CookieSecure On
	CookieName Apache
	CookieTracking on
	LogFormat "%v:%{Apache}C %r %t %{UNIQUE_ID}e" usertrack
	CustomLog "${APACHE_LOG_DIR}/clicktracker.log" usertrack
</IfModule>

You will need to modify the CookieDomain, CookieExpires, and log destination to suit your system but this basic config will get you started. It outputs something like the following.

vhost             :tracking cookie        the request                              Timestamp                    Unique request identifier                                 
www.rrbrussell.com:689e322a.5adf4e2bd2d78 GET /2020/07/openwrt-on-x86-64/ HTTP/2.0 [28/Aug/2020:14:17:29 -0500] X0lYSSUCdg@45i0GT-H@qQAAAAE

I will write more on this topic in another few days. Until then.

—Robert

Another Quick Cash Grab In Blog Writing

I do not have any other copies or formats of this book to compare the audiobook against. There are a lot of word choice and usage problems in this audiobook. Most Americans would call someone who reads websites, books, or other forms of written language a reader. She consistently uses words like perusers instead of readers or subscribers.

Another example that stood out to me was. “Attempt to think of a lot of thoughts consistently and store them in an article schedule, spreadsheet, or some other spot you can catch notes.” (I had to go over that sentence about four or five times myself just typing it out here because I kept subconsciously correcting the phrasing.)

The author did an adequate job of laying each chapter’s content out in a reasonable way. However, I am worried about the overall order in the book.

If I only look at the chapter titles, the book appears to be laid out reasonably. However, I didn’t get a good sense of connection between the chapters. I noticed this problem more in the later chapters.

This book is not a howto book. It varies widely in the number of pieces a topic gets broken down into. None of the issues get covered in any suitable depth, though.

My overall score is shoddy. I do not suggest getting this book.

—Robert

SSH Clients For Windows

Here is a listing of my preferred SSH clients for Windows.

Windows has included a copy of OpenSSH enable by default since the April 2018 Update to Windows 10. The only downside to using it is the very basic default terminal in Windows. If we use Windows Terminal then it is an acceptable option though I prefer using one of the WSL distributions.

Bitvise SSH is a free, but not opensource, SSH client that was previously my default SSH client for Windows.

Putty is the old standard that I abandoned shortly after I found out about Bitvise.

There are a couple of other SSH options on the Microsoft store that I haven’t tried.

Enabling TLS 1.3 in Apache >=2.4.38

TLSv1.3 is now available on 85% of web clients, according to caniuse.com. Since I don’t have to support either Internet Explorer or the six microscopic mobile web browsers that don’t support it at all, I have gone ahead and migrated my servers straight over to TLSv1.3.

Below is a sample configuration that will enable TLSv1.3 and the currently recommended ciphers in a reasonable order. You must enable TLSv1.3 globally on the entire server. I made my adjustments in the /etc/apache2/mods-enabled/ssl.conf file. I gave Chacha preference to AES due to the number of mobile devices running modern browsers that don’t have AES hardware acceleration.

        #   SSL Cipher Suite:
        #   List the ciphers that the client is permitted to negotiate. See the
        #   ciphers(1) man page from the openssl package for list of all available
        #   options.
        #   Enable only secure ciphers:
        SSLCipherSuite TLSv1.3 TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384
:TLS_AES_128_GCM_SHA256

        # SSL server cipher order preference:
        # Use server priorities for cipher algorithm choice.
        # Clients may prefer lower grade encryption.  You should enable this
        # option if you want to enforce stronger encryption, and can afford
        # the CPU cost, and did not override SSLCipherSuite in a way that puts
        # insecure ciphers first.
        # Default: Off
        SSLHonorCipherOrder on

        #   The protocols to enable.
        #   Available values: all, SSLv3, TLSv1, TLSv1.1, TLSv1.2
        #   SSL v2  is no longer supported
        SSLProtocol -all +TLSv1.3