Skip to content

Instantly share code, notes, and snippets.

View troyfontaine's full-sized avatar

Troy Fontaine troyfontaine

View GitHub Profile
@troyfontaine
troyfontaine / create.sh
Last active April 8, 2022 03:25
Cloudkey SSL Cert with Third-party cert
#!/bin/bash
# Create fullchain
cat ~/cert/*.ca-bundle ~/cert/*.crt >> fullchain.cer
# Generate pkcs12 cert from acme output
openssl pkcs12 -export -in ~/cert/fullchain.cer -inkey \
~/cert/mydomain.key \
-out ~/cert/unifi.p12 -name unifi -password pass:aircontrolenterprise
@troyfontaine
troyfontaine / macos_to_windows10_oss_developer.md
Last active April 8, 2022 03:40
Windows 10-based Linux Developer Setup (Coming from macOS)

How to Install OpenSSH on Windows 10 (any version) with Publickey Authentication working

This brief tutorial assumes you already have an SSH public key you want to use

  1. Install chocolatey via Powershell

    Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
    
  2. Close Powershell

  3. Open a new Powershell session

@troyfontaine
troyfontaine / README.md
Created April 12, 2022 03:16
Rsync commands for TrueNAS

Rsync Commands for use with TrueNAS

Due to the way TrueNAS is built-duplicating files using Rsync requires some special flags to allow it to work

The below example command has been used and verified as working with TrueNAS Scale

rsync -avrh -A --no-perms <SOURCE> <DESTINATION>
@troyfontaine
troyfontaine / google-authenticator.md
Last active April 28, 2022 15:03
Getting Google Authenticator working on Ubuntu for SSH Authentication

Google Authenticator for SSH How-To

Installing the Google Authenticator pam package alone does not configure a system for 2 Factor Authentication when connecting via SSH.

Overview

The Google Authenticator package can be installed on Ubuntu via apt-get on Ubuntu 14.04.3 and later (that I've confirmed).

It provides a pam module that allows you to prompt a user for a code generated via a Google Authenticator app or other compatible TOTP app (such as 1Password). The script below enables the authenticator prompt when using ssh and password authentication.

A few things to keep in mind:

  • You cannot enable Google Authenticator for Public Key-based authentication at the same time as Password-based authentication
@troyfontaine
troyfontaine / remove_gh_package.sh
Created December 12, 2019 04:29
Bash script to Delete/Remove Private Github Packages
#!/bin/bash
# Really crappy script that works to delete private packages stored on Github Packages
# Intended to simplify deleting packages that are counting against your limit
# By Troy Fontaine (github.com/troyfontaine)
# First displays the private packages name then the version finally the ID needed to delete it
# Then prompts you if you want to delete the packages based on the ID
GITHUB_TOKEN=$SUPERSECRETTOKEN
REPO_OWNER=$YOURGITHUBUSERNAME
@troyfontaine
troyfontaine / realmd_ubuntu1404.md
Last active October 17, 2022 00:05
Steps to join an Ubuntu 14.04 Server to Active Directory using realmd

Steps to join an Ubuntu 14.04 Server to Active Directory using realmd

Step 1: Perform updates

apt-get update

Step 2: Install realmd

apt-get install -y realmd
@troyfontaine
troyfontaine / howtosurvive.md
Last active December 14, 2022 22:43
PFSense Router with VLANs and TFTP Server

Ephemeral Ports are your bane

TFTP is said to "only use UDP 69" but this is completely and totally inaccurate.

TFTP starts communications on UDP 69, then moves the conversation to ephemeral ports between the two systems-and depending on the systems involved, they can change during the boot process.

Note, this doesn't seem to work across VLANs....

So, where do you start?

Step 1) You need UDP 67, 69, 4011, 1024:5000 from your PXE booting machine to the PXE Server. This is because the PXE bootloader appears to use that range specifically.

@troyfontaine
troyfontaine / README.md
Last active December 22, 2022 16:04
USG ddclient Upgrade Script

How to use this script?

Why, that's simple! Copy this script to your USG, run chmod +x on it and then, as a user with sudo permission, execute it.

Shamelessly borrowed from Brittanic on the Ubiquiti Unifi forums

How to use it?

Simply run the following command (note, if you are at all security concious-don't run it and instead review the script, then copy it to your USG to execute).

curl https://gist.githubusercontent.com/troyfontaine/7e6f93e32621177fc9a94e823adc52b5/raw/fix_ddns.sh | sudo bash
@troyfontaine
troyfontaine / beg_redirect.map
Last active March 23, 2023 10:19
HAProxy Redirecting based on an HTTP Query or a Map with a fallback redirect based on host header
# This file contains only partial paths to match on
# This file should reside in the same directory as the haproxy.cfg simply due to the way it is configured in the sample snippet-but they can go anywhere in the /etc/haproxy directory
/my-partial- https://subdomain3.mydomain.com/my-new-full-path
@troyfontaine
troyfontaine / 1-raspberry_pi_with_led_powerbutton_and_rtc.md
Last active July 17, 2023 21:59
Raspberry Pi with LED Power Button and RTC

How to Set up a Raspberry Pi with LED Power Button and RTC

After a lot of trial and error, I've figured out how to set up a Raspberry Pi (in my case, I tested with a 2B and 3B+, this may not work on a Pi 4B). This involves using the i2c0 bus (which normally isn't recommended), but this is what I was able to get working as re-mapping would communicate with the RTC via i2c, but the overlay for the RTC wouldn't adjust its configuration when told to use i2c3 or higher.

Required hardware

  1. Power button (this should be a momentary switch type)
  2. Power LED (for me, this was actually built into the power button)
  3. 330K Ohm resistor (this is connected between the LED and the 3.3v header
  4. A Real Time Clock (RTC) Module (preferably, one with built-in pull up resistors)
  5. Jumper wires