Skip to content

Instantly share code, notes, and snippets.

@Psmths
Psmths / udev-rules.md
Created August 16, 2023 18:42
Linux: Preventing certain USB devices from connecting

Step 1: Identify the Bus/Device pair of the device

# lsusb
...
Bus 005 Device 014: ID 05ac:12a8 Apple, Inc. iPhone 5/5C/5S/6/SE
...

In this instance, the bus ID is 005 and the device ID is 014.

@Psmths
Psmths / README.md
Last active December 8, 2021 01:59
Enumerating ESXi Hosts

Enumerating ESXi Hosts

List all guest machines

# vim-cmd vmsvc/getallvms

Example output:

Vmid   Name             File                 Guest OS       Version   Annotation
2      test   [ds-nfs-01] test/test.vmx   debian9_64Guest   vmx-19
@Psmths
Psmths / README.md
Last active November 13, 2021 07:48
Creating a Certificate Authority with OpenSSL

Creating a Certificate Authority with OpenSSL

This tutorial will guide you step-by-step to creating a certificate authority using OpenSSL, with a three-tier structure (root, intermediate, application). All key materials are created with ECC.

Staging

The first step is to create the directory in which the CA will reside. As a simple example, we will work out of /root/ca. We will create a directory, /root/ca/db, to store the CA database flat files. Within this directory, three files must be created as follows:

touch /root/ca/db/index.txt
touch /root/ca/db/index.txt.attr 
echo 100000 > /root/ca/db/serial
@Psmths
Psmths / README.md
Created February 7, 2021 03:52
Bash one-liners

BASH One-Liners

Print unique file extensions in a directory (recursive)

find . -type f | perl -ne 'print $1 if m/\.([^.\/]+)$/' | sort -u

Count instances of multiple file extensions

@Psmths
Psmths / README.md
Last active February 6, 2021 06:42
Apache Catch-All HTTP Redirect

Apache Catch-All HTTP Redirect

Use this virtual host configuration to redirect traffic from HTTP to HTTP/S for multiple subdomains.

<VirtualHost *:80>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
@Psmths
Psmths / README.md
Last active February 6, 2021 16:03
Apache Client Certificate Authentication

Apache Client Certificate Authentication / Certificate Authority

By following this guide you will create an apache domain or subdomain with self-signed certificates, signed by your personal CA, and use this to authenticate clients. All certificates ECC.

I. Create the Certificate Authority

First, create the CA's key and certificate. This will be used to sign all other certificates. In this example it is valid for 1 year. For the CN field anything is acceptable, preferably ca.<yourdomain>.<yourtld>.