Linux: How to create an SSH tunnel as a systemd service

Much often you will need a constant SSH tunnel connection, to avoid the administrative load for those tunnels after a reboot is to configure them as systemd services and use SSH keys to avoid passwords.

Also its nice and super helpfull to create the systemd service as a template that can accept tunnel parameters from a file, this allow very easily to manage your tunnels (add,delete,modify,start,stop).

https://medium.com/linuxstories/linux-how-to-create-an-ssh-tunnel-as-a-systemd-service-73e6e0fff19b

12 factor CLI apps

CLIs are a fantastic way to build products. Unlike web applications, they take a small fraction of the time to build and are much more powerful. With the web, you can do whatever the developer programmed. With CLIs, you can easily mash-up multiple tools together yourself to perform advanced tasks. They require more technical expertise to use, but still work well for admin tasks, power-user tasks, or developer products.

https://medium.com/@jdxcode/12-factor-cli-apps-dd3c227a0e46

7 Best Free and Open Source Status Page Systems

A status page system is software that lets you communicate incidents, schedule maintenance and downtimes with your customers.

A status page can be public or private. Public stage pages engender customer trust and demonstrate the reliability of a platform. Private status pages are useful to communicate incidents with internal stakeholders.

smxi: A CLI Tool for Managing Debian Based Linux Distros

https://itsfoss.com/smxi/

smxi is a maintenance script with a few features that you will appreciate once you start using it. It varies from helping you install a specific office suite to managing multiple Linux kernels on the same machine.

Below are a few features that it offers:

  • Automatic installation of GPU drivers, along with necessary patches (even nVidia)
  • Installing software (from a simple package to a full fledged Desktop Environment)
  • Removing any given software
  • System clean up (clearing apt cache, removing old kernels and kernel modules, etc)
  • Manage and deploy system upgrades
  • Kernel upgrades / Kernel module upgrades

Query your Linux operating system like a database

https://opensource.com/article/21/6/osquery-linux

Linux offers a lot of commands to help users gather information about their host operating system: listing files or directories to check attributes; querying to see what packages are installed, processes are running, and services start at boot; or learning about the system’s hardware.

Each command uses its own output format to list this information. You need to use tools like grep, sed, and awk to filter the results to find specific information. Also, a lot of this information changes frequently, leading to changes in the system’s state.

It would be helpful to view all of this information formatted like the output of a database SQL query. Imagine that you could query the output of the ps and rpm commands as if you were querying an SQL database table with similar names.

Fortunately, there is a tool that does just that and much more: Osquery is an open source “SQL powered operating system instrumentation, monitoring, and analytics framework.”

https://osquery.readthedocs.io/en/latest/

PingMe CLI

https://pingme.lmno.pk/#/

PingMe is a personal project to satisfy my needs of having alerts, most major platforms have integration to send alerts but it’s not always useful, either you are stuck with one particular platform, or you have to do alot of integrations. I needed a small app which i can just call from my backup scripts, cron jobs, CI/CD pipelines or from anywhere to send a message with particular information. And i can ship it everywhere with ease. Hence, the birth of PingMe.

Demo

Demo

tinydb

TinyDB is a lightweight document oriented database optimized for your happiness 🙂 It’s written in pure Python and has no external dependencies.

Example Code

>>> from tinydb import TinyDB, Query
>>> db = TinyDB('/path/to/db.json')
>>> db.insert({'int': 1, 'char': 'a'})
>>> db.insert({'int': 1, 'char': 'b'})

Query Language

>>> User = Query()
>>> # Search for a field value
>>> db.search(User.name == 'John')
[{'name': 'John', 'age': 22}, {'name': 'John', 'age': 37}]

>>> # Combine two queries with logical and
>>> db.search((User.name == 'John') & (User.age <= 30))
[{'name': 'John', 'age': 22}]

>>> # Combine two queries with logical or
>>> db.search((User.name == 'John') | (User.name == 'Bob'))
[{'name': 'John', 'age': 22}, {'name': 'John', 'age': 37}, {'name': 'Bob', 'age': 42}]

>>> # More possible comparisons:  !=  <  >  <=  >=
>>> # More possible checks: where(...).matches(regex), where(...).test(your_test_func)