From 41b63f50f8a447b347d0806f83c9f810ca87fbf5 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Thu, 5 Nov 2026 09:28:30 -0600 Subject: [PATCH] Add Generate A Random Secret Value With OpenSSL as a Unix TIL --- README.md | 3 ++- ...nerate-a-random-secret-value-with-openssl.md | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 unix/generate-a-random-secret-value-with-openssl.md diff --git a/README.md b/README.md index a47ea3d..eebc2a4 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1899 TILs and counting..._ +_1900 TILs and counting..._ See some of the other learning resources I work on: @@ -1837,6 +1837,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Fix Unlinked Node Binaries With asdf](unix/fix-unlinked-node-binaries-with-asdf.md) - [Format And Display Small Amounts Of Columnar Data](unix/format-and-display-small-amounts-of-columnar-data.md) - [Forward Multiple Ports Over SSH](unix/forward-multiple-ports-over-ssh.md) +- [Generate A Random Secret Value With OpenSSL](unix/generate-a-random-secret-value-with-openssl.md) - [Generate A SAML Key And Certificate Pair](unix/generate-a-saml-key-and-certificate-pair.md) - [Generate A Sequence Of Numbered Items](unix/generate-a-sequence-of-numbered-items.md) - [Generate Base64 Encoding Without Newlines](unix/generate-base64-encoding-without-newlines.md) diff --git a/unix/generate-a-random-secret-value-with-openssl.md b/unix/generate-a-random-secret-value-with-openssl.md new file mode 100644 index 0000000..b849601 --- /dev/null +++ b/unix/generate-a-random-secret-value-with-openssl.md @@ -0,0 +1,17 @@ +# Generate A Random Secret Value With OpenSSL + +The `openssl` command can generate a random hex-based value like so: + +```bash +❯ openssl rand -hex 32 +101142ffaf1c6b14395cec5592f6f3739d5ee282a9db27ec2d7ad879540c16a2 +``` + +This is useful if I need to generate a secret key value for authentication in a +feature I'm building. For example, I'm working on a dedicated MCP server that +can only be accessed by a 3rd-party messaging interface. I need to only allow +requests to the MCP endpoint that have a valid secret key. I can use the above +command to generate unique values for both local testing and the actual secret +that ends up in our production vault. + +See `man openssl` for more details.