As part of my morning routine, I have a few scripts I run to make sure my laptop and servers are up to date.

Rather than login to the web GUI of my OPNSense firewall, I created an alias to check for updates from the CLI.

Add the following line to .bash_aliases or directly to .bashrc:

alias check-update='sudo /usr/local/opnsense/scripts/firmware/launcher.sh check'

There are a few small, but interesting, additional steps required for the alias to work over a “non-interactive” SSH session.

First, include the -t parameter with ssh to force the use of a psuedo-tty (so sudo will work). And instead of calling the alias directly, invoke bash and pass the alias as the command. The combined flags of -ic to bash make all that work together. (Credit goes to Cyberciti.biz for explaining these options to me.)

All of the above results in allowing me to run this from my terminal:

me@macbookpro:~ ssh -t opnsense /usr/local/bin/bash -ic 'check-update'

resulting in output similar to the following:

Updating OPNsense repository catalogue...
Fetching meta.conf: . done
Fetching packagesite.pkg: .......... done
Processing entries: .......... done
OPNsense repository update completed. 822 packages processed.
All repositories are up to date.
Checking integrity... done (0 conflicting)
Your packages are up to date.
Checking for upgrades (0 candidates): . done
Processing candidates (0 candidates): . done
Checking integrity... done (0 conflicting)
Your packages are up to date.