<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Victor</title>
    <description>The latest articles on DEV Community by Victor (@victor_sunday_1de46f21e18).</description>
    <link>https://dev.to/victor_sunday_1de46f21e18</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3732770%2Fead67bc4-a9bf-4076-b344-b1c13bf48350.png</url>
      <title>DEV Community: Victor</title>
      <link>https://dev.to/victor_sunday_1de46f21e18</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/victor_sunday_1de46f21e18"/>
    <language>en</language>
    <item>
      <title>Stop Using .env Files on Servers (Do This Instead)</title>
      <dc:creator>Victor</dc:creator>
      <pubDate>Sun, 22 Mar 2026 23:56:55 +0000</pubDate>
      <link>https://dev.to/victor_sunday_1de46f21e18/stop-using-env-files-on-servers-do-this-instead-2adm</link>
      <guid>https://dev.to/victor_sunday_1de46f21e18/stop-using-env-files-on-servers-do-this-instead-2adm</guid>
      <description>&lt;p&gt;If you're deploying apps on a VPS, chances are you're still using &lt;code&gt;.env&lt;/code&gt; files.&lt;/p&gt;

&lt;p&gt;I was, too.&lt;/p&gt;

&lt;p&gt;Until I realized how messy (and risky) it actually is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;copying &lt;code&gt;.env&lt;/code&gt; files between machines&lt;/li&gt;
&lt;li&gt;leaving secrets sitting in plaintext on servers&lt;/li&gt;
&lt;li&gt;forgetting to delete old files&lt;/li&gt;
&lt;li&gt;no real access control per machine&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It works… until it doesn’t.&lt;/p&gt;

&lt;p&gt;So I built a different approach.&lt;/p&gt;




&lt;h2&gt;
  
  
  🚀 The idea
&lt;/h2&gt;

&lt;p&gt;Instead of storing secrets on your server:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;don’t store them at all&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;encrypt secrets locally&lt;/li&gt;
&lt;li&gt;store only ciphertext&lt;/li&gt;
&lt;li&gt;inject them into your app at runtime&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;No &lt;code&gt;.env&lt;/code&gt; files. No plaintext on disk.&lt;/p&gt;




&lt;h2&gt;
  
  
  ⚡ Example
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vaultsync secrets push &lt;span class="nt"&gt;--file&lt;/span&gt; .env
vaultsync run &lt;span class="nt"&gt;--&lt;/span&gt; node app.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it.&lt;/p&gt;

&lt;p&gt;Your app still gets environment variables —&lt;br&gt;
but they’re never written to disk on the server.&lt;/p&gt;


&lt;h2&gt;
  
  
  🧠 How it works (simplified)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.env&lt;/code&gt; is encrypted locally using AES&lt;/li&gt;
&lt;li&gt;the server stores only ciphertext&lt;/li&gt;
&lt;li&gt;each machine has its own RSA keypair&lt;/li&gt;
&lt;li&gt;secrets are decrypted &lt;strong&gt;only in memory at runtime&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After your app exits, secrets are wiped.&lt;/p&gt;


&lt;h2&gt;
  
  
  🔐 Why this is better than &lt;code&gt;.env&lt;/code&gt;
&lt;/h2&gt;
&lt;h3&gt;
  
  
  &lt;code&gt;.env&lt;/code&gt; files:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;stored in plaintext&lt;/li&gt;
&lt;li&gt;copied across servers&lt;/li&gt;
&lt;li&gt;hard to rotate&lt;/li&gt;
&lt;li&gt;easy to leak&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  This approach:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;no plaintext on servers&lt;/li&gt;
&lt;li&gt;per-machine access control&lt;/li&gt;
&lt;li&gt;secrets only exist in memory&lt;/li&gt;
&lt;li&gt;easier to revoke access&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  🆚 What about Vault, Doppler, etc?
&lt;/h2&gt;

&lt;p&gt;There are great tools out there:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HashiCorp Vault → powerful but complex&lt;/li&gt;
&lt;li&gt;Doppler / Infisical → nice UX but SaaS-based&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wanted something:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;simple&lt;/li&gt;
&lt;li&gt;self-hostable&lt;/li&gt;
&lt;li&gt;designed for VPS / bare metal&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  🛠️ What I built
&lt;/h2&gt;

&lt;p&gt;I ended up building a CLI called &lt;strong&gt;VaultSync&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It lets you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;push encrypted secrets&lt;/li&gt;
&lt;li&gt;register machines&lt;/li&gt;
&lt;li&gt;grant access per machine&lt;/li&gt;
&lt;li&gt;run apps with secrets injected at runtime&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  🖥️ Real-world use case
&lt;/h2&gt;

&lt;p&gt;Let’s say you’re deploying a Node.js API on a VPS.&lt;/p&gt;

&lt;p&gt;Instead of:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;scp .env server:/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;vaultsync secrets push &lt;span class="nt"&gt;--file&lt;/span&gt; .env
vaultsync run &lt;span class="nt"&gt;--&lt;/span&gt; node dist/index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No &lt;code&gt;.env&lt;/code&gt; file ever touches the server.&lt;/p&gt;




&lt;h2&gt;
  
  
  🤔 When should you use this?
&lt;/h2&gt;

&lt;p&gt;This is useful if you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;deploy apps to VPS or bare metal&lt;/li&gt;
&lt;li&gt;don’t want secrets sitting on disk&lt;/li&gt;
&lt;li&gt;want per-machine access control&lt;/li&gt;
&lt;li&gt;don’t need a full-blown Vault setup&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📦 Try it
&lt;/h2&gt;

&lt;p&gt;If this sounds useful, you can check it out here:&lt;/p&gt;

&lt;p&gt;👉 &lt;a href="https://github.com/KingVics/vaultsync-cli" rel="noopener noreferrer"&gt;https://github.com/KingVics/vaultsync-cli&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Would love feedback — especially from people managing secrets in production.&lt;/p&gt;




&lt;h2&gt;
  
  
  💬 Curious how others are handling this
&lt;/h2&gt;

&lt;p&gt;Are you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;still using &lt;code&gt;.env&lt;/code&gt; files?&lt;/li&gt;
&lt;li&gt;using Vault / Doppler?&lt;/li&gt;
&lt;li&gt;rolling your own solution?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’m curious what’s working (or not working) for you.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>node</category>
      <category>security</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
