<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>DevOps on Jhooq</title><link>https://jhooq.com/tags/devops/</link><description>Recent content in DevOps on Jhooq</description><generator>Hugo -- gohugo.io</generator><language>en</language><copyright>Jhooq</copyright><lastBuildDate>Thu, 29 Oct 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://jhooq.com/tags/devops/index.xml" rel="self" type="application/rss+xml"/><item><title>Stop Using .env Files for Secrets: Encrypt Them with sops and age Instead (Real Output, gitleaks Included)</title><link>https://jhooq.com/stop-using-env-files-for-secrets/</link><pubDate>Thu, 29 Oct 2026 00:00:00 +0000</pubDate><guid>https://jhooq.com/stop-using-env-files-for-secrets/</guid><description>
&lt;h2 id="tldr"&gt;TL;DR&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A committed &lt;code&gt;.env&lt;/code&gt; file never goes away.&lt;/strong&gt; After &lt;code&gt;git rm&lt;/code&gt; the password is still readable with &lt;code&gt;git show &amp;lt;commit&amp;gt;:.env&lt;/code&gt; and &lt;code&gt;git log -p&lt;/code&gt;. The only real fix is to rotate the secret.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;gitleaks finds it in milliseconds.&lt;/strong&gt; In my run it scanned 105 bytes in 24 ms and reported 2 leaks (a Stripe-style key and a generic password); it exits with code 1, so a CI job or pre-commit hook can block the commit.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;sops plus age lets you commit secrets safely.&lt;/strong&gt; The values become &lt;code&gt;ENC[AES256_GCM,...]&lt;/code&gt;, the key names stay readable, and the diff of a changed password touches only that line plus the MAC and timestamp lines.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Decrypt at deploy time, not on disk.&lt;/strong&gt; &lt;code&gt;sops exec-env prod.enc.env 'your-command'&lt;/code&gt; puts the values into the environment of one process and writes no plaintext file.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Not your case?&lt;/strong&gt; If your secrets live in Kubernetes, read &lt;a href="https://jhooq.com/kubernetes-secrets"&gt;Kubernetes Secrets&lt;/a&gt; first; if they live in Terraform state, read &lt;a href="https://jhooq.com/terraform-do-not-store-tfstate-in-git/"&gt;why the tfstate file should not be stored in git&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="video"&gt;
&lt;iframe src="https://www.youtube.com/embed/z5N3zJuxv3M?controls=1&amp;rel=0" loading="lazy"&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;h2 id="table-of-content"&gt;Table of Content&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href="#why-a-env-file-in-git-is-a-leak"&gt;Why a .env file in git is a leak&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#install-the-tools"&gt;Install the tools&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#reproduce-the-leak-and-catch-it-with-gitleaks"&gt;Reproduce the leak and catch it with gitleaks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#encrypt-the-file-with-sops-and-age"&gt;Encrypt the file with sops and age&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#decrypt-at-deploy-time"&gt;Decrypt at deploy time&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#what-broke-when-i-ran-this"&gt;What broke when I ran this&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#comparison-of-the-options"&gt;Comparison of the options&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="#my-recommendation"&gt;My recommendation&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;figure&gt;
&lt;picture&gt;
&lt;img
loading="lazy"
decoding="async"
alt=".env in git versus a sops encrypted file"
class="image_figure image_internal image_unprocessed"
src="https://jhooq.com/wp-content/uploads/devops/sops-age/env-file-vs-sops.svg"
/&gt;
&lt;/picture&gt;
&lt;/figure&gt;
&lt;/p&gt;</description></item></channel></rss>