Matthew Ernisse

July 10, 2019 @16:00

Hooks are a great way to execute various tasks as part of your git(1) workflow. Since I run my own repository server I have plugged a number of different things into my repositories, both private and public. There are several previous posts where I discuss some of them.

git push output

To access my git repository there are in general 3 methods. I allow anonymous pulls via https using the built in HTTP helpers with Apache, authenticated pulls and pushes use ssh and gitolite, and finally there is both a public and private viewer using gitweb. The latter most automatically includes the contents of README.html in the root of the repository in the header of the project pages on the rendered website. I almost never remember to update it, so I set about writing a hook to take care of it for me. Since I have a bunch of hooks already I also added a way to have several hooks all get run from the main hook.

My git server's root is /srv/git, the repositories are in /srv/git/repositories, so I put my global post-receive hook in /srv/git/repositiories/global-hooks/. In all the different repositories where I already had a post-receive hook I created a hooks/post-receive.d/ directory and moved the hook into it with a descriptive name. For example the hook on my misc.git repository that creates the checksum file used by my .profile auto-updater is now called post-receive.d/checksum. I then wrote a small script to link the global hook into all my repositories.

If you are interested you can find the hook and the install script in my misc git repository.

June 25, 2019 @11:31

I am sure I am in the minority of mobile users (though probably not a small minority these days, especially among the technically apt) in that I try to only use mobile applications where they provide a large amount of concrete value over the mobile website. The inability to sanely audit applications in conjunction with their ability to exfiltrate way more data than a mobile website raises the bar I set to a much higher level.

I understand the application developer's desire to move users away from their mobile "web experience" into their application. I also understand the business reasons behind the whip that is being put to the developer's back, but for me I'd say 99% of the time the app is just too much risk.

I know I've complained about this before, but it seems like it just keeps getting worse. In fact it seems like Apple is getting in on the fad.

Twitter, begging you to use their app

Et tu, Amazon?

So please, I implore you. Stop doing this shit.

April 04, 2019 @09:35

I have mentioned a few times that I rely on OpenBSD VPNs to ensure that clients outside of my home network get the same level of protection as they do inside. This means that I can use already existing DNS and proxy infrastructure to prevent various malvertizing, tracking, beacons, and poorly behaved applications and websites from leaking personal information, and I can prevent wifi hotspots from analyizing my traffic or injecting JavaScript. Creating the actual infrastructure is out of scope for this post, but I did previously post some information about what the DNS configuration looks like.

Part 1: OpenBSD

Setting up a VPN with OpenBSD is extremely simple compared to the many alternatives. This is a large part of why I like OpenBSD so much. I have several site to site VPN tunnels as well as the road warrior configuration all terminating on the same iked(8) instance. In my case I use an internal certificate authority for all on-network SSL/TLS so it was fairly easy to extend that to authentication for my VPNs. You can run your VPN with a pre-shared key; however, for security purposes I cannot recommend that and will instead talk about the configuration as I have implemented it.

I'm going to assume you have generated a CA and certificate and key pair for your VPN server as well as your clients in PEM (PKCS1) format.

  1. Your CA's certificate goes in /etc/iked/ca/ca.crt. This can be a bundle of CA certificates to trust.
  2. Your VPN server's certificate goes in /etc/iked/certs/ and is named based on the ID you will be using. I use FQDNs for peer identification so mine is simply the hostname of the server. So something like /etc/iked/certs/
  3. The private key for your VPN server goes in /etc/iked/private/private.key
  4. Ensure you have pf(4) setup to properly allow traffic both to iked(8) and from the client tunnel(s) to the Internet (with NAT if you need it). For more information see pf.conf(5)

You should now be ready to tackle your iked.conf(5). Here you will need to make some choices based on your devices. You may need to look up their capabilities and test some of the options. I have used the following configuration with clients running iOS 12.2 and macOS 10.14.4. I consider this to provide the minimum viable security which is why I have the re-key lifetime fairly short.

ikev2 "RoadWarrior" passive esp \
        from to \
        peer \
        ikesa enc aes-256 \
                prf hmac-sha2-256 \
                auth hmac-sha2-256 \
                group modp2048 \
        childsa enc aes-256 \
                auth hmac-sha2-256 \
                group modp2048 \
        srcid \
        lifetime 180m bytes 16G \
        config address [ Addresses to assign to clients in CIDR ] \
        config name-server [ Your DNS server 1 ] \
        config name-server [ Your DNS server 2 ] \
        config netmask [ Dotted quad netmask for your client network ] \
        tag "$name-$id"

This rule should be first in your iked.conf(5) to ensure it is matched only if there is not another rule that is more specific. Please familiarize yourself with the iked.conf(5) manpage, it explains all the options available to you. The key here is that I'm setting up the tunnel to capture all IPv4 traffic from the client, and the client can come from any IPv4 address. This is part of why I don't use a pre-shared key for this. A pre-shared key could be easily compromised turning your VPN endpoint into an open proxy for all sorts of Internet ne'er-do-wells; however, if public key cryptography is being used you would have to leak a valid, signed certificate and corresponding private key. In that unlikely even you can always revoke that certificate and place a CRL in /etc/iked/crls/.

Make sure you read the iked(8) manpage, depending on your network setup you may find that you need one or more of the flags for reliable operation. In particular -6, and the -t, -T pair may be important to you.

Once you reach this point start up iked.

Part 2: macOS and iOS clients

Apple has included a reasonably fully featured VPN client in both macOS and iOS, though most of the connection configuration is not exposed via a GUI. I used Apple Configurator 2 to generate a configuration profile that can be installed on both macOS and iOS clients. You will need a CA certificate, and a client certificate and key pair. For clients I issue client only certificates which adds the benefit of the client cert not being considered valid to run a server with. In the extremely unlikely case of a compromised client, the certificate cannot be used to impersonate a server. You will want the CA certificate as a .PEM file (PKCS1) and the client certificate and key bundled in a .p12 (PKCS12) file to make the Apple Configurator happy.

Apple Configurator 2

The work flow for the Apple Configuration 2 utility is fairly straightforward. There are many more options available to you than what I will cover here. For example in my production deployments I include various device restrictions, I preload the WPA2-Enterprise configuration for my wifi SSID, configure my AirPrint printers, all alongside the VPN and certificate configuration shown here. This is just what you need to get a VPN connection going.

  1. Fill out the mandatory General page.
  2. Add your CA and client certificate bundles.
  3. Configure the VPN client, matching the authentication and transport settings from iked.conf(5) above.

Apple Configurator 2 General

Add Certificates

VPN Page 1

VPN Page 2

VPN Page 3

Manual Additions for Connect on Demand

I want my VPN to connect any time I'm not on a trusted wifi network. Thankfully Apple lets you connect to your VPN on demand with some simple rule based matching (see the VPN section of the Configuration Profile reference guide). Unfortunately the Configurator does not allow you to setup those rules in the GUI, so once you have your profile made you will need to add some keys into the plist. Open up the .mobileconfig you just created in a text editor and look for the chunk that looks like this.

            <string>Configures VPN settings</string>

To that dictionary you will need to add some additional keys to setup an OnDemand configuration. An example of the policy I use is below, but the reference document above describes the rules available in more detail. The example will start the VPN connection any time the device is not connected to the list of trusted wifi SSIDs and will automatically disconnect when the device connects to one of those trusted SSIDs.

            <string>Your Home SSID</string>
            <string>Your Other SSID</string>

Now install the profile and you should see your VPN appear in the Settings application. Once you leave your SSIDMatch networks you should see the icon at the top of the screen showing that you are now connected.

iOS VPN Indicator

Part 3: Errata and Caveats

This has worked really well for me for years now, however there have been edge cases. In particular I have found some cases where the captive portal detection in iOS doesn't work with the on demand VPN connection.

To disable your VPN in iOS open Settings and tap General, then scroll down to VPN and then tap the "i" next to your connection name. On the following screen de-select Connect On Demand. This will disable the OnDemandRules and let traffic flow out the normal wifi / cellular interfaces.

Real clear tap target, Apple...

Disable Connect On Demand

Since your device's Internet access will now be reliant upon your VPN tunnel you may way to look into adding high availability to your OpenBSD endpoint. The manpages for carp(4), pfsync(4), and sasyncd(8) are good places to start looking.

April 02, 2019 @18:10

I really don't want to sound like the old man yelling at a cloud here; however, sometimes you need to. When DRM first appeared as a way to sell digital goods on the Internet and prevent the dreaded piracy and sharing that was certain to be the downfall of all capitalism and hurl us into the darkest night, the Internet was, as you might expect quite put out.

Books Burning

The problem of course is that the digital age is littered with corpses of companies that couldn't possibly disappear. To make matters worse the morass that spawns companies in the post dot com era has such a death grip on anything that might even smell slightly like intellectual property that in death these companies often live on, like zombies, to eventually be sold off to recoup some of the venture capital that they were founded upon. What that ultimately means is that the DRM protected digital assets that customers licensed are almost always rendered useless.

Over the decades I have been involved in technology I have continued to prefer to have physical, or DRM-free digital versions of the things that I buy. Sometimes this means spending more money than the DRM encumbered, all digital versions; however, this is fine with me because at the end of the day these things will survive the almost certain death of the distributer from whom I purchased the items.

Sure, the cloud, and the digital economy are convenient. I will happily affirm the ease of use that Amazon, Apple, Spotify, Pandora, and others all bring to the consumer, often with minimal admonishment. At the end of the day though, the risk of the inevitable failure of the companies that store everything "for me" vastly outweighs the ease of use. The anxiety I would feel knowing that thousands of dollars worth of content, entertainment, culture, history, literature, and art could disappear from my grasp at the whim of a faceless corporation trying to fulfill its mandate to provide shareholder value is frankly not something I want in my life.

I more often than not find Cory Doctorow a little 'out there', but in this case he's spot on.

December 04, 2018 @11:00

I'm trying to figure out a way to balance the lack of surprise and schadenfreude I have at Tumblr/Verizon's decision to paint all sexual content with the regressive and transparent 'but think of the children' brush. Tumblr grew largely thanks to the alternative and adult communities that found its permissive and accepting nature welcoming. It became what it is today because of the LGBTQ+ and sex worker communities, and now it has decided to break up. Their post paints a pretty picture full of platitudes, inclusiveness, acceptance, and love of community but it is obvious to the most casual of observer that it is just a sham. Tumblr is breaking up with the people that helped it grow because it is easier than trying to actually make the service a better place.


I feel bad for the users that are being displaced, some of whom I have followed for close to a decade. I admit I do feel a bit like pointing and laughing at the management of Tumblr who just signed their product's own death warrant, but most of all I feel like this is yet another billboard for retaining control of your community, and your content. In an era with filled with social media companies promising to help you build communities and share content it is more important than ever to remember that at the end of the day they all will betray you eventually because you aren't their customer, you are their product. At some point your needs will clash with theirs and they will without remorse chose themselves every single time.

Anyone who creates anything on the Internet needs to relentlessly protect their community by ensuring that they have control. I am sure it sounds a bit bizarre to some but if you are going to use services like social media to engage people (which you basically have to right now) you need to act like any day you could wake up and find them gone. You need to ensure that people can find you again, that your content and community doesn't just disappear and that you can move on to whatever comes next.

Tumblr will die, the Internet will move on. In a couple years it will be another story the olds tell the kids these days, but hopefully... we learn. In the mean time, I'm firing up grab-site and archiving the people I have followed on Tumblr for the last 10 years. Hopefully we will cross paths again.

To The Archive Mobile!

For creators, find a way to root your community in something you control. Go pay Ghost or a similar host to house your blog. Domain names are cheap these days, I like Gandi but there are many places that will sell you one. Resist the urge to get a free blog with a free url. Being is no less risky than being It's not expensive, or difficult anymore to maintain a presence online where you are the customer. It isn't perfect, but at least when you own the domain name if you need to change providers your address stays the same and your community can follow you to your new home. Link everything to your blog and link your blog to everything. Make it the clearing house for all that you are doing, make it easy for your community to follow you when the inevitable happens.

For members of communities, and followers of creators, if it isn't clear where to go next reach out to the creators. Many of them are scrambling to find a place to land or to let all their followers know where else they can be found. If you don't know ask, and politely suggest they think about creating a place they own to anchor their community if they havne't already..

November 26, 2018 @15:30

While I was waiting for new tires to be put on my car today I was able to watch the landing of Mars InSight which was relayed via the MarCo A&B experimental interplanetary cube sats.

Misson Control as touchdown was confirmed

Since everything worked so well we even got back a picture from the lander mere moments after landing was confirmed.

Hello, Mars

Congratulations to everyone involved in this mission, I'm excited to see what we learn not only about our friend the red planet but also about the continued feasibility of the cube sat program. Maybe we'll see something like the PlanetLabs Dove cube sat streaking towards Mars someday.

MarCo Relay Animation from NASA/JPL-Caltech

November 07, 2018 @23:30

A little over six and a half years ago I left the Linux as a desktop community for the Mac community. I replaced a Lenovo Thinkpad T500 for an Apple refurbished late 2011 MacBook Pro and honestly have not regretted it.

Over the years I maxed out the memory, went from the 500G SATA HDD to a Crucial 256GB SSD, then put the 500G HDD in the optical bay, then upgraded to a Samsung EVO 512GB SSD with the optical drive back in there. I replaced the keyboard twice, the battery twice, and had the logic board replaced out of warranty for free by Apple thanks to the recall for an issue with the discrete graphics. Through all that it quite happily chugged along and for the most part just worked. Even now it's in better shape than most of my old laptops, but the lid hinge is starting to get weak (it will often just slowly close itself on me), it needs yet another new battery, and the inability to run the latest macOS lead me to conclude that it is time to look for an upgrade.

Old Laptops

It ended up being a bit of a challenge to decide on an upgrade, though. I really like the 13" Retina MacBook Pro I have for work, I really like the portability of the MacBook, and the new MacBook Air looks like a great compromise between the two. I fought with myself for quite some time over what would come next for me and finally settled on a 15" Mid-2015 Retina MacBook Pro. Essentially the bigger brother of what I have for work.

Hello, Kitsune

Now I won't blame you if you are wondering why I'd pick a 3 year old laptop over the latest and greatest. In the end it was almost the only choice. I wanted a 15" class laptop because I spend most of my time computing sitting on the couch. The 13" is really nice and portable but it's actually a little too light and a tad too small to comfortably use on my lap. That basically ruled out the lighter and smaller MacBook and MacBook Air. As for the newer 15" MacBook Pro, I almost exclusively use the vi text editor so not having a hardware escape key is just not something I feel I can get used to. I've also heard many people at work who do have the new MacBook Pros complain loudly about the keyboard so that was another nail in the coffin of the new models.

Given all that, the last non-touchbar 15" MacBook Pro is... the Mid 2015. I found a nice example with the 2.5GHz i7 and the Radeon R9 on eBay for a real good price after a few weeks of looking and snapped it up.

Since this is the second Mac I've ever had as my primary workstation it was the first time I got to use Migration Assistant. I have previously used recovery mode to recover from Time Machine which works a treat so I had high expectations. In the end I'd say the experience lived up to them. The only real problem I had seems to be related to how I have my WiFi configured. I use WPA2 Enterprise (so username and password authentication) on my main SSID which I configure using a profile in macOS (which also serves to disable Siri, a bunch of iCloud stuff I don't use, sets up my internal certificate trust settings, and my VPN). Every time I started up Migration Assistant it would drop off the WiFi with no explanation. After flailing around a bit it looks like that was because it couldn't access the authentication information after logging me out to start the migration, so I figured I'd use Ethernet. That would have worked except that the laptop showed up on a Saturday and the only Thunderbolt to Ethernet adapter I own was at the office. Thankfully my guest WiFi uses WPA2 PSK and that actually appears to work just fine.


It took about 4 hours to transfer the 210GB or so of data, but afterwards the new Mac looked just the same as the old Mac. A quick run through my customization script to catch the few settings in the new version of macOS, the automounter, and the applications I have installed via homebrew, I have not had to go back. Sunday evening I shut off the old laptop. I do plan on re-deploying it as a test workstation if I ever get around to building a dedicated test environment, but for now it is sitting in a drawer under my desk.

It's been a good laptop and this new one has big shoes to fill.

Goodbye, Aramaki


September 27, 2018 @11:30

I was making some firewall changes last weekend and while watching the logs I discovered that every now and then some host would try to connect to on port 80. This was peculiar since I don't use the IPv4 link local addresses anywhere in my network. It seemed to be happening randomly from all of my Linux hosts, both physical and virtual.

If the processes originated on my firewall which is running OpenBSD I'd be able to track down the process that was doing this by adding a more specific rule with "log (user)" to pf.conf(5) but it seems that Linux dropped this ability from Netfilter sometime back in the 2.6 time frame. 😢

The part that makes this a bit unique is that this is a connection that will certainly fail. It trips a rule in my firewall that blocks bogons outbound on my WAN interface which means that the normal tools like netstat(1) and lsof(8) will only reveal anything if I somehow catch the process between the execution of the connect(2) system call and it failing. What I need to be able to do is log in real time what is happening, which I could do with something like strace(1) but I'd need to know the PID of the process and that is what I'm trying to find out.

So off I went looking for other things that might be helpful and stumbled upon the Linux kernel audit system. The audit system has been around for a while and lets you ask the kernel to communicate the details of syscalls as they happen. There is a filtering mechanism built in so that you don't end up dumping too much information or dramatically impacting performance and the raw data is sent to a userland program via a netlink socket. By default most distributions ship auditd, which listens on that netlink socket and dumps all the messages into a log.

Since I am looking at an attempted TCP connection the connect system call is the one I am interested in. I don't know much else about it though so it turns out a pretty simple filter rule is what I was looking for.

$ sudo auditctl -a exit,always -F arch=b64 -S connect

This asks the kernel to log upon exiting of the syscall any calls to connect(2). This immediately started flooding the audit log with entries like:

type=SYSCALL msg=audit(1538057732.986:13752): arch=c000003e syscall=42 success=yes exit=0 a0=12 a1=7ffc987e28c0 a2=6e a3=7f20abf93dd0 items=1 ppid=9803 pid=19584 auid=4294967295 uid=33 gid=33 euid=33 suid=33 fsuid=33 egid=33 sgid=33 fsgid=33 tty=(none) ses=4294967295 comm="apache2" exe="/usr/sbin/apache2" key=(null)
type=SOCKADDR msg=audit(1538057732.986:13752): saddr=01002F746D702F7...
type=CWD msg=audit(1538057732.986:13752): cwd="/"
type=PATH msg=audit(1538057732.986:13752): item=0 name="/tmp/passenger.PIT9MCV/agents.s/core" inode=1499146 dev=fe:01 mode=0140666 ouid=0 ogid=0 rdev=00:00 nametype=NORMAL
type=PROCTITLE msg=audit(1538057732.986:13752): proctitle=2F7573722F7362696E2F617...

OK, so I'm getting closer but obviously some of the data is coming out in some packed hex format and the things I want aren't all on the same line so I need to figure out how to decode this. While searching for the format of the messages in hopes of writing a quick and dirty parser I found ausearch(8) which includes the handy -i option.

I fired up tcpdump(8) on the pflog(4) interface and waited for one of the packets to be dropped. That let me find what I was looking for in the audit log... the culprit.

ausearch and tcpdump to the rescue

It turns out it was a puppet agent run. Now I know none of my modules try to talk to that address but puppet does a lot of things including running facter to get information about the system and the environment it is running in. I know some cloud infrastructure has standardized on that address as a location for guest agents to pick up metadata from so I suspected some default module trying to see if we are running on a cloud provider. A quick locate(1) and grep(1) later and it turns out that the built in facter ec2 module does in fact try to pull metadata from

apollo@10:16:49 1.8T ~ >locate facter
[ ... many paths elided for brevity ...]
[ ... many more paths ...]
apollo@10:16:53 1.8T ~ >grep -R /usr/lib/ruby/vendor_ruby/facter/*
/usr/lib/ruby/vendor_ruby/facter/ec2/rest.rb:      DEFAULT_URI = ""
/usr/lib/ruby/vendor_ruby/facter/ec2/rest.rb:      DEFAULT_URI = ""
/usr/lib/ruby/vendor_ruby/facter/util/ec2.rb:      url = ""
/usr/lib/ruby/vendor_ruby/facter/util/ec2.rb:  # GET request for the URI  If the
/usr/lib/ruby/vendor_ruby/facter/util/ec2.rb:    uri = "{version}/user-data/"

So in the end, the Linux audit system is our friend. There is a lot of other cool stuff in there, I ran across a post from the slack engineering team that talks about how they use the audit system and how they leverage this information to alert on and challenge user actions in real time. It is also a cautionary tale that good network hygiene is important since you never know what random things you might leak out onto the Internet (or your ISP's network) if you aren't careful.


September 16, 2018 @15:00

I installed one of the Mojave public betas last week on the Mac Mini I have in the office. I used it as an excuse to finally tweak a script I wrote for customizing macOS out of the box.


I'll annotate inline below, you can snag the original if it looks useful to you. The first hunk is just standard shell boilerplate. I tend to write POSIX shell and eschew any bash specific nonsense for maximum compatibility.

# install-macos (c) 2017-2018 Matthew J. Ernisse <>
# All Rights Reserved.
# Customize a base macOS install.
# Redistribution and use in source and binary forms,
# with or without modification, are permitted provided
# that the following conditions are met:
#     * Redistributions of source code must retain the
#       above copyright notice, this list of conditions
#       and the following disclaimer.
#     * Redistributions in binary form must reproduce
#       the above copyright notice, this list of conditions
#       and the following disclaimer in the documentation
#       and/or other materials provided with the distribution.

set -e

I don't use iCloud, I run ownCloud instead. This just makes the directory I use to sync my files to/from.

    if [ ! -d "$HOME/Documents/cloud" ]; then
        echo "Creating ownCloud directory"
        mkdir -p "$HOME/Documents/cloud"

Disable more things I don't use or care about. Touristd is a bit annoying because they can push more crap to bother you with down the line. This at least shuts it up after initial install.

    echo "Disabling Siri"
    defaults write StatusMenuVisible -bool false
    defaults write UserHasDeclinedEnable -bool true
    defaults write 'Assistant Enabled' 0

    defaults write \
        seed- \
        -date "$(date)"

Set a whole bunch of system preferences. Disable automatic spelling and unicode quote correction. Set my preferred Finder style (list view), and enable daily update check and installation. Also try to keep finder from crapping .DS_Store folders all over the network shares.

    echo "Writing various macOS defaults"
    # I suspect I am missing some...
    defaults write NSGlobalDomain AppleKeyboardUIMode -int 3
    defaults write NSGlobalDomain AppleICUForce24HourTime -int 1
    defaults write NSGlobalDomain AppleAquaColorVariant -int 6
    defaults write NSGlobalDomain AppleInterfaceStyle "Dark"
    defaults write NSGlobalDomain \
        AppleMiniturizeOnDoubleClick -bool false
    defaults write NSGlobalDomain AppleShowScrollBars "Always"
    defaults write NSGlobalDomain ApplePressAndHoldEnabled -bool false
    defaults write NSGlobalDomain \
        NSAutomaticCapitalizationEnabled -int 0
    defaults write NSGlobalDomain \
        NSAutomaticDashSubstitutionEnabled -int 0
    defaults write NSGlobalDomain \
        NSAutomaticPeriodSubstitutionEnabled -int 0
    defaults write NSGlobalDomain \
        NSAutomaticQuoteSubstitutionEnabled -int 0
    defaults write NSGlobalDomain \
        NSAutomaticSpellingCorrectionEnabled -int 0
    defaults write NSGlobalDomain \
        NSAutomaticTextCompletionEnabled -int 1
    defaults write NSGlobalDomain NSCloseAlwaysConfirmsChanges -int 1

    defaults write -int 1
    defaults write disable-shadow -bool true
    defaults write FXPreferredViewStyle -string '"Nlsv"'

    # Check for updates automatically, daily, and auto-install
    # security updates
    defaults write \
        AutomaticCheckEnabled -bool true
    defaults write ScheduleFrequency -int 1
    defaults write AutomaticDownload -int 1
    defaults write CriticalUpdateInstall -int 1

    # Don't shit .DS_Store all over the show.
    defaults write \
        DSDontWriteNetworkStores true

As it says, install my internal CA into the trust store.

# Install and trust my local CA.
    echo "Installing CA, you will be prompted for your password"
    local tmpfile=$(mktemp)
    curl --fail \
        --silent \
        --location \
        --insecure \
        --output $tmpfile \

    security add-trusted-cert \
        -k "$HOME/Library/Keychains/login.keychain-db" \

    rm $tmpfile

This gets called to install homebrew and a bunch of applications. There is a nasty hack later as the script needs to be run with sudo, but homebrew won't work that way.

# I hate you so much homebrew for having a fucking trustmeprompt shell
# pipe to a thing installer.  Fuck you.
    echo "Installing Homebrew and sundry applications"
    /usr/bin/ruby -e "$(curl -fsSL"
    brew analytics off
    brew install caskroom/cask/docker
    brew install caskroom/cask/firefox
    brew install caskroom/cask/iterm2
    brew install caskroom/cask/owncloud
    brew install caskroom/cask/visual-studio-code
    brew install caskroom/cask/vnc-viewer
    brew install caskroom/cask/vlc
#   broken?!
#   brew install caskroom/fonts/font-inconsolata
    brew install imagemagick
    brew install flake8
    brew install ffmpeg
    brew install fdk-aac-encoder
    brew install gnupg
    brew install gnutls
# this doesn't seem to function correctly.
#   brew install opensc
    brew install pass
    brew install tmux
    brew install telnet
    brew install pwgen
    brew install wget

Setup my default shell environment.

    echo "Installing .profile"
    curl --fail \
        --silent \
        --location \
        --output "$HOME/.profile" \

Setup autofs, this gets customized a bit for different sites. It also setups the client to match my NFSv4 configuration.

    local nfs_server=""
    local shares="/vol/staff/mernisse /vol/backup /vol/media"
    echo "Setting up NFS automount."

    if [ ! -d "$HOME/Shares" ]; then
        mkdir $HOME/Shares

    if [ ! -f /etc/auto_nfs ]; then
        touch /etc/auto_nfs
        chown root:wheel /etc/auto_nfs
        chmod 644 /etc/auto_nfs

    for share in $shares; do
        if ! grep -q "nfs://$nfs_server$share" /etc/auto_nfs; then
            echo "$(basename $share)        nfs://$nfs_server$share" \
                >> /etc/auto_nfs

    if ! grep -q "$HOME/Shares  auto_nfs" /etc/auto_master; then
        echo "$HOME/Shares  auto_nfs" >> /etc/auto_master

    if ! grep -q nfs.client.default_nfs4domain /etc/nfs.conf; then
        echo "nfs.client.default_nfs4domain = localdomain" >> /etc/nfs.conf

    automount -c

This just says hello and is called at the start of the script.

    local reset="\033[0m"
    local green="\033[32;1;m"
    local yellow="\033[33;1;m"
    local red="\033[31;1;m"
    local magenta="\033[35;1;m"
    local blue="\033[34;1;m"
    local cyan="\033[36;1;m"

    local hello=" ${green}H${yellow}e${red}l${magenta}l${blue}o${reset}"
    hello="${hello}, I am the Macintosh. "

    hello="${hello} $(sysctl -n hw.model)"
    hello="${hello} ${cyan}macOS $(sw_vers -productVersion)${reset}"

    printf "$hello\n"

The default uid/gid doesn't match my network so I change it here. This is why the script needs to be run as root. You do have to be careful with this since it can do wonky things to your login session once it does what its thing.

    if [ "$(id -u mernisse)" -eq 1000 ]; then

    echo "Setting uid to 1000 and creating media group"
    dscl . -change $HOME UniqueID $SUDO_UID 1000
    dseditgroup -o create -i 1042 media
    dseditgroup -o edit -a mernisse media
    echo "Changing ownership of $HOME to reflect new uid"
    chown -R 1000 $HOME

This is the start of execution. It checks to see if you are running as root or doing the homebrew step.

# ublock origin?
if [ ! "$UID" -eq 0 ] && [ ! "$1" = "homebrew" ]; then
    echo "Please run this script with sudo(8)."
    exit 1

Catch the homebrew install which needs to be run as the user, not as root.

if [ "$1" = "homebrew" ]; then
    echo "Returning to sudo session..."

Call all the stuff above.


I replaced all the spinning disks with SSDs a while ago. So I don't need the sudden motion sensor..

echo "Disabling SuddenMotionSensor"
pmset -a sms 0

Some finder related things here. I don't like things being hidden.

echo "Unhiding /Volumes and ~/Library"
chflags nohidden ~/Library
chflags nohidden /Volumes

locate is a good thing to have.

echo "Enabling locatedb"
launchctl load -w /System/Library/LaunchDaemons/

This re-executes the script as the user that ran sudo. This is done to make homebrew happy.

echo "Dropping privs to $SUDO_USER to install homebrew"
echo "************************************************"
# This is a hack...
sudo -u $SUDO_USER $0 homebrew

Finally, change my UID and GID if needed.

# Do this late, because my window session will still have the old UID cached
# it gets... wonky.

And that's it. There is still a few things I have to do manually, including installing a Configuration Profile with my WiFi and VPN settings but it really reduces the amount of things that I have to do to get a new macOS install up and running. 👍 🥃

September 15, 2018 @16:40

For a while now I've used a Yubikey Neo as a PIV card to authenticate to my public facing hosts. This is fairly straightforward but requires a host with OpenSC on it. In my .profile I have a function called add_smartcard which will add the PIV driver to the ssh-agent. This means I actually authenticate with the key that was generated in the Yubikey and not my password.

Yubikey in my laptop

# add_smartcard - Add the PIV key to the current ssh-agent if available.
# Requires a opensc compatible smartcard and associated libs and binaries.
    # Set to a string in the opensc-tool(1) -l output for your card.
    local _card_name="Yubikey"

    # set to the installed location of the opensc libraries.
    # on OSX with HomeBrew this is /usr/local/lib
    local _lib_dir="/usr/local/lib"

    if ! quiet_which opensc-tool; then

    if [ -z "$SSH_AUTH_SOCK" ]; then

    if opensc-tool -l | grep -q "$_card_name"; then
        if ssh-add -l | grep -q opensc-pkcs11; then

        ssh-add -s "$_lib_dir/"


    # If card is no longer present, remove the key.
    if ssh-add -l | grep -q opensc-pkcs11; then
        ssh-add -e "$_lib_dir/" > /dev/null

Yubikey PIV Authentication

This is all well and good but I wanted to have stronger authentication for scenarios when I'm not on one of my computers. I also wanted to ensure other users of my systems were protected since I can't force them to use PIV cards for authentication. I did a little research and found pam_oath which supports both sequence based and time based one time passwords. This means it is compatible with the OTP profile on the Yubikey and authenticator based apps like Google Authenticator.

The parts I did with Puppet

The first part is pretty straightforward so I setup a Puppet module to do it for me. You need to have the PAM module installed, add it to the sshd pam.d policy, and update your sshd_config.

I am using Debian 9 but you should be able to adapt the following to most Puppet setups and distributions.

# Setup OATH (HTOP) modules/oath/manifests/init.pp
class oath {
  package { 'libpam-oath':
    ensure => latest,

  package { 'oathtool':
    ensure => latest,

  service { 'sshd':

  file { '/etc/users.oath':
    ensure => present,
    owner => root,
    group => root,
    mode => '0600',

  augeas { 'add':
    context => "/files/etc/pam.d/sshd",
    changes => [
      'ins 01 after include[. = "common-auth"]',
      'set 01/type auth',
      'set 01/control required',
      'set 01/module',
      'set 01/argument[last()+1] usersfile=/etc/users.oath',
      'set 01/argument[last()+1] window=20',
    onlyif => 'match /files/etc/pam.d/sshd/*/module[. = ""] size == 0',

  augeas { 'set ChallengeResponseAuthentication':
    context => '/files/etc/ssh/sshd_config',
    changes => [
      'set ChallengeResponseAuthentication yes',
    onlyif => 'match /files/etc/ssh/sshd_config/ChallengeResponseAuthentication != "yes"',
    notify => Service['sshd'],

Things I didn't do with Puppet

The last thing you need is to initalize your shared secrets. I didn't want to do this with Puppet since I felt the need to control where the secrets were and minimize their exposure. The way I have pam_oath configured they will ultimately live in a file called /etc/users.oath. Make sure this is owned by root and has mode 0600. There are two examples that follow for creating the secret. One is for the OATH-HOTP used in the Yubikey, the other is for TOTP which most authenticator apps use (I use the One Time Password feature built into the Hurricane Electric Network Tools app on iOS, but I tested this with Google Authenticator as well).

Create a secret for the Yubikey

> dd if=/dev/urandom count=1 bs=1k 2>/dev/null | sha256sum

Put the returned hexadecimal string into your Yubikey as the shared secret.

Yubico Personalization Tool

Create a secret for an authenticator app

> dd if=/dev/urandom count=1 bs=1k 2>/dev/null | sha256sum | cut -b 1-30
> oathtool --totp -v <hexadecimal key from above>

So if your randomly generated key is 01ab5d053493a266172b16248a8377 then you would see:

imladris@15:27:29 ~ >oathtool --totp -v 01ab5d053493a266172b16248a8377
Hex secret: 01ab5d053493a266172b16248a8377
Digits: 6
Window size: 0
Step size (seconds): 30
Start time: 1970-01-01 00:00:00 UTC (0)
Current time: 2018-09-15 19:37:58 UTC (1537040278)
Counter: 0x30DC773 (51234675)


I used the Python module qrcode which includes a command line utility called qr to generate the configration QR code for the authenticator app. Using the above output of oathtool as an example this is how I made the QR code.

qr "otpauth://totp/<user>@<host>?secret=AGVV2BJUSORGMFZLCYSIVA3X" > qr.png

You can find more information about the otpauth:// uri format on Google's GitHub wiki.


Regardless of which mode you are using you'll need to add the secret to the users.oath file (I am using the example secret from above).

# Yubikey
HOTP    user1   -   01ab5d053493a266172b16248a8377
# Authenticator App
HOTP/T30/6  user2   -   01ab5d053493a266172b16248a8377    

The second line automatically increments the code every 30 seconds. In both cases they will expect a 6 digit code but in the second form it is explicit.

SSH with One Time Password

You can have different users with different methods. There are more complex PAM methods available if you don't want everyone to be required to use MFA or key based authentication, for example this is a good writeup that includes group or host exclusions. I feel like that provides an attacker the ability to work around your MFA.

In the end this probably took me long to write about than actually do and it's enhanced the security of my systems without any negative impact with one exception.

I use Panic's Transmit from time to time and I'm cheap so I have not upgraded to 5.0 yet. It turns out that they don't support the OTP prompt (in 4.0 at least). You can use a custom SSH key, and I believe you can restrict that key to sftp only so I may look into that as a workaround.

In any case there is really no reason you can't secure your servers now.


September 02, 2018 @12:45

Recently I had a rental VW with the fancy new radio in it and I figured I'd give CarPlay a shot.


Welp, I guess I won't be needing that feature when I buy a new car.

August 29, 2018 @09:20

I've been stewing about this for a while and have not yet found an alternative so this is part rant part dear lazyweb plea.

Goodbye, Sonos.

Sonos recently released the 9.0 version of their software which now requires you to have a Sonos account. I have zero desire to sign up for an account or be be in a situation where my home stereo equipment needs to connect to the Internet just to work so I'm actively looking to replace all the Sonos equipment in my home with something else. At the moment the leading idea is to just sprinkle Bluetooth speakers around the house. I don't see any drawback to this approach. with the exception of the Since you need to use a phone or tablet to control the Sonos system there isn't any real drawback to just using Bluetooth audio streaming directly to a speaker.

Honestly since they never got AirPlay or the Android audio streaming equivalent working (for no clear reason since both have been available on Raspberry Pis for YEARS now), nor did they ever support anything other than optical Dolby Digital on the Play:Bar and Play:Base TV speaker products, and since their controller applications just keep getting worse and worse, I am not sad about leaving them. For me, the only nice thing about their hardware that I have found over the years that is missing from most modern network speakers is the inclusion of Ethernet.

So if anyone out there dear lazyweb has an idea of a replacement that doesn't need the cloud to provide base functionality I'd be interested in hearing about it.

🔊 🍸

August 27, 2018 @17:10

For a long time now the core of my ad blocking strategy has been squid and privoxy running on my OpenBSD routers. Mobile devices VPN into the network and receive a proxy.pac which routes all traffic to these proxies which reject connections to known ad hosts. With the growing adoption of HTTPS (thankfully) privoxy is becoming less and less useful so I have been trying to find better ways to block ads at the networking level.

I'm not going to get into the ethics of ad blocking, it's my choice to make but I will leave this here.

Tay Tay says block ads (source)

Around the same time CloudFlare announced, a privacy focused anycast DNS service. I've been using the Level 3 anycast DNS resolvers for a while now but that's not exactly optimal. With CloudFlare's resolvers you get not only a geographically distributed DNS resolver cluster but DNS-over-TLS and DNS-over-HTTPS support.

Now I run ISC BIND for resolvers, which at this point doesn't support either encrypted DNS method. I do support and validate DNSSEC but that doesn't keep people from eavesdropping on me.

Enter unbound

For a while now OpenBSD has had unbound as the recursive resolver in the base installation so I've been aware of it and trust it. Since I do both recursive and authorative DNS on the same servers I have not had a reason to introduce it. Until CloudFlare.

I added the unbound packages to my DNS server's puppet manifest so the default Debian package got installed. I then added the following configuration to /etc/unbound/unbound.conf.d/cloudflare.conf. Since I'm going to have BIND actually listen to and respond to queries from clients I bind only to localhost (::1 is the IPv6 loopback address) and listen on a non-standard DNS port (5300 since it was open and semi-obvious). This does mean that I have two layers of cache to worry about if I need to clear the DNS cache for any reason but I almost never have to do that so I will worry about that later.

unbound configuration

# This file is managed by Puppet.
# Forward DNS requests to CloudFlare using DNS over TLS.
    verbosity: 1
    use-syslog: yes
    do-tcp: yes
    prefetch: yes
    port: 5300
    interface: ::1
    do-ip4: yes
    do-ip6: yes
    prefer-ip6: yes
    rrset-roundrobin: yes
    use-caps-for-id: yes
    name: "."
    forward-ssl-upstream: yes

I then switched the forwarders section of my named.conf from:

    forwarders {;;


    // Unbound listens on [::1]:5300 and forwards to CloudFlare
    forwarders {
        ::1 port 5300;

After letting puppet apply the new configuration I checked the outbound WAN interface of my router with tcpdump(8) and verified that all DNS resolution was heading off to CloudFlare.

Adding adblocking

unbound(8) has a really nice feature where you can override recursion fairly easily. This can be leveraged to block malicious sites at the DNS layer. I found a couple lists that I was able to plug in that so far have worked really well for me.

The first one is a malware block list that is already provided in the unbound config format. So I just used puppet-vcsrepo to ensure an up-to-date copy is always checked out in /usr/local/etc/unbound/blocks. I was then able to add include: "/usr/local/etc/unbound/blocks/blocks.conf" to the server: section of my unbound config.

Since I also wanted ad blocking I continued my search and came across Steven Black's curated list that consildates a number of difference sources into a hosts.txt format file. Since this isn't exactly the format unbound wants I had to do a little more work.

  1. Checked that repository out with puppet-vcsrepo into /usr/local/etc/unbound/stevenblack.
  2. Wrote the script below to convert the list format from a hosts file to an unbound configuration file.
  3. Configured puppet to exec that script when the vcsrepo pulls an update and then notify (restart) the unbound service.
  4. Added include: /usr/local/etc/unbound/stevenblack.conf to my unbound configuration.

unbound-blocklist script

# unbound-blacklist (c) 2018 Matthew J Ernisse <>
# Generate an unbound style config from a hosts list.

set -e


if [ ! -f "$SRC" ]; then
    echo "Could not open $SRC"
    exit 1

awk '/^0\.0\.0\.0/ {
    print "local-zone: \""$2"\" redirect"
    print "local-data: \""$2" A\""
}' "$SRC" > "$OUTPUT"

The entire puppet manifest for the unbound configuration is as follows. It is included by the rest of the manifests that setup BIND on my name servers.

unbound Puppet manifest

# Unbound - This is the caching recursor.  Uses DNS-over-TLS
# to CloudFlare to provide secure and private DNS resolution.
class auth_dns::unbound {
    package { 'unbound':
        ensure => latest,

    service { 'unbound':
        ensure => running,

    file { '/etc/unbound/unbound.conf.d/cloudflare.conf':
        source => 'puppet:///modules/auth_dns/unbound.conf',
        owner => 'root',
        group => 'root',
        mode => '0644',
        require => [
        notify => [

    exec { 'rebuild unbound blacklist':
        command => '/usr/bin/unbound-blacklist',
        refreshonly => true,
        require => [
        notify => Service['unbound'],

    file { '/usr/bin/unbound-blacklist':
        ensure => present,
        source => 'puppet:///modules/auth_dns/unbound-blacklist',
        owner => root,
        group => root,
        mode => '0755',

    file { '/usr/local/etc/unbound':
        ensure => directory,
        owner => root,
        group => root,
        mode => '0755',

    vcsrepo { '/usr/local/etc/unbound/blocks':
        ensure => present,
        provider => git,
        source => '',
        revision => 'master',
        require => [
        notify => Service['unbound'],

    vcsrepo { '/usr/local/etc/unbound/stevenblack':
        ensure => present,
        provider => git,
        source => '',
        revision => 'master',
        require => [
        notify => Exec['rebuild unbound blacklist'],


So far it feels like a lot of things load faster. I am noticing less requests being blocked by privoxy and squid, to the point that I'm thinking I may be able to completely depricate them. It is also nice that devices on the network that don't listen to proxy.pac files are now being protected from malware and malvertizing as well.


August 26, 2018 @11:30

iPictureFrame and XCode

I know I'm not 'average' when it comes to my opinions about technology. I imagine this has to do with growing up with technology that was much more simplistic than it is today. Compared to modern software and hardware the NEC PowerMate 286 running DOS 6.0 that I learned to program on was extremely simple. Not that it wasn't powerful, but it didn't have any designs to hide things from you. You had access to the hardware directly, and all the memory, and all the peripheral I/O space. You were able to completely control the system, and even understand exactly what was going on.

Not today.

Don't get me wrong, this isn't a bad thing. The protections in modern operating systems are required for the interconnected (and hostile) world we live in. Computers are also powerful enough that you can afford to give the user an API instead of direct access to the hardware (with all the risks that come along with that). The real problem I have is when vendors decide to lock down their consumer hardware to prevent the user from running whatever software they would like on it.

I could easily go off on a rant about Android devices with locked boot loaders, or "smart" TVs with the unnecessary, non-removable, and often poorly supported, and under powered guts, or a myriad of the unfortunate decisions manufacturers are making these days. But that's not what has been bugging me lately. I, like many people if their quarterly filings and trillion dollar valuation is to be believed, have spent a fair amount of money on iOS powered hardware. I expect when I buy a thing that I can basically do whatever I want with it. Now I really do love the security by default stance of iOS but I also believe firmly that as the owner of the device, if I want to shoot myself in the foot, I should be allowed to peel off the warranty void if removed sticker and fire away.

Fucking Apple...

Of course the worst part is that it's not that I'm not allowed to run my own code on my iOS devices. If I have a Mac, and install XCode, and sign up for an Apple Developer account, then for 6 days at a time I can run something I wrote on the thing I bought. To be clear, I'm 100% fine with that being the App Store development experience, however what I want to do is write code for my own personal use on my own personal devices. I don't want any of this software to be transmitted to Apple to be put on the store, or sent in binary form to another person. All I want to do is run my own stuff on things I own.

Now I do understand that my particular use-case might be a bit outside the middle of the bell curve, but I think this is an expectation that isn't unreasonable. I would also point out that if you want to encourage people to learn to code, it might be a good idea to let them actually run their code, and live with it before trying to make a buck off it. In this world of launch early, release often and fix it in a patch release we really do need more people who are used to living with the choices they make. In my case I wrote a silly streaming audio player to help me fall asleep at night that requires a fair amount of infrastructure behind it, so I would never distribute it as a compiled binary, but I'd really like to not have to reload it on my device every 6 days. Similarly I have an iPad 1 and an iPad 2 that are basically useless but would make nice digital picture frames... if only I could run the app that I wrote for more than a few days without having to reload the code on them.

If anyone out there at Apple is listening, I'd really like a way to make my iOS devices trust my internal CA for code signing. Is that really so much to ask?


August 25, 2018 @12:00

UniFi Switches in the NMS

Since I installed the first bits of the Ubiquiti UniFi family of products in my network I have been impressed. They have never failed to meet my expectations. I have written several articles about some rather advanced configuration and implementation details:

And of course I have written several generally glowing reviews about the product line.

The only thing I've been missing is the UniFi switch products. Until recently I have not had a burning need for switches, I had plenty and they worked fine. However, similar to the story of the UniFi USG that replaced a wonky MikroTik RouterBoard I started to have problems with the switch in my detached garage.

Old Garage Linksys

I did actually look around a bit when choosing a switch, there are 3 devices in the garage that are powered by PoE that I really wanted the switch to provide. The Linksys did 802.3af PoE, but two of the 3 devices use the "passive PoE" which isn't compatible so I really wanted to either find a dual mode switch or a source for 802.3af to passive PoE adapters.

Well, the UniFi Switch 8-150W fit the bill perfectly. It has the ability to provide 802.3af, 802.3at (PoE+), and passive PoE over its 8 RJ-45 ports and sports 2 SFP cages as well. As with all the other UniFi stuff installation and configuration was a breeze (in fact I did it using the iOS app while standing in my garage during a downpour), and it has been completely problem free since installation (despite several 100+ degree days where I'm sure the poor thing has roasted).

New Garage USW8-150W

In fact, it worked so well that I kept poking around the UniFi switch line and discovered that there was another switch that scratched a rather odd itch.

At the office, the LAN is provided by the landlord. It is a combination of cable Internet and a bunch of Cisco Meraki gear. I have a PoE+ powered jack in my office that I use for my personal equipment but have not been able to take advantage of it so I have an unsightly mess of power cables and PoE injectors hanging about. Turns out the UniFi Switch 8 (USW8) has just the thing. Port 1 can consume PoE and power the device while port 8 can provide PoE to a downstream device. I was able to eliminate a bunch of crap by dropping in one of these as it was powered from the Meraki switch and in turn powered the downstream access point.

USW8 at work

I think it all came out rather smart. Chalk up another well designed product from Ubiquiti. I actually have another USW8 sitting and waiting to be deployed at home, but I have several holes to cut before that goes in.


Subscribe via RSS. Send me a comment.