Skip to content

Instantly share code, notes, and snippets.

View stephen-fox's full-sized avatar
🦈
:)

stephen-fox

🦈
:)
View GitHub Profile
package power
import (
"errors"
"os/exec"
"os/user"
"runtime"
)
// Power provides several methods for controlling a machine's power state.
@stephen-fox
stephen-fox / loggerprefix.go
Last active April 4, 2020 16:05
Adding a prefix to Go's log.Logger after the log flags
// This example code demonstrates how to add a prefix to messages
// generated by Go's standard library logger *after* the log flags.
//
// For example, this source file's main() produces the
// following output:
// 2020/04/04 11:45:24 main.go:13: [my cool prefix] some work from anonymous go routine
// 2020/04/04 11:45:25 main.go:18: [my cool prefix] here is a panic 1
// panic: here is a panic 1
//
// goroutine 1 [running]:
@stephen-fox
stephen-fox / openssl-payload.sh
Last active April 13, 2024 15:18
Encrypting data with openssl and transmitting it with nc
#!/bin/bash
# This snippet demonstrates how to send and receive data
# encrypted with openssl using netcat.
#
# You can switch around the netcat listener and sender
# depending on your preference. This example is setup
# for copying data from a host into a VirtualBox VM.
# You can also substitute 'nc' for another tool.
#
@stephen-fox
stephen-fox / yubikey-macos-notes.md
Last active November 22, 2021 20:03
macOS yubikey notes (focused on Go development)

yubikey w/ ssh on macOS notes

Trade offs

  • FIDO2 (AKA, "security key" / "sk") key:
    • You really need physical presence (need to tap the yubikey - no prompts)
    • Odd workflow even with ssh-agent for Go due to lack of tap prompt
    • Need to update OpenSSH on macOS to at least 8.2 on Big Sur, and servers
    • OpenSSH added FIDO2 support recently (8.2, early 2020 - see ssh -V)
  • PIV (Personal Identity Verification) key: