Skip to content

Instantly share code, notes, and snippets.

View JPvRiel's full-sized avatar

Jean-Pierre van Riel JPvRiel

  • South Africa, Johannesburg
View GitHub Profile
@JPvRiel
JPvRiel / inspect_raid.md
Last active March 14, 2025 14:15
Linux MD software raid inspection

inspect_raid.sh

A bash script that collects some useful commands to check Linux MD software arrays and component devices for some issues, e.g.

  • RAID component device has a SMART warnings or errors.
  • A RAID with HDD and SSD mixed doesn't have the HDD components set to write-mostly or the SSD is set to write-mostly.

It can also display info. Set env var SHOW_INFO='y' or anything else, e.g. 'n' (default) to just report issues.

Usage

@JPvRiel
JPvRiel / SysRq magic keys.md
Created January 9, 2019 02:26
SysRq magic keys

sysrq magic keys

This is useful for trying to recover from an unresponsive system. However, by default, Ubuntu disables the key to gain raw keyboard access.\

Sometimes part of the issue is that X/Wayland display servers have crashed due to bad graphics drivers and keyboard input isn't processed anymore, whereby changing to another console, e.g. ctrl + alt + F1 doesn't work. Since the default disables keyboard control, alt + sysrq + r, can't help salvage the situation. Hence the suggestion to at least enable system request raw keyboard control when trying to recover a system.

Ubuntu doesn't enable control of keyboard by default

Ubuntu 16.04 LTS default value:

@JPvRiel
JPvRiel / Convert old weakly encrypted SSH private keys to the newer PKCS8 format.md
Last active November 24, 2022 14:05
Convert Old Weakly Encrypted SSH Private Keys to the Newer PKCS8 Format

Convert Old Weakly Encrypted SSH Private Keys to the Newer PKCS8 Format

The default password-based encryption for openSSH RSA private keys (generated with ssh-keygen -t rsa) has inadequate protection against brute forcing due to a weak Password-Based Key Derivation Function (PBKDF) because it used OpenSSL's key derivation with just one round of MD5.

TL;DR: Rather generate new keys with ssh-keygen -t ed25519 which by default should use the more secure PBKDF with the PKCS8 format. RSA key generation defaults to the weak PBKDF stored in the PEM format.

However, if you still need RSA to work with older Unix systems, network devices, and other systems' SSH servers are not yet upgraded with Ed25519 support, this provides info to avoid the less secure default of saving private keys in the legacy PEM format when generating RSA keys. Backward compatibility is not that much of a concern since only the SSH client needs a reasonably modern version of SSH.

Identify if the old PEM format is in use

@JPvRiel
JPvRiel / README.md
Last active October 10, 2022 17:27
Decode syslog priority

Decode syslog priority

Well-formed syslog message headers start with the facility and severity encoded as the priority in angle brackets, e.g. <179>.... As per RFC5424:

The Priority value is calculated by first multiplying the Facility number by 8 and then adding the numerical value of the Severity.

The python files in this gist are a demo to help showcase how to decode the priority. E.g.:

pri = 179