<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Htpasswd on Janusworx</title>
    <link>https://janusworx.com/tags/htpasswd/</link>
    <description>Recent content in Htpasswd on Janusworx</description>
    <image>
      <title>Janusworx</title>
      <url>https://janusworx.com/images/jw-logo.png</url>
      <link>https://janusworx.com/images/jw-logo.png</link>
    </image>
    <generator>Hugo -- 0.160.1</generator>
    <language>en</language>
    <lastBuildDate>Sat, 24 Jun 2023 15:16:26 +0530</lastBuildDate>
    <atom:link href="https://janusworx.com/tags/htpasswd/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>htpasswd Notes to Self</title>
      <link>https://janusworx.com/work/htpasswd-notes-to-self/</link>
      <pubDate>Sat, 24 Jun 2023 15:16:26 +0530</pubDate>
      <guid>https://janusworx.com/work/htpasswd-notes-to-self/</guid>
      <description>&lt;p&gt;To &lt;em&gt;create&lt;/em&gt; the &lt;code&gt;htpasswd&lt;/code&gt; file along with its first user, I just:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;htpasswd -c /path/to/htpasswdfile/htpasswd some-user&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;It’ll ask you for the password for that user, encrypt it and store it in that location.&lt;/p&gt;
&lt;p&gt;Add these lines to get Nginx to use the file for basic auth:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-nginx&#34; data-lang=&#34;nginx&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;auth_basic&lt;/span&gt;	&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;Login&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;to&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;Proceed:&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;&lt;/span&gt;; &lt;span style=&#34;color:#75715e&#34;&gt;#(or whatever message you want)
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;auth_basic_user_file&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;/path/to/htpasswdfile/htpasswd&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To &lt;em&gt;append&lt;/em&gt; &lt;em&gt;&lt;strong&gt;another&lt;/strong&gt;&lt;/em&gt; user to the &lt;code&gt;htpasswd&lt;/code&gt; file do:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;htpasswd /path/to/htpasswd/htpasswd second-user&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;That ought to do it.&lt;/p&gt;
&lt;p&gt;P.S. Install &lt;code&gt;apache-utils&lt;/code&gt; on Debian or use Paru/Yay to install &lt;code&gt;nginx_passwd&lt;/code&gt; on Arch.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>To <em>create</em> the <code>htpasswd</code> file along with its first user, I just:</p>
<p><code>htpasswd -c /path/to/htpasswdfile/htpasswd some-user</code></p>
<p>It’ll ask you for the password for that user, encrypt it and store it in that location.</p>
<p>Add these lines to get Nginx to use the file for basic auth:</p>
<div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-nginx" data-lang="nginx"><span style="display:flex;"><span><span style="color:#66d9ef">auth_basic</span>	<span style="color:#e6db74">&#34;Login</span> <span style="color:#e6db74">to</span> <span style="color:#e6db74">Proceed:</span> <span style="color:#e6db74">&#34;</span>; <span style="color:#75715e">#(or whatever message you want)
</span></span></span><span style="display:flex;"><span><span style="color:#66d9ef">auth_basic_user_file</span> <span style="color:#e6db74">/path/to/htpasswdfile/htpasswd</span>;
</span></span></code></pre></div><p>To <em>append</em> <em><strong>another</strong></em> user to the <code>htpasswd</code> file do:</p>
<p><code>htpasswd /path/to/htpasswd/htpasswd second-user</code></p>
<p>That ought to do it.</p>
<p>P.S. Install <code>apache-utils</code> on Debian or use Paru/Yay to install <code>nginx_passwd</code> on Arch.</p>
<p><hr style='margin-left: auto; margin-right: auto; margin-bottom: 40px; margin-top: 50px; width:100px; border: none; background-color:rgb(238, 238, 238); color: rgb(238, 238, 238);  height: 1px;'/>

Feedback on this post? Mail me at <a href="mailto:feedback@janusworx.com">feedback@janusworx.com</a>
<br>

<br>

P.P.S. Subscribe to my <a href="https://janusworx.com/subscribe/">mailing list!</a><br>
Forward these posts and letters to your friends and get them to subscribe!<br>
P.P.P.S. Feed my <a href="https://www.amazon.in/hz/wishlist/ls/2QAUKHHAMOOVS?ref_=wl_share">insatiable reading habit.</a></p>
<hr>
]]></content:encoded>
    </item>
  </channel>
</rss>
