Skip to content

Instantly share code, notes, and snippets.

View jbennink's full-sized avatar

Johan Bennink jbennink

View GitHub Profile
@startergo
startergo / KVM_in_WSL2.md
Last active July 14, 2026 11:54
KVM on WSL2 Windows 11
  • In WSL2 run:
sudo apt update
sudo apt install qemu qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils cpu-checker \
network-manager iptables-persistent linux-headers-generic \
qemu uml-utilities virt-manager git \
wget libguestfs-tools p7zip-full make dmg2img tesseract-ocr \
tesseract-ocr-eng genisoimage vim net-tools screen firewalld libncurses-dev -y
sudo apt install virt-manager
sudo addgroup kvm
@Reclyptor
Reclyptor / .bashrc
Last active July 2, 2026 13:26
Windows GPG Agent Configuration
# WSL2 SSH Pageant
export SSH_AUTH_SOCK="$HOME/.ssh/agent.sock"
if ! ss -a | grep -q "$SSH_AUTH_SOCK"; then
rm -f "$SSH_AUTH_SOCK"
wsl2_ssh_pageant_bin="$HOME/.ssh/wsl2-ssh-pageant"
if test -x "$wsl2_ssh_pageant_bin"; then
(setsid nohup socat UNIX-LISTEN:"$SSH_AUTH_SOCK,fork" EXEC:"$wsl2_ssh_pageant_bin" >/dev/null 2>&1 &)
else
echo >&2 "WARNING: $wsl2_ssh_pageant_bin is not executable."
fi

WSL does now have native support for USB devices, which means it can't detect the Yubikey plugged into your computer. It seems like USB support will come soon, but for now we need to use a workaround.

The workaround consists in exposing a GPG socket from Windows to your WSL Linux instance. That way, your WSL's gpg command will connect to your Windows's gpg software and will be able to detect your USB Yubikey.

  1. Install GnuPG on Windows

  2. Install Putty on Windows

  3. Run the following 2 commands in Powershell to create your GPG conf file:

@RobSchilderr
RobSchilderr / gist:7467c00933d328bce33e1793b75bfa7b
Created December 22, 2021 08:21
Common regular expressions for Dutch people, such as kvk number, iban, dutch identitycard
const regexps = {
alpha: '[a-zA-Z .-]+',
alphaNumeric: '[a-zA-Z0-9À-ü ,.\'-]+',
sameChars: /^(?!.*(.)\1\1+)/i,
date: /^(?:(?:(?:[0]?[1-9]|1[0-9]|2[0-8])-(?:(0)?[1-9]|1[0-2])|(?:29|30)-(?:(0)?[13-9]|1[0-2])|31-(?:(0)?[13578]|1[02]))-[1-9]\d{3}|29-(0)?2-(?:[1-9]\d(?:0[48]|[2468][048]|[13579][26])|(?:[2468][048]|[13579][26])00))$/,
kvkNumber: /^[0-9]{8}$/,
btwNumber: /^[A-Za-z]{2}[0-9]{9}[A-Za-z][0-9]{2}$/,
phoneMobile: /(^(\(?(0031|0|\+31)\)?){1})( ?-?(6){1}\)?)(( ?|-)?[1-9]( ?|-)?){1}(( ?|-)?[0-9]( ?|-)?){7}$/,
phoneFixedThreeDigits: /(^(\(?(0031|0|\+31)\)?){1})( ?-?([0-9]){3}\)?)(( ?|-)?[0-9]( ?|-)?){6}$/,
phoneFixedFourDigits: /(^(\(?(0031|0|\+31)\)?){1})( ?-?([0-9]){2}\)?)(( ?|-)?[0-9]( ?|-)?){7}$/,

Yubikey GPG inside WSL2

  1. Install GPG4Win.
  2. Start up Kleopatra (a UI tool from 1) and make sure your YubiKey is loaded there.
    • You can also add GPG4Win to Startup folder using a link with this Target:
      "C:\Program Files (x86)\GnuPG\bin\gpg-connect-agent.exe" /bye
      
      This will only load the agent at Startup, and you won't be bothered by any UI or tray agent.
  3. Download wsl2-ssh-pageant into your Windows %userprofile%/.ssh directory (Windows dir is important for performance).
@marcbarry
marcbarry / machine.config.markdown
Last active October 18, 2024 11:42
Security hardening pointers for web.config and machine.config
Prevent applications running if debug=true
<system.web>
  <deployment retail="true"/>
</system.web>
@davidfowl
davidfowl / dotnetlayout.md
Last active July 11, 2026 15:54
.NET project structure
$/
  artifacts/
  build/
  docs/
  lib/
  packages/
  samples/
  src/
 tests/