Skip to content

Instantly share code, notes, and snippets.

@aphu
aphu / id_rsa_encryption.md
Created July 25, 2025 19:19 — forked from fcoury/id_rsa_encryption.md
Encrypt/Decrypt a File using your SSH Public/Private Key on Mac OS X

A Guide to Encrypting Files with Mac OS X

This guide will demonstrate the steps required to encrypt and decrypt files using OpenSSL on Mac OS X. The working assumption is that by demonstrating how to encrypt a file with your own public key, you'll also be able to encrypt a file you plan to send to somebody else using their private key, though you may wish to use this approach to keep archived data safe from prying eyes.

Too Long, Didn't Read

Assuming you've already done the setup described later in this document, that id_rsa.pub.pcks8 is the public key you want to use, that id_rsa is the private key the recipient will use, and secret.txt is the data you want to transmit…

Encrypting

$ openssl rand 192 -out key

$ openssl aes-256-cbc -in secret.txt -out secret.txt.enc -pass file:key

@aphu
aphu / .wezterm.lua
Created June 22, 2023 12:01
wezterm
-- Pull in the wezterm API
local wezterm = require 'wezterm'
-- This table will hold the configuration.
local config = {}
-- In newer versions of wezterm, use the config_builder which will
-- help provide clearer error messages
if wezterm.config_builder then
config = wezterm.config_builder()
@aphu
aphu / logback.xml
Last active August 9, 2021 19:07
Spring Logback Color
<configuration>
<conversionRule conversionWord="clr" converterClass="org.springframework.boot.logging.logback.ColorConverter"/>
<property name="pattern" value="%clr(%d{yyyy-MM-dd HH:mm:ss}){yellow} %clr([%thread]){faint} %clr(%-5level) %clr(%logger{36}){cyan} - %msg%n"/>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${pattern}</pattern>
</encoder>
</appender>
// create CA key
openssl genrsa -out ca.key 2048
// create CA cert
openssl req -x509 -sha256 -new -nodes -key ca.key -days 365 -out ca.pem
// create client key
openssl genrsa -out client.key 2048
// create client csr
@aphu
aphu / logback.xml
Created May 15, 2018 02:03
logback template
<configuration scan="true" scanPeriod="30 seconds">
<property name="pattern" value="%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"/>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>logs/application.log</file>
<encoder>
<pattern>${pattern}</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>application.%d{yyyy-MM-dd}.log.gz</fileNamePattern>