<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type="text/xsl" href="rss.xsl"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>TailoredSec Blog</title>
        <link>https://tailoredsec.com/blog/</link>
        <description>TailoredSec Blog</description>
        <lastBuildDate>Sat, 06 Jun 2026 00:00:00 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <item>
            <title><![CDATA[How to set up a log relay Part 2 - Client Setup]]></title>
            <link>https://tailoredsec.com/blog/siem-log-relay-pt2/</link>
            <guid>https://tailoredsec.com/blog/siem-log-relay-pt2/</guid>
            <pubDate>Sat, 06 Jun 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Learn how to set up device to send logs to a SIEM through a log ingestor/relay with mTLS (mutual TLS) for secure log ingestion.]]></description>
            <content:encoded><![CDATA[<p>In <a href="https://tailoredsec.com/blog/siem-log-relay-pt1/">Part 1 of this tutorial</a>, you learned how to set up a log relay server that uses mTLS to securely receive logs from only specifically registered devices and forward them to a SIEM like <a href="https://wazuh.com/" target="_blank" rel="noopener noreferrer">Wazuh</a>.</p>
<p>In this, Part 2 of the tutorial, you'll learn how to configure agents (or clients) to authenticate themselves to that log relay and send their logs securely to the SIEM server.</p>
<hr>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="overview">Overview<a href="https://tailoredsec.com/blog/siem-log-relay-pt2/#overview" class="hash-link" aria-label="Direct link to Overview" title="Direct link to Overview">​</a></h2>
<p>Before diving in, review these steps to get an idea for what's ahead:</p>
<ol>
<li>Create a certificate for your client<!-- -->
<ul>
<li>Use the CA (Certificate Authority) you created in Part 1 to generate and sign a certificate for each client</li>
</ul>
</li>
<li>Install and configure the software necessary to handle mTLS on your client machine</li>
<li>Install your SIEM agent and configure it to use the log relay you've created</li>
</ol>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="certificate-preparation">Certificate preparation<a href="https://tailoredsec.com/blog/siem-log-relay-pt2/#certificate-preparation" class="hash-link" aria-label="Direct link to Certificate preparation" title="Direct link to Certificate preparation">​</a></h2>
<p>First, we need to create a certificate to be used by the device you want to monitor. On the machine you're using as your certificate authority (CA), perform the following steps:</p>
<ol>
<li>
<p>Create the key</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl genrsa </span><span class="token parameter variable" style="color:#36acaa">-out</span><span class="token plain"> agent-hostname.key </span><span class="token number" style="color:#36acaa">4096</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">600</span><span class="token plain"> agent-hostname.key</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
</ol>
<p>This gives you a file called <code>&lt;agent-hostname&gt;.key</code>. Hold onto that.</p>
<ol>
<li>
<p>Create a CSR (Certificate Signing Request) for the key</p>
<p>Use the following command, making sure to replace <code>agent-hostname</code> and <code>YourOrg</code> with the names of the device to be monitored and the name you want to represent your "organization".</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>This command uses the name of the file you created in the previous step. Remember to copy that exactly and provide it in the <code>-key</code> parameter of the command.</p></div></div>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl req </span><span class="token parameter variable" style="color:#36acaa">-new</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-key</span><span class="token plain"> agent-hostname.key </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-out</span><span class="token plain"> agent-hostname.csr </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-subj</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"/C=US/O=YourOrg/CN=agent-hostname"</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Use the CSR to create and sign a certificate for the host to be monitored.</p>
<p>Remember to replace <code>agent-hostname</code> and <code>mtls-ca</code> with the names of the host to be monitored and the name of your certificate authority, respectively.</p>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>This command includes several flags (parameters), so click here for a quick breakdown of the whole command if you're interested:</summary><div><div class="collapsibleContent_i85q"><table><thead><tr><th>Flag</th><th>Meaning</th><th>Purpose in This Command</th></tr></thead><tbody><tr><td><code>openssl x509</code></td><td>Invokes the OpenSSL X.509 certificate utility.</td><td>Used to create, inspect, or sign X.509 certificates.</td></tr><tr><td><code>-req</code></td><td>Treats the input as a Certificate Signing Request (CSR).</td><td>Tells OpenSSL to read and sign the CSR specified by <code>-in</code>.</td></tr><tr><td><code>-in agent-hostname.csr</code></td><td>Specifies the input CSR file.</td><td>Reads the certificate request from <code>agent-hostname.csr</code>.</td></tr><tr><td><code>-CA mtls-ca.pem</code></td><td>Specifies the CA certificate to use for signing.</td><td>Uses <code>mtls-ca.pem</code> as the issuing Certificate Authority certificate.<br><strong>Change this to the name of your CA's <code>.pem</code> file.</strong></td></tr><tr><td><code>-CAkey mtls-ca.key</code></td><td>Specifies the private key corresponding to the CA certificate.</td><td>Uses <code>mtls-ca.key</code> to cryptographically sign the new certificate.<br><strong>Change this to the name of your CA's <code>.key</code> file.</strong></td></tr><tr><td><code>-CAcreateserial</code></td><td>Creates a CA serial number file if one does not already exist.</td><td>Generates a file (typically <code>mtls-ca.srl</code>) to track certificate serial numbers issued by this CA.</td></tr><tr><td><code>-out agent-hostname.crt</code></td><td>Specifies the output certificate file.</td><td>Writes the signed certificate to <code>agent-hostname.crt</code>.</td></tr><tr><td><code>-days 825</code></td><td>Sets the certificate validity period in days.</td><td>Makes the issued certificate valid for 825 days from the time of signing. <br><strong>You can change this duration or omit it if you want. However, if you don't provide a value, it will expire after 30 days by default.</strong></td></tr><tr><td><code>-sha256</code></td><td>Uses SHA-256 as the message digest algorithm for signing.</td><td>Signs the certificate using a SHA-256 hash, which is a widely accepted secure algorithm.</td></tr><tr><td><code>\</code></td><td>Shell line-continuation character (not an OpenSSL option).</td><td>Allows the command to be split across multiple lines for readability while being executed as a single command.</td></tr></tbody></table></div></div></details>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl x509 </span><span class="token parameter variable" style="color:#36acaa">-req</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-in</span><span class="token plain"> agent-hostname.csr </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-CA</span><span class="token plain"> mtls-ca.pem </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-CAkey</span><span class="token plain"> mtls-ca.key </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-CAcreateserial</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-out</span><span class="token plain"> agent-hostname.crt </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-days</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">825</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-sha256</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">644</span><span class="token plain"> agent-hostname.crt</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Copy the key and certificate to the system you want to monitor.</p>
<p>These are the files that end with <code>.crt</code> and <code>.key</code>.</p>
<p>These files were created on the machine that's acting as your certificate authority, but <strong>they need to be on the machine you want to enroll in monitoring</strong>. So, use whatever tool works best for you to transfer them to that device. You could copy them to a USB drive, <a href="https://en.wikipedia.org/wiki/Secure_copy_protocol" target="_blank" rel="noopener noreferrer">use SCP</a>, or whatever you prefer.</p>
</li>
</ol>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="install-and-configure-stunnel">Install and configure stunnel<a href="https://tailoredsec.com/blog/siem-log-relay-pt2/#install-and-configure-stunnel" class="hash-link" aria-label="Direct link to Install and configure stunnel" title="Direct link to Install and configure stunnel">​</a></h2>
<p>In <a href="https://tailoredsec.com/blog/siem-log-relay-pt1/">Part 1 of this tutorial</a>, we set up a log relay and used <strong>HAProxy</strong> to simultaneously terminate TLS and forward packets to the Wazuh server. <strong>We likewise need a tool to terminate TLS on the host to be monitored</strong>. For that, we're going to use <strong>Stunnel</strong>.</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>Windows vs Mac vs Linux</div><div class="admonitionContent_BuS1"><p><strong>I've included variations of these instructions for Windows and Linux</strong>, as these are the platforms I have available to me for testing/validation. If you'd like to adapt this process to monitor a MacOS device, I encourage you to use the Linux steps as a general guide. You may also find success using an AI tool to help you adapt the instructions for MacOS.</p></div></div>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">Windows</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Linux</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><ol>
<li>
<p>Install Stunnel</p>
<ol>
<li>Download and run the installer from <a href="https://stunnel.org/downloads.html" target="_blank" rel="noopener noreferrer">https://stunnel.org/downloads.html</a>.</li>
<li>When you start the installer, make sure to install it at the system level, which tells the installer to put it in <code>C:\Program Files (x86)\stunnel</code></li>
<li>Then, just continue to follow the installer prompts to provide information about your org. It's not actually that important what you put here and you can provide a period (<code>.</code>) if you want to skip things.</li>
</ol>
</li>
<li>
<p>Organize your files and certificates.</p>
<p>You should make sure this directory structure and these files exist.</p>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">C:\Program Files (x86)\stunnel\</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">│</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── config\</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">│   └── stunnel.conf</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── moreconfig\</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">|   ├── wazuh-1514.conf</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">|   └── wazuh-1515.conf</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── certs\</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">│   ├── agent-hostname.crt</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">│   ├── agent-hostname.key</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">│   └── mtls-ca.pem (This is the .pem file you created for your CA in part 1)</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<ol>
<li>Start by copying your certificate and key files to the <code>certs</code> folder.</li>
<li>Next, make sure the <code>stunnel.conf</code> file exists in the <code>config</code> directory.</li>
<li>Lastly, create a <code>moreconfig</code> directory and create two empty files inside it named <code>wazuh-1515.conf</code> and <code>wazuh-1514.conf</code>.</li>
</ol>
</li>
<li>
<p>Make sure file permissions are sufficiently permissive but otherwise locked down for the certificate files you imported.</p>
<ol>
<li>
<p>OPTION 1: Open the <code>certs</code> folder in File Explorer, right-click it, and select <strong>Properties &gt; Security</strong>. Then make sure the only users with access are your user, SYSTEM, and the Administrators group.</p>
</li>
<li>
<p>OPTION 2: Run these commands in PowerShell as Administrator:</p>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">icacls </span><span class="token string" style="color:#e3116c">"C:\Program Files (x86)\stunnel\certs"</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">/</span><span class="token plain">inheritance:r</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">icacls </span><span class="token string" style="color:#e3116c">"C:\Program Files (x86)\stunnel\certs"</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">/</span><span class="token plain">grant:r </span><span class="token string" style="color:#e3116c">"</span><span class="token string function" style="color:#d73a49">$</span><span class="token string function punctuation" style="color:#393A34">(</span><span class="token string function variable" style="color:#36acaa">$env</span><span class="token string function" style="color:#d73a49">:USERNAME</span><span class="token string function punctuation" style="color:#393A34">)</span><span class="token string" style="color:#e3116c">:(F)"</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
</ol>
</li>
<li>
<p>Edit the configuration files:</p>
<ol>
<li>
<p>Edit the <code>stunnel.conf</code> file you created at <code>C:\Program Files (x86)\stunnel\config\stunnel.conf</code> with Notepad and make sure it includes this line:</p>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">include = C:\Program Files (x86)\stunnel\moreconfig</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Edit <code>C:\Program Files (x86)\stunnel\wazuh-1514.conf</code> in Notepad and insert the following contents:</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>In this step <em>and the next step</em>, make sure to replace <code>lr.example.com</code> with the <strong>IP address or URL of the <em>log relay</em> you set up in Part 1 of this tutorial</strong>.</p><p>Additionally, replace <code>agent-hostname</code> and <code>mtls-ca</code> with the names of your device and your CA server, respectively.</p><p>The <code>checkHost</code> parameter tells Stunnel to verify that the relay server certificate matches the server’s hostname. In this config, it should be set to the hostname that appears on the certificate for the relay; Otherwise, you can omit that line from the config if you do not want to enforce hostname verification.</p></div></div>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">client = yes</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">[wazuh-agent-1514]</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">accept = 127.0.0.1:1514</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">connect = lr.example.com:1514</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">cert = C:\Program Files (x86)\stunnel\certs\agent-hostname.crt</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">key = C:\Program Files (x86)\stunnel\certs\agent-hostname.key</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">CAfile = C:\Program Files (x86)\stunnel\certs\mtls-ca.pem</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">verifyChain = yes</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">checkHost = lr.example.com</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Edit <code>C:\Program Files (x86)\stunnel\wazuh-1515.conf</code> in Notepad and insert the following contents:</p>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">client = yes</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">[wazuh-agent-1515]</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">accept = 127.0.0.1:1515</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">connect = lr.example.com:1515</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">cert = C:\Program Files (x86)\stunnel\certs\agent-hostname.crt</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">key  = C:\Program Files (x86)\stunnel\certs\agent-hostname.key</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">CAfile = C:\Program Files (x86)\stunnel\certs\mtls-ca.pem</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">verifyChain = yes</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">checkHost = lr.example.com</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
</ol>
</li>
<li>
<p>Install Stunnel as a Windows Service so it runs automatically at startup.</p>
<ol>
<li>
<p>Run these commands in Command Prompt as Administrator:</p>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">cd C:\Users\&lt;USERNAME&gt;\AppData\Local\Programs\stunnel\bin</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain">\stunnel</span><span class="token punctuation" style="color:#393A34">.</span><span class="token plain">exe </span><span class="token operator" style="color:#393A34">-</span><span class="token plain">install</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>To verify it's running properly, run this command:</p>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">netstat </span><span class="token operator" style="color:#393A34">-</span><span class="token plain">ano </span><span class="token punctuation" style="color:#393A34">|</span><span class="token plain"> findstr 1514</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>Look for a line that looks like this:</p>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">127.0.0.1:1514 LISTENING</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>You can also verify that it was properly configured to autostart after a reboot. Make sure to run this in Command Prompt and not Powershell:</p>
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sc</span><span class="token plain"> qc stunnel</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>You should see <code>AUTO_START</code> in the results of that command.</p>
</li>
</ol>
</li>
</ol></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><ol>
<li>
<p>Install Stunnel</p>
<p>Install with whatever package manager you use, for example, with the <code>apt</code> package manager:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">apt</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">install</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-y</span><span class="token plain"> stunnel4</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>Extra note for Debian/Ubuntu based distributions:</div><div class="admonitionContent_BuS1"><p>If you run a Linux distribution based on Debian or Ubuntu, you need to run another command after installing Stunnel. This edits Stunnel's configuration file to allow the <code>stunnel4</code> service to be started, and set to automatically set to start at boot.</p><div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">sed</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-i</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">'s/^ENABLED=0/ENABLED=1/'</span><span class="token plain"> /etc/default/stunnel4</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div><p>(You could also make this change manually by editing that configuration file.)</p></div></div>
</li>
<li>
<p>Organize your files and certificates.</p>
<p>You should make sure this directory structure and these files exist:</p>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">/etc/stunnel</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── certs</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">│   ├── agent-hostname.crt</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">│   ├── agent-hostname.key</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">│   └── mtls-ca.pem (This is the .pem file you created for your CA in part 1)</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── conf.d</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">│&nbsp;&nbsp; ├── wazuh-1514.conf</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">|   └── wazuh-1515.conf</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">├── stunnel.conf</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">└── stunnel.conf-sample (This one isn't important if you dont' see it.)</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<ol>
<li>Start by copying your certificate and key files to the <code>certs</code> folder.</li>
<li>Next, make sure the <code>stunnel.conf</code> file exists in the main directory.</li>
<li>Lastly, create <code>wazuh-1515.conf</code> and <code>wazuh-1514.conf</code> in the <code>conf.d</code> directory.</li>
</ol>
</li>
<li>
<p>Make sure file permissions are sufficiently permissive but otherwise locked down for the files you imported/created.</p>
<ol>
<li>
<p>Run these commands:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">700</span><span class="token plain"> /etc/stunnel/certs</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">600</span><span class="token plain"> /etc/stunnel/certs/*.key</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">644</span><span class="token plain"> /etc/stunnel/certs/*.crt /etc/stunnel/certs/*.pem</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
</ol>
</li>
<li>
<p>Edit the <code>stunnel.conf</code> file you created at <code>/etc/stunnel/stunnel.conf</code> and make sure it has the right contents. You can use this command to do that quickly:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">tee</span><span class="token plain"> /etc/stunnel/stunnel.conf </span><span class="token operator" style="color:#393A34">&gt;</span><span class="token plain">/dev/null </span><span class="token operator" style="color:#393A34">&lt;&lt;</span><span class="token string" style="color:#e3116c">EOF</span><br></span><span class="token-line" style="color:#393A34"><span class="token string" style="color:#e3116c">include = /etc/stunnel/*.conf</span><br></span><span class="token-line" style="color:#393A34"><span class="token string" style="color:#e3116c">EOF</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<ol>
<li>
<p>Edit <code>/etc/stunnel/wazuh-1514.conf</code> and insert the following contents:</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>In this step <em>and the next step</em>, make sure to replace <code>lr.example.com</code> with the <strong>IP address or URL of the <em>log relay</em> you set up in Part 1 of this tutorial</strong>.</p><p>Additionally, replace <code>agent-hostname</code> and <code>mtls-ca</code> with the names of your device and your CA server, respectively.</p><p>The <code>checkHost</code> parameter tells Stunnel to verify that the relay server certificate matches the server’s hostname. In this config, it should be set to the hostname that appears on the certificate for the relay; Otherwise, you can omit that line from the config if you do not want to enforce hostname verification.</p></div></div>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">client = yes</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">foreground = no</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">[wazuh-agent-1514]</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">accept = 127.0.0.1:1514</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">connect = lr.example.com:1514</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">cert = /etc/stunnel/certs/agent-hostname.crt</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">key = /etc/stunnel/certs/agent-hostname.key</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">CAfile = /etc/stunnel/certs/mtls-ca.pem</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">verifyChain = yes</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">checkHost = lr.example.com</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Edit <code>/etc/stunnel/wazuh-1515.conf</code> and insert the following contents:</p>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">client = yes</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">foreground = no</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">[wazuh-agent-1515]</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">accept = 127.0.0.1:1515</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">connect = lr.example.com:1515</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">cert = /etc/stunnel/certs/agent-hostname.crt</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">key  = /etc/stunnel/certs/agent-hostname.key</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">CAfile = /etc/stunnel/certs/mtls-ca.pem</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">verifyChain = yes</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">checkHost = lr.example.com</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
</ol>
</li>
<li>
<p>Start Stunnel by running this command:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> systemctl restart stunnel4</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>You can verify it worked by running this:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> ss </span><span class="token parameter variable" style="color:#36acaa">-lntp</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">|</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">grep</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">1514</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>You should see something like this in the output of that command:</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>The important parts are <code>LISTEN</code> and <code>127.0.0.1:1514</code></p></div></div>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">LISTEN 0      4096       127.0.0.1:1514       0.0.0.0:*    users:(("stunnel",pid=1646,fd=9))</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
</ol></div></div></div>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="install-and-configure-the-wazuh-agent">Install and configure the Wazuh agent<a href="https://tailoredsec.com/blog/siem-log-relay-pt2/#install-and-configure-the-wazuh-agent" class="hash-link" aria-label="Direct link to Install and configure the Wazuh agent" title="Direct link to Install and configure the Wazuh agent">​</a></h2>
<p>Now that stunnel is set up, you're ready to install the Wazuh agent on your device! Start by following <a href="https://documentation.wazuh.com/current/installation-guide/wazuh-agent/index.html" target="_blank" rel="noopener noreferrer">the official Wazuh documentation</a> to install the agent on your machine.</p>
<div class="theme-admonition theme-admonition-tip admonition_xJq3 alert alert--success"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 12 16"><path fill-rule="evenodd" d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>tip</div><div class="admonitionContent_BuS1"><p>If you're using Arch Linux or another Linux distribution that's not supported by default, you can install the Wazuh agent by compiling it from source.</p><p>Refer to <a href="https://documentation.wazuh.com/current/deployment-options/wazuh-from-sources/wazuh-agent/index.html" target="_blank" rel="noopener noreferrer">the official Wazuh documentation</a> for those instructions.</p></div></div>
<p>Once the Wazuh agent is installed, you just need to edit the <code>ossec.conf</code> configuration file and replace the server address with <code>127.0.0.1</code>. When that is properly configured, Wazuh will send all logs to the local port where Stunnel is listening and ready to route to the log relay through TLS. Here is a sample of the <code>server</code> section of the Wazuh agent configuration that will show you what that should look like:</p>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">&lt;server&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  &lt;address&gt;127.0.0.1&lt;/address&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">  &lt;port&gt;1514&lt;/port&gt;</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">&lt;/server&gt;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">Windows</li><li role="tab" tabindex="-1" aria-selected="false" class="tabs__item tabItem_LNqP">Linux</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><ol>
<li>Edit the configuration file at <code>C:\Program Files (x86)\ossec-agent\ossec.conf</code></li>
<li>Restart the service by running this command in PowerShell<!-- -->
<div class="language-powershell codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-powershell codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">Restart-Service</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">-</span><span class="token plain">Name wazuh</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
</ol></div><div role="tabpanel" class="tabItem_Ymn6" hidden=""><ol>
<li>Edit the configuration file at <code>/var/ossec/etc/ossec.conf</code></li>
<li>Restart the service by running this command<!-- -->
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> systemctl restart wazuh-agent</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
</ol></div></div></div>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="summary--conclusion">Summary &amp; Conclusion<a href="https://tailoredsec.com/blog/siem-log-relay-pt2/#summary--conclusion" class="hash-link" aria-label="Direct link to Summary &amp; Conclusion" title="Direct link to Summary &amp; Conclusion">​</a></h2>
<p>Congratulations! With these steps completed, you should have successfully enrolled a new device with Wazuh, allowing it to send logs <strong>through your secure log relay</strong> using mTLS.</p>
<p>Now, you're using a configuration that reduces exposure while providing you with better endpoint visibility.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="quirks-of-this-setup">Quirks of this setup<a href="https://tailoredsec.com/blog/siem-log-relay-pt2/#quirks-of-this-setup" class="hash-link" aria-label="Direct link to Quirks of this setup" title="Direct link to Quirks of this setup">​</a></h3>
<p>One quirk of this setup is all the agents you enroll this way will display the IP address <code>127.0.0.1</code> in the Wazuh manager. I'm sure there is a workaround that can fix this, but I haven't found a way to do that yet because it hasn't been important to me.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to set up a log relay Part 1 - Server Setup]]></title>
            <link>https://tailoredsec.com/blog/siem-log-relay-pt1/</link>
            <guid>https://tailoredsec.com/blog/siem-log-relay-pt1/</guid>
            <pubDate>Sat, 30 May 2026 00:00:00 GMT</pubDate>
            <description><![CDATA[Learn how to set up a log ingestor/relay with mTLS (mutual TLS) for secure log ingestion.]]></description>
            <content:encoded><![CDATA[<p>A SIEM (Security Information and Event Management) tool like <a href="https://wazuh.com/" target="_blank" rel="noopener noreferrer">Wazuh</a> is only as good as the logs it ingests. It's important to gather useful information from your critical assets, and <strong>endpoints are some of the most important assets we manage</strong>. But how do you gather logs from those devices when they're constantly moving around?</p>
<hr>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="background">Background<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#background" class="hash-link" aria-label="Direct link to Background" title="Direct link to Background">​</a></h2>
<p>I've been running Wazuh as the SIEM for my homelab for two years now, but have only ever been able to consistenty monitor machines that lived <strong>inside my homelab</strong>. I have always really wanted to be able to monitor logs from my personal devices even when I'm away from home. This is important to me because being unable to monitor logs generated when I'm away from home creates a huge blind spot in my security posture.</p>
<p>At one point, I tried to solve this problem by using <a href="https://tailscale.com/" target="_blank" rel="noopener noreferrer">Tailscale</a> to connect my remote devices directly to the Wazuh server, but I didn't like that method very much because it required me to keep Tailscale on all the time. Since I use other VPNs, that didn't work well for me, as Tailscale and the VPNs would conflict with one another.</p>
<p>I eventually decided I would need to make the log ingestion ports publicly accessible, but I wanted to do as much as I could to reduce the risks associated with that exposure, at which point <strong>I decided to set up mTLS</strong>. In this blog, I'll show you how to do that as well.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="why-use-mtls">Why use mTLS?<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#why-use-mtls" class="hash-link" aria-label="Direct link to Why use mTLS?" title="Direct link to Why use mTLS?">​</a></h2>
<p>To answer the question of why I used mTLS, I'll first explain what mTLS is. <a href="https://www.cloudflare.com/learning/access-management/what-is-mutual-tls/" target="_blank" rel="noopener noreferrer">Cloudflare's website</a> states it this way:</p>
<blockquote>
<p>"mTLS ensures that the parties at each end of a network connection are who they claim to be"</p>
</blockquote>
<p>This means that when a remote device connects to the server, both the server and the device authenticate one another to ensure they can trust one another. Another excerpt from Cloudflare's explanation of mTLS says:</p>
<blockquote>
<p>"mTLS is often used in a <strong>Zero Trust security framework</strong> to verify users, devices, and servers within an organization. . . Zero Trust means that <strong>no user, device, or network traffic is trusted by default</strong>, an approach that helps eliminate many security vulnerabilities."</p>
</blockquote>
<p>These security benefits are <em>massively helpful</em> when you're exposing a service publicly. In the case of log collection, they make it possible for a server to receive logs from <em>anywhere</em>, but <strong>not</strong> from just <em>anyone</em>. They also make it possible for a device to be just as careful about where it sends logs.</p>
<p>Because a SIEM collects all kinds of information (including some potentially sensitive information) from the endpoints it monitors, I find it super important to enforce these zero trust principles in the connection between the server and its agents. With that, let's jump into how to set it up!</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="tutorial-overview">Tutorial Overview<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#tutorial-overview" class="hash-link" aria-label="Direct link to Tutorial Overview" title="Direct link to Tutorial Overview">​</a></h2>
<p>Before your fingers hit the keyboard, begin with the end in mind by reviewing this list of steps.</p>
<ol>
<li><strong>Set up PKI (Public Key Infrastructure)</strong>
<ul>
<li>Create a CA (Certificate Authority)</li>
</ul>
</li>
<li><strong>Configure relay server and HAProxy</strong>
<ul>
<li>Pick and install an OS</li>
<li>Apply security hardening</li>
<li>Configure HAProxy</li>
</ul>
</li>
<li><strong>Networking + DNS setup</strong></li>
</ol>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="diagram">Diagram<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#diagram" class="hash-link" aria-label="Direct link to Diagram" title="Direct link to Diagram">​</a></h3>
<p>This is a rough visual diagram of the setup you'll configure. Hopefully this helps you picture what we're trying to accomplish.</p>
<img src="https://tailoredsec.com/img/logrelay-diagram-light.png" alt="Docusaurus themed image" class="themedComponent_mlkZ themedComponent--light_NVdE"><img src="https://tailoredsec.com/img/logrelay-diagram-dark.png" alt="Docusaurus themed image" class="themedComponent_mlkZ themedComponent--dark_xIcU">
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="prerequisites">Prerequisites<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#prerequisites" class="hash-link" aria-label="Direct link to Prerequisites" title="Direct link to Prerequisites">​</a></h3>
<p>These are the resources/things you'll need to set this up.</p>
<ol>
<li><strong>Your own domain OR a machine with a static public IP address</strong>
<ul>
<li>I know this prerequisite can be discouraging if you don't already have one, but I HIGHLY recommend getting one. It'll open up your home-labbing opportunities so much, and it's not very expensive.</li>
<li>If you do not have your own domain and don't want to purchase one, you have the option of setting up your log relay on a server with a static public IP address such as a VPS in AWS, Linode, or similar cloud-hosting service. However, this is not my recommended method, and I would strongly suggest purchasing a domain. (It'll probably be cheaper than the alternative anyway).</li>
</ul>
</li>
<li><strong>Access to two or three separate machines (virtual or physical)</strong>
<ul>
<li>One will be your SIEM server (I'll use Wazuh in my examples), one will be the certificate authority (CA) for your PKI, and the other will be the relay that receives and forwards your logs to the SIEM server.</li>
<li><strong>Note:</strong> You can technically run the CA on one of the other two servers, but it's a little risky to combine them.</li>
</ul>
</li>
<li><strong>An endpoint you want to monitor</strong>
<ul>
<li>If you just want to set this up as a PoC, you can use any physical or virtual machine. However, it is designed with mobile devices like personal laptops in mind. They're the ones that will get the most use from a setup like this.</li>
</ul>
</li>
</ol>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="step-1---set-up-pki-public-key-infrastructure">Step 1 - Set up PKI (Public Key Infrastructure)<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#step-1---set-up-pki-public-key-infrastructure" class="hash-link" aria-label="Direct link to Step 1 - Set up PKI (Public Key Infrastructure)" title="Direct link to Step 1 - Set up PKI (Public Key Infrastructure)">​</a></h2>
<p>Let's start by creating your certificate authority. Your certificate authority is critical in issuing and signing certificates that will be used in mTLS. Here, it's important to understand that your certificate authority isn't necessarily a <em>machine</em>. It's essentially a CA private key and a CA certificate.</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>Helpful Explanation of TLS &amp; Public Key Cryptography</div><div class="admonitionContent_BuS1"><p><a href="https://www.ibm.com/think/topics/transport-layer-security" target="_blank" rel="noopener noreferrer">IBM's website</a> has a great, in-depth explanation of TLS and public key cryptography that will make a great read if these concepts are new to you.</p><p>You may also benefit from reading <a href="https://docs.redhat.com/en/documentation/red_hat_certificate_system/9/html/planning_installation_and_deployment_guide/introduction_to_public_key_cryptography" target="_blank" rel="noopener noreferrer">RedHat's explanation of public key cryptography</a>.</p></div></div>
<p>Your CA private key and CA certificate are just files and they can live anywhere you want. Often, it's a good idea to store them encrypted in an offline container like a USB drive. However, you will need a machine to access them any time you want to issue or sign a new certificate, so you <em>can</em> keep them on the machine you'll be using to sign and issue certificates. It's up to you how you want to handle it, but the latter option is likely appropriate for a homelab setup.</p>
<p>To create them, use these commands:</p>
<ol>
<li>
<p>Create your CA private key:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl genrsa </span><span class="token parameter variable" style="color:#36acaa">-out</span><span class="token plain"> mtls-ca.key </span><span class="token number" style="color:#36acaa">4096</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">600</span><span class="token plain"> mtls-ca.key</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>This will generate a file called <code>mtls-ca.key</code>.</p>
<p><strong>This key does NOT need to be copied anywhere else, and you should only copy it if you have to back it up and if you're extremely careful to protect it.</strong></p>
</li>
<li>
<p>Create your CA certificate (Change "YourOrg" and "relay-mtls-ca" to the names you prefer.)</p>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>This command includes several flags (parameters), so click here for a quick breakdown of the whole command if you're interested:</summary><div><div class="collapsibleContent_i85q"><table><thead><tr><th>Flag</th><th>Meaning</th><th>Purpose in This Command</th></tr></thead><tbody><tr><td><code>openssl req</code></td><td>Invokes the OpenSSL certificate request utility.</td><td>Used to create and process certificate requests and self-signed certificates.</td></tr><tr><td><code>-x509</code></td><td>Outputs a self-signed X.509 certificate instead of a CSR.</td><td>Creates a self-signed Certificate Authority (CA) certificate directly, rather than generating a certificate signing request.</td></tr><tr><td><code>-new</code></td><td>Generates a new certificate request or certificate.</td><td>Creates a new certificate rather than processing an existing one.</td></tr><tr><td><code>-noenc</code></td><td>Skips encryption of the private key.</td><td>Prevents OpenSSL from prompting for a passphrase when using the private key.<br><strong>Use this only if you are comfortable storing the CA private key unencrypted.</strong></td></tr><tr><td><code>-key mtls-ca.key</code></td><td>Specifies the private key file to use.</td><td>Uses <code>mtls-ca.key</code> as the private key associated with the new CA certificate.<br><strong>Change this to the name of your CA private key file if different.</strong></td></tr><tr><td><code>-sha256</code></td><td>Uses SHA-256 as the message digest algorithm for signing.</td><td>Signs the certificate using a SHA-256 hash, which is a widely accepted secure algorithm.</td></tr><tr><td><code>-days 3650</code></td><td>Sets the certificate validity period in days.</td><td>Makes the CA certificate valid for 3,650 days (approximately 10 years).<br><strong>You can change this duration if you want.</strong></td></tr><tr><td><code>-out mtls-ca.pem</code></td><td>Specifies the output certificate file.</td><td>Writes the generated CA certificate to <code>mtls-ca.pem</code>.<br><strong>Change this to your preferred certificate filename if desired. But know that this tutorial assumes you named it this way.</strong></td></tr><tr><td><code>-subj "/C=US/O=YourOrg/CN=relay-mtls-ca"</code></td><td>Specifies the certificate subject non-interactively.</td><td>Sets the certificate's Distinguished Name (DN) without prompting for input. In this example, the country is <code>US</code>, the organization is <code>YourOrg</code>, and the common name is <code>relay-mtls-ca</code>.<br><strong>Replace these values with your desired information.</strong></td></tr><tr><td><code>\</code></td><td>Shell line-continuation character (not an OpenSSL option).</td><td>Allows the command to be split across multiple lines for readability while being executed as a single command.</td></tr></tbody></table></div></div></details>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl req </span><span class="token parameter variable" style="color:#36acaa">-x509</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-new</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-noenc</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-key</span><span class="token plain"> mtls-ca.key </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-sha256</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-days</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">3650</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-out</span><span class="token plain"> mtls-ca.pem </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-subj</span><span class="token plain"> </span><span class="token string" style="color:#e3116c">"/C=US/O=YourOrg/CN=relay-mtls-ca"</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">644</span><span class="token plain"> mtls-ca.pem</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>This will create a file called <code>mtls-ca.pem</code>, which is your new CA certificate. It is an X509 certificate, which you specified in that command when you ran <code>openssl req -x509...</code></p>
</li>
<li>
<p>Create your relay server's private key</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl genrsa </span><span class="token parameter variable" style="color:#36acaa">-out</span><span class="token plain"> relay.key </span><span class="token number" style="color:#36acaa">4096</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">600</span><span class="token plain"> relay.key</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Create a CSR (Certificate Signing Request) configuration file</p>
<ul>
<li>Create a file called <code>relay.req.conf</code> and copy/paste these contents to that file.</li>
<li>Be sure to replace "YourOrg" and "example.com" and the entries under <code>alt_names</code> to match what you want them to.</li>
</ul>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">[req]</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">distinguished_name = req_distinguished_name</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">req_extensions     = req_ext</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">prompt             = no</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">[req_distinguished_name]</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">C  = US</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">O  = YourOrg</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">CN = lr.example.com</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">[req_ext]</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">subjectAltName = @alt_names</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">[alt_names]</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">DNS.1 = lr.example.com</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">DNS.2 = wazuh-relay.example.com</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Generate the CSR for your relay server</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl req </span><span class="token parameter variable" style="color:#36acaa">-new</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-key</span><span class="token plain"> relay.key </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-out</span><span class="token plain"> relay.csr </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-config</span><span class="token plain"> relay.req.conf</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Sign the relay's certificate</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl x509 </span><span class="token parameter variable" style="color:#36acaa">-req</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-in</span><span class="token plain"> relay.csr </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-CA</span><span class="token plain"> mtls-ca.pem </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-CAkey</span><span class="token plain"> mtls-ca.key </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-CAcreateserial</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-out</span><span class="token plain"> relay.crt </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-days</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">825</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-sha256</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-extfile</span><span class="token plain"> relay.req.conf </span><span class="token punctuation" style="color:#393A34">\</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token parameter variable" style="color:#36acaa">-extensions</span><span class="token plain"> req_ext</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">644</span><span class="token plain"> relay.crt</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Create your relay server's "PEM bundle"</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>A "PEM bundle" is a file with a <code>.pem</code> extension that combines a certificate and a private key. This is useful because some tools/services, like the ones we'll be using in this guide, require both to be bundled into a single file.</p></div></div>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">cat</span><span class="token plain"> relay.crt relay.key </span><span class="token operator" style="color:#393A34">&gt;</span><span class="token plain"> relay.pem</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">600</span><span class="token plain"> relay.pem</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
</ol>
<p>Congratulations! If you followed the steps outlined above, you should now have a <strong>Certificate Authority</strong> ready to use.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="make-sure-it-all-worked">Make sure it all worked<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#make-sure-it-all-worked" class="hash-link" aria-label="Direct link to Make sure it all worked" title="Direct link to Make sure it all worked">​</a></h3>
<p>Before we move on, let's quickly stop to make sure you've done everything correctly so far. You should have all of the following files:</p>
<table><thead><tr><th>Filename</th><th>Description</th></tr></thead><tbody><tr><td><code>mtls-ca.key</code></td><td>CA private key</td></tr><tr><td><code>mtls-ca.pem</code></td><td>CA certificate</td></tr><tr><td><code>mtls-ca.srl</code></td><td>Certificate serial number file created by OpenSSL</td></tr><tr><td><code>relay.key</code></td><td>Relay server private key</td></tr><tr><td><code>relay.req.conf</code></td><td>CSR configuration file</td></tr><tr><td><code>relay.csr</code></td><td>Certificate Signing Request</td></tr><tr><td><code>relay.crt</code></td><td>Signed relay certificate</td></tr><tr><td><code>relay.pem</code></td><td>Combined certificate and private key bundle used by Stunnel and related services</td></tr></tbody></table>
<p>If those all look good, it's a good idea to verify that all your certificates were created correctly and that your relay certificate was properly signed with the Certificate Authority (CA) you just created.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="verify-the-ca-certificate">Verify the CA Certificate<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#verify-the-ca-certificate" class="hash-link" aria-label="Direct link to Verify the CA Certificate" title="Direct link to Verify the CA Certificate">​</a></h4>
<p>Display information about your CA certificate:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl x509 </span><span class="token parameter variable" style="color:#36acaa">-in</span><span class="token plain"> mtls-ca.pem </span><span class="token parameter variable" style="color:#36acaa">-text</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-noout</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>You should see information similar to:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">Issuer: C=US, O=YourOrg, CN=relay-mtls-ca</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">Subject: C=US, O=YourOrg, CN=relay-mtls-ca</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>Because this is a self-signed CA certificate, the <strong>Issuer</strong> and <strong>Subject</strong> values should be identical.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="verify-the-relay-certificate">Verify the Relay Certificate<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#verify-the-relay-certificate" class="hash-link" aria-label="Direct link to Verify the Relay Certificate" title="Direct link to Verify the Relay Certificate">​</a></h4>
<p>Display information about your relay certificate:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl x509 </span><span class="token parameter variable" style="color:#36acaa">-in</span><span class="token plain"> relay.crt </span><span class="token parameter variable" style="color:#36acaa">-text</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-noout</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>Verify that the certificate contains the hostname you specified:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">Subject:</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    C=US</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    O=YourOrg</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    CN=lr.example.com</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>Also verify that the <strong>Subject Alternative Name (SAN)</strong> section contains the DNS names you configured:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">X509v3 Subject Alternative Name:</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    DNS:lr.example.com</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    DNS:wazuh-relay.example.com</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>If the SAN section is missing, clients performing hostname verification may reject the certificate.</p>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="verify-that-the-relay-certificate-was-signed-by-your-ca">Verify That the Relay Certificate Was Signed by Your CA<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#verify-that-the-relay-certificate-was-signed-by-your-ca" class="hash-link" aria-label="Direct link to Verify That the Relay Certificate Was Signed by Your CA" title="Direct link to Verify That the Relay Certificate Was Signed by Your CA">​</a></h4>
<p>Run:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl verify </span><span class="token parameter variable" style="color:#36acaa">-CAfile</span><span class="token plain"> mtls-ca.pem relay.crt</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>Expected output:</p>
<div class="language-text codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">relay.crt: OK</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>If you receive any errors, verify that:</p>
<ul>
<li>You used the correct CA certificate.</li>
<li>The relay certificate was signed using the corresponding CA private key.</li>
<li>The CA and relay certificate files were not modified after creation.</li>
</ul>
<h4 class="anchor anchorWithStickyNavbar_LWe7" id="verify-the-certificate-chain">Verify the Certificate Chain<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#verify-the-certificate-chain" class="hash-link" aria-label="Direct link to Verify the Certificate Chain" title="Direct link to Verify the Certificate Chain">​</a></h4>
<p>You can also confirm that the relay certificate's issuer matches your CA:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">openssl x509 </span><span class="token parameter variable" style="color:#36acaa">-in</span><span class="token plain"> relay.crt </span><span class="token parameter variable" style="color:#36acaa">-noout</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-issuer</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">openssl x509 </span><span class="token parameter variable" style="color:#36acaa">-in</span><span class="token plain"> mtls-ca.pem </span><span class="token parameter variable" style="color:#36acaa">-noout</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-subject</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>The issuer reported by <code>relay.crt</code> should match the subject reported by <code>mtls-ca.pem</code>.</p>
<p>If all of the checks above succeeded, congratulations! Your Certificate Authority and relay server certificate are all looking good, and you're ready to move onto the next step.</p>
<p>If anything above didn't look right, don't worry! Just go back through the steps carefully and read each step thoroughly to make sure you didn't miss something.z</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="step-2---set-up-haproxy-to-relay-logs-from-your-monitored-devices-to-wazuh">Step 2 - Set up HAProxy to relay logs from your monitored devices to Wazuh<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#step-2---set-up-haproxy-to-relay-logs-from-your-monitored-devices-to-wazuh" class="hash-link" aria-label="Direct link to Step 2 - Set up HAProxy to relay logs from your monitored devices to Wazuh" title="Direct link to Step 2 - Set up HAProxy to relay logs from your monitored devices to Wazuh">​</a></h2>
<p>Now, we'll set up HAProxy. This service will perform the dual function of <strong>authenticating clients</strong> wanting to connect to the Wazuh server and <strong>forwarding logs to the server.</strong></p>
<p>Putting HAProxy in between clients and the Wazuh server this way helps reduce the risk of your server being overwhelmed or compromised. If you were to expose your SIEM directly to the rest of the world, an attacker might try perform a denial of service attack by overwhelming the server with traffic. Or, they might attempt to send fake logs to the server to hide normal activity.</p>
<p>So, let's see the setup steps.</p>
<ol>
<li>
<p>Pick a place to install it</p>
<ul>
<li>HAProxy needs to run on a server somewhere, so that could be a physical or virtual machine. To preserve the goal of separation, it shouldn't be running as a service on the same machine or operating system that's running your Wazuh server. So, you might create a lightweight VM to run this service. Once you have one installed, proceed to the next steps.</li>
</ul>
</li>
<li>
<p>Install HAProxy</p>
<ul>
<li>This guide assumes you're using an OS with the <code>apt</code> package manager. If not, adjust commands to match your package manager.</li>
</ul>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">apt</span><span class="token plain"> update</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">apt</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">install</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-y</span><span class="token plain"> haproxy</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Install the certificates you created in <a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#step-1---set-up-pki-public-key-infrastructure">Step 1</a></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>First, you'll need to find a way to get your certificates onto the server that will host HAProxy. Do this whatever way works best for you, such as by using SCP (Secure Copy) or with a USB stick.</p><p>All you need to do is copy the files you created in the previous steps (<code>relay.pem</code> and <code>mtls-ca.pem</code>) to the server that will host HAProxy. One you have them copied to the server, use the following commands below to organize them.</p></div></div>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">mkdir</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-p</span><span class="token plain"> /etc/haproxy/certs</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">700</span><span class="token plain"> /etc/haproxy/certs</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">cp</span><span class="token plain"> relay.pem mtls-ca.pem /etc/haproxy/certs/</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">600</span><span class="token plain"> /etc/haproxy/certs/relay.pem</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">chmod</span><span class="token plain"> </span><span class="token number" style="color:#36acaa">644</span><span class="token plain"> /etc/haproxy/certs/mtls-ca.pem</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Configure HAProxy
Modify the file <code>/etc/haproxy/haproxy.cfg</code> and add the following contents at the bottom of the file, <strong>making sure to replace <code>&lt;WAZUH_MANAGER_IP&gt;</code> with the IP address of your Wazuh server</strong>:</p>
<div class="codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-text codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">frontend wazuh_agent_1514_in</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    bind 0.0.0.0:1514 ssl crt /etc/haproxy/certs/relay.pem ca-file /etc/haproxy/certs/mtls-ca.pem verify required</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    mode tcp</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    option tcplog</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    timeout client 2m</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    default_backend wazuh_manager_1514</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">backend wazuh_manager_1514</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    mode tcp</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    timeout server 2m</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    server wazuh_manager &lt;WAZUH_MANAGER_IP&gt;:1514 check</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
<li>
<p>Validate the configuration and reload HAProxy</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> haproxy </span><span class="token parameter variable" style="color:#36acaa">-c</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-f</span><span class="token plain"> /etc/haproxy/haproxy.cfg</span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> systemctl reload haproxy</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
</li>
</ol>
<p>If the results of the first command in the last step returned "Configuration file is valid" and you were able to successfully restart the haproxy service, you should now have a functioning HAProxy log relay!</p>
<p>This relay is configured to do the following:</p>
<ol>
<li>Handle mTLS authentication by validating the identities of clients wanting to connect to the Wazuh server</li>
<li>Attest to its own identity when clients attempt to validate it</li>
<li>Forward logs from successfully authenticated clients to the Wazuh server on port 1514</li>
</ol>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="step-3---configure-dns-and-networking">Step 3 - Configure DNS and Networking<a href="https://tailoredsec.com/blog/siem-log-relay-pt1/#step-3---configure-dns-and-networking" class="hash-link" aria-label="Direct link to Step 3 - Configure DNS and Networking" title="Direct link to Step 3 - Configure DNS and Networking">​</a></h2>
<p>This relay should be publicly accessible so you can receive logs from your monitored devices wherever they go. The steps to set that up will depend on where you're hosting this relay. If you're hosting it at home, for example, you may want to set up port forwarding at your firewall to forward traffic on TCP ports 1514 and 1515 to the log relay.</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>This next step is where it's really helpful to own your own domain. Once you have that, it makes it really easy to tell your devices where to send their logs. Keep in mind that you won't be able to do this last step the way I recommend if you don't have that.</p></div></div>
<p>Next, you will want to configure an entry with your DNS provider to give your log relay a URL so you can more easily tell your devices where to send their logs. For example, you could set "lr.yourdomain.com" to point to your log relay's public IP address, and you're good to go!</p>
<p>You're now ready to move onto <a href="https://tailoredsec.com/blog/siem-log-relay-pt2/">part 2 of this tutorial</a>, where you'll learn how to connect a client (also known as an "agent") to Wazuh through your log relay.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to encrypt your home folder and swap partition in Ubuntu]]></title>
            <link>https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/</link>
            <guid>https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/</guid>
            <pubDate>Thu, 26 Jun 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[Learn how to encrypt a home folder and swap partition in Ubuntu to improve your security posture.]]></description>
            <content:encoded><![CDATA[<p>Hey, Ubuntu users! If you haven't encrypted your hard drive, <strong>you should!</strong> An unencrypted hard drive makes it easy for someone to compromise your system when it's left unattended. With a few minutes of physical access to even a <strong>locked</strong> computer, an attacker (or prankster) could gain access to your sensitive files.</p>
<p>If you're <em>using your computer for work</em>, you should be <strong>even more careful</strong> to protect the information on your computer. In this tutorial, we'll cover how to encrypt your hard drive.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="full-disk-encryption--encrypted-home-folder--no-encryption">Full disk encryption &gt; encrypted home folder &gt; no encryption<a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#full-disk-encryption--encrypted-home-folder--no-encryption" class="hash-link" aria-label="Direct link to Full disk encryption > encrypted home folder > no encryption" title="Direct link to Full disk encryption > encrypted home folder > no encryption">​</a></h2>
<blockquote>
<p>Full disk encryption is better than just an encrypted home folder, but an encrypted home folder is better than nothing.</p>
</blockquote>
<p>The <strong>best way</strong> to protect your computer's files offline is to enable full disk encryption. This ensures that all (or MOST) of your operating system and files are encrypted. However, full disk encryption of Linux systems is best performed during the installation of the operating system. And if you're reading this, I'm guessing you probably already have Linux installed, and you didn't enable full-disk encryption when you set it up. That's okay! In this tutorial, we'll cover the next best thing: <strong>encrypting your home folder and swap partition.</strong></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="preparation">Preparation<a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#preparation" class="hash-link" aria-label="Direct link to Preparation" title="Direct link to Preparation">​</a></h2>
<div class="theme-admonition theme-admonition-warning admonition_xJq3 alert alert--warning"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg></span>warning</div><div class="admonitionContent_BuS1"><p>Before starting, you should back up your home folder. The tool I recommend you use will perform a backup automatically, but it's still a good idea to do your own backup just in case.</p></div></div>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>These instructions are written for Ubuntu users, but can be applied to other distributions as well.</p></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="installing-the-tools">Installing the tools<a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#installing-the-tools" class="hash-link" aria-label="Direct link to Installing the tools" title="Direct link to Installing the tools">​</a></h3>
<p>First, install <code>ecryptfs-utils</code> and <code>cryptsetup</code>.</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">apt</span><span class="token plain"> update </span><span class="token operator" style="color:#393A34">&amp;&amp;</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">apt</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">install</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-y</span><span class="token plain"> ecryptfs-utils cryptsetup</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="user-configuration">User configuration<a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#user-configuration" class="hash-link" aria-label="Direct link to User configuration" title="Direct link to User configuration">​</a></h3>
<p>The user whose home folder is to be encrypted needs to be logged out during this process, and the one performing the encryption needs to be a sudoer (administrative user). If you already have another sudoer account on your computer, you can <a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#migrating-to-an-encrypted-home-folder">skip to the next step</a>.</p>
<p>To set up a new sudo-enabled account on Ubuntu, open <code>Settings &gt; System &gt; Users</code>. Then click on <code>Unlock...</code> in the top right corner and type in your password.</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>Your system may look slightly different. I'm using <code>Ubuntu 24.04 LTS</code>, but the options should be relatively similar even if you're on a different version.</p></div></div>
<p><img decoding="async" loading="lazy" alt="A screenshot of the Users menu in Ubuntu settings" src="https://tailoredsec.com/assets/images/ubuntu-settings-users-menu-f5a7db6c3b631bda8e83658848b9b036.png" width="1688" height="857" class="img_ev3q"></p>
<p>Next, click <code>Add user</code> and create the user. <strong>Make sure to make the user an administrator!</strong></p>
<p><img decoding="async" loading="lazy" alt="A screenshot showing an example of the user configuration settings for a new admin user." src="https://tailoredsec.com/assets/images/ubuntu-new-admin-user-setup-314584a8fc516974ed9e22483011d7b8.png" width="1077" height="720" class="img_ev3q"></p>
<p>After creating the new user, log out of your user session.</p>
<p><img decoding="async" loading="lazy" alt="A screenshot showing how to log out of a user session" src="https://tailoredsec.com/assets/images/ubuntu-log-out-menu-2659d0cc1064406f753d9b5d91f3302a.png" width="553" height="618" class="img_ev3q"></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="migrating-to-an-encrypted-home-folder">Migrating to an encrypted home folder<a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#migrating-to-an-encrypted-home-folder" class="hash-link" aria-label="Direct link to Migrating to an encrypted home folder" title="Direct link to Migrating to an encrypted home folder">​</a></h2>
<p>At this step, you should:</p>
<ol>
<li>Be logged in as a sudo-enabled user</li>
<li><strong>Not</strong> be logged in as the user whose home directory is to be encrypted</li>
<li>Have a backup of the home directory to be encrypted</li>
</ol>
<p>If that's true for you, go ahead and open a terminal and run this command. (Replace &lt;user&gt; with the name of the user whose home directory you want to encrypt):</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> ecryptfs-migrate-home </span><span class="token parameter variable" style="color:#36acaa">-u</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">&lt;</span><span class="token plain">user</span><span class="token operator" style="color:#393A34">&gt;</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>You'll be prompted for a password. Type the password of the target user (not the user you're logged in as.)</p>
<p><img decoding="async" loading="lazy" alt="A screenshot of the messages a user sees when they run the migrate home command" src="https://tailoredsec.com/assets/images/ecryptfs-migrate-home-in-progress-4b3d80ebb480a97906bc4b61ecc66778.png" width="851" height="512" class="img_ev3q"></p>
<p>Once the command finishes, you'll see a few informational messages. Basically, they say:</p>
<ol>
<li>You need to <strong>immediately</strong> log into the user whose home folder was just encrypted, <strong>before the next reboot</strong>.</li>
<li>The script automatically backed up the user's home folder so it can be restored if something went wrong.</li>
<li>The script generated a mount passphrase for the home directory. Hopefully, you'll never need to use it, but you can use it to decrypt the home folder if it ever fails to decrypt at boot-up.</li>
<li>You should also encrypt your swap partition. (More on this below.)</li>
</ol>
<p><img decoding="async" loading="lazy" alt="A screenshot of the success message that appears after a successful migration of the home folder" src="https://tailoredsec.com/assets/images/home-folder-encryption-success-8f9e6898f618e71f86b6a0531487e0d5.png" width="832" height="504" class="img_ev3q"></p>
<p>Log back in as the user whose home folder was just encrypted, open a terminal, and run this command:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">ecryptfs-unwrap-passphrase</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>When it prompts you for <code>passphrase: </code>, type in your user's password. Then, you'll see a random string of characters. This is your mount passphrase, and you should save it somewhere safe like a password manager.</p>
<p><img decoding="async" loading="lazy" alt="A screenshot showing the results of running the command above" src="https://tailoredsec.com/assets/images/ecryptfs-unwarp-passphrase-91464c56a80c736d09cd04a426cf0b34.png" width="850" height="178" class="img_ev3q"></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>At some point, you'll probably see a window like this pop up on your screen. It's just a part of the script that's designed to prompt you to generate the passphrase you just retrieved, but in my experience, it takes a while to show up, and the message doesn't display properly. So you can just ignore it if you already ran the unwrap-passphrase command shown above.</p><p><img decoding="async" loading="lazy" alt="A screenshot of the popup that appears after logging back in" src="https://tailoredsec.com/assets/images/ecryptfs-migrate-home-popup-db6376b631e9f24a037b092d019e6d7f.png" width="593" height="480" class="img_ev3q"></p></div></div>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="encrypting-the-swap-partition">Encrypting the swap partition<a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#encrypting-the-swap-partition" class="hash-link" aria-label="Direct link to Encrypting the swap partition" title="Direct link to Encrypting the swap partition">​</a></h2>
<p>When you install Ubuntu with full disk encryption, your swap file is encrypted too. Lenovo has <a href="https://www.lenovo.com/gb/en/glossary/swap-file/" target="_blank" rel="noopener noreferrer">a pretty good explanation of swap files</a> and it includes this quote:</p>
<blockquote>
<p>"A swap file is a file on your computer's hard drive that is used as virtual memory. It is an extension of the computer's physical memory random-access memory (RAM) and acts as a temporary storage space for data that doesn't fit in the RAM."</p>
</blockquote>
<p>That means data from your home folder could get loaded into the swap file temporarily, which might leave it vulnerable to attack. So, encrypting your swap partition is a solid way of making sure your encrypted data <strong>stays encrypted</strong>.</p>
<p><strong>Before running this command, I recommend you alter the script slightly,</strong> and I'll show you why.</p>
<p>When you run the script to encrypt your swap partition as-is, you're likely to encounter a message stating:</p>
<blockquote>
<p>“swapon: cannot open /dev/mapper/cryptswap1: No such file or directory”</p>
</blockquote>
<p>This isn't necessarily a bad thing, and the script hasn't necessarily failed. There is a call within the script that runs <code>systemctl restart cryptsetup.target</code> after modifying <code>/etc/crypttab</code>. However, it does so without first calling <code>systemctl daemon-reload</code>. According to <a href="https://www.freedesktop.org/software/systemd/man/latest/systemd-cryptsetup-generator.html" target="_blank" rel="noopener noreferrer">freedesktop.org</a>:</p>
<blockquote>
<p>“systemd-cryptsetup-generator is a generator that translates /etc/crypttab into native systemd units early at boot and when configuration of the system manager is reloaded.”</p>
</blockquote>
<p>Therefore, the changes won't take full effect until either a reboot or manual re-run of the generators. So, you have two options:</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="option-1-recommended-modify-the-script">Option 1 (recommended): Modify the script:<a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#option-1-recommended-modify-the-script" class="hash-link" aria-label="Direct link to Option 1 (recommended): Modify the script:" title="Direct link to Option 1 (recommended): Modify the script:">​</a></h3>
<p>First, locate the script with this command:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">which</span><span class="token plain"> ecryptfs-setup-swap</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>Then, open it in your editor of choice. (for example: <code>sudo nano /usr/bin/ecryptfs-setup-swap</code>) and add <code>systemctl daemon-reload</code> above <code>systemctl restart cryptsetup.target</code> near the end of the script as shown in the screenshot below:</p>
<p><img decoding="async" loading="lazy" alt="A screenshot showing the altered script" src="https://tailoredsec.com/assets/images/ecryptfs-setup-swap-altered-1c150103b58c0d7ac79c50863535b6f9.png" width="512" height="357" class="img_ev3q"></p>
<p>Once you've modified and saved the script, you're ready to run it! Use this command to run it:</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> ecryptfs-setup-swap</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>If you followed these steps and modified the script as instructed, you should see: “INFO: Successfully encrypted swap!” To verify that it worked, see the section on <a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#verifying-successful-encryption">verifying successful encryption</a>.</p></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="option-2-restart-after-running-the-script">Option 2: Restart after running the script<a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#option-2-restart-after-running-the-script" class="hash-link" aria-label="Direct link to Option 2: Restart after running the script" title="Direct link to Option 2: Restart after running the script">​</a></h3>
<p>If you run the script without modifying it, you'll encounter a message stating:</p>
<blockquote>
<p>“swapon: cannot open /dev/mapper/cryptswap1: No such file or directory”</p>
</blockquote>
<p>After encountering that message, reboot your computer and your swap partition should be successfully encrypted. To verify that it worked, see the next section.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="verifying-successful-encryption">Verifying successful encryption<a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#verifying-successful-encryption" class="hash-link" aria-label="Direct link to Verifying successful encryption" title="Direct link to Verifying successful encryption">​</a></h2>
<p>To verify that your home folder and swap partition were successfully encrypted, run these two commands. (Again, replace &lt;username&gt; with your username)</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token plain">findmnt </span><span class="token parameter variable" style="color:#36acaa">--target</span><span class="token plain"> /home/</span><span class="token operator" style="color:#393A34">&lt;</span><span class="token plain">username</span><span class="token operator" style="color:#393A34">&gt;</span><span class="token plain"> </span><span class="token operator" style="color:#393A34">|</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">column</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-t</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token function" style="color:#d73a49">sudo</span><span class="token plain"> dmsetup table /dev/mapper/cryptswap1</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>NOTE</div><div class="admonitionContent_BuS1"><p>The first command allows you to verify whether your home folder has been encrypted. The second command allows you to verify whether your swap partition has been encrypted. In both cases, you want to see ‘crypt’ in the command output to verify successful encryption.</p></div></div>
<p><img decoding="async" loading="lazy" alt="A screenshot showing example outputs from the previous commands" src="https://tailoredsec.com/assets/images/encryption-verification-commands-e2e360cfdde92e3ca5a5af51d94cb8cc.png" width="1302" height="388" class="img_ev3q"></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="clean-up">Clean-up<a href="https://tailoredsec.com/blog/encrypt-ubuntu-home-folder/#clean-up" class="hash-link" aria-label="Direct link to Clean-up" title="Direct link to Clean-up">​</a></h2>
<p>If you've gotten through all those steps and were able to verify successful encryption, you're in great shape! In case you haven't already, you'll just want to make sure you can still read/write to your new home directory just to make sure it works. If that looks right, you can go ahead and delete the backup folder you created, as well as the one the script automatically created for you.</p>
<div class="language-bash codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-bash codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token function" style="color:#d73a49">rm</span><span class="token plain"> </span><span class="token parameter variable" style="color:#36acaa">-rf</span><span class="token plain"> /home/tailoredsec.HYSCiPFk</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Black Hat Thinking for White Hat Wins]]></title>
            <link>https://tailoredsec.com/blog/black-hat-thinking-for-white-hat-wins/</link>
            <guid>https://tailoredsec.com/blog/black-hat-thinking-for-white-hat-wins/</guid>
            <pubDate>Thu, 27 Mar 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[Discover how adopting an adversarial mindset and understanding hacker tactics can improve cybersecurity defenses. This post explores the importance of thinking like an attacker to proactively prevent vulnerabilities and strengthen security measures.]]></description>
            <content:encoded><![CDATA[<p>Does knowing how to commit crime make you better at detecting it? If you've heard stories of individuals like <a href="https://techcrunch.com/2016/08/13/how-frank-abagnale-turned-early-life-as-con-artist-into-a-40-year-security-consulting-career/" target="_blank" rel="noopener noreferrer">Frank Abagnale</a>, who committed massive fraud and stole millions of dollars and was later contracted as a consultant for the U.S. government, you may be inclined to say: "Yes!" But not everyone would agree...</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="why-are-some-criminals-good-detectives">Why are some criminals good detectives?<a href="https://tailoredsec.com/blog/black-hat-thinking-for-white-hat-wins/#why-are-some-criminals-good-detectives" class="hash-link" aria-label="Direct link to Why are some criminals good detectives?" title="Direct link to Why are some criminals good detectives?">​</a></h2>
<p>I read a LinkedIn post recently in which the poster argued pretty vehemently that anyone who thinks hacking is an important skill for cybersecurity is seriously mistaken. He drew an analogy to accounting and said that no accountant needs to be good at committing fraud in order to detect it. At first, I was intrigued by his argument and wanted to understand how it could make sense. But the longer I thought about it, the more I felt like he was making the wrong argument. I don't think it's really about knowing <strong>how to commit crime</strong>; It's about <strong>knowing how criminals think.</strong></p>
<p>I regularly attend penetration testing workshops taught by a Penetration Tester who works for AWS (Amazon Web Services). In these workshops, he explains pentesting concepts and walks through techniques for finding and remediating vulnerabilities in applications. Sometimes, he also shares stories of vulnerabilities he has found in real-life engagments and lessons they taught him.</p>
<p>In one recent workshop, he explained how he found a cross-site scripting vulnerability in an application and demonstrated how he could inject malicious code into the web page by using <code>&lt;script&gt;</code> HTML tags. When he reported this vulnerability to the application developers, their response was to write code that '<em>sanitized</em>' user input by erasing any instances of the tag <code>&lt;script&gt;</code> from user input, like so:</p>
<div class="language-php codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#393A34;--prism-background-color:#f6f8fa"><div class="codeBlockContent_biex"><pre tabindex="0" class="prism-code language-php codeBlock_bY9V thin-scrollbar" style="color:#393A34;background-color:#f6f8fa"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#393A34"><span class="token keyword" style="color:#00009f">function</span><span class="token plain"> </span><span class="token function-definition function" style="color:#d73a49">sanitize</span><span class="token punctuation" style="color:#393A34">(</span><span class="token variable" style="color:#36acaa">$input</span><span class="token punctuation" style="color:#393A34">)</span><span class="token plain"> </span><span class="token punctuation" style="color:#393A34">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain">    </span><span class="token keyword" style="color:#00009f">return</span><span class="token plain"> </span><span class="token function" style="color:#d73a49">str_replace</span><span class="token punctuation" style="color:#393A34">(</span><span class="token punctuation" style="color:#393A34">[</span><span class="token string single-quoted-string" style="color:#e3116c">'&lt;script&gt;'</span><span class="token punctuation" style="color:#393A34">]</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token string single-quoted-string" style="color:#e3116c">''</span><span class="token punctuation" style="color:#393A34">,</span><span class="token plain"> </span><span class="token variable" style="color:#36acaa">$input</span><span class="token punctuation" style="color:#393A34">)</span><span class="token punctuation" style="color:#393A34">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#393A34"><span class="token plain"></span><span class="token punctuation" style="color:#393A34">}</span><br></span></code></pre><div class="buttonGroup__atx"><button type="button" aria-label="Copy code to clipboard" title="Copy" class="clean-btn"><span class="copyButtonIcons_eSgA" aria-hidden="true"><svg viewBox="0 0 24 24" class="copyButtonIcon_y97N"><path fill="currentColor" d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z"></path></svg><svg viewBox="0 0 24 24" class="copyButtonSuccessIcon_LjdS"><path fill="currentColor" d="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"></path></svg></span></button></div></div></div>
<p>The developers failed to consider the myriad of other methods a hacker might use to inject malicious code to their website, such as enclosing the malicious code in another type of HTML tag, or using <em>any</em> of the following variations on the <code>&lt;script&gt;</code> tag:</p>
<ul>
<li><code>&lt;SCRIPT&gt;</code></li>
<li><code>&lt;ScRiPt&gt;</code></li>
<li><code>&lt;scr&lt;script&gt;ipt&gt;</code></li>
</ul>
<p>What this example demonstrates is not that the developers didn't know HOW to hack. I'm sure any one of them would have been capable of writing a malicious script and injecting it into the web page... But it's clear that none of them were <em>thinking like hackers</em>. They didn't <strong>consider the mindset of an attacker</strong> who, upon meeting an obstacle, immediately looks for creative ways to evade the obstacle.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="detecting-crime-vs-preventing-it">Detecting crime vs preventing it<a href="https://tailoredsec.com/blog/black-hat-thinking-for-white-hat-wins/#detecting-crime-vs-preventing-it" class="hash-link" aria-label="Direct link to Detecting crime vs preventing it" title="Direct link to Detecting crime vs preventing it">​</a></h2>
<p>To refer to the LinkedIn post I mentioned at the beginning, I'll give the author some credit... He may be onto something when he says '<em>you don't need to know how to commit crime to detect it.</em>' But then again, cybersecurity isn't just about <em>detecting</em> cybercrime, is it?... It's also about <strong>preventing</strong> cybercrime!</p>
<p>After all, <strong>what good is it to 'detect' theft if you can't prevent it from occurring in the first place?</strong> If you can't do that, the theft will likely continue. You can't stop someone from breaking a rule until you know <em>how</em> they're breaking it. For example, maybe someone has been stealing snacks from your vending machine, and you want to stop it. You might assume that they're shaking or tilting the machine - and decide to anchor the machine to the ground. But if all they're doing is attaching a string to their money so they can pull it back out after purchasing a snack, your 'theft detection' hasn't done you any good.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="an-adversarial-mindset-informs--improves-defensive-tactics">An adversarial mindset informs &amp; improves defensive tactics<a href="https://tailoredsec.com/blog/black-hat-thinking-for-white-hat-wins/#an-adversarial-mindset-informs--improves-defensive-tactics" class="hash-link" aria-label="Direct link to An adversarial mindset informs &amp; improves defensive tactics" title="Direct link to An adversarial mindset informs &amp; improves defensive tactics">​</a></h2>
<p>Knowing how to hack may not make you significantly better at 'detecting' cybercrime... but knowing <strong>how to <em>think</em> like a hacker</strong> can certainly make you a better defender! Employing an <strong>adversarial mindset</strong> (thinking like an attacker) helps you consider tactics, techniques, and procedures an attacker might use against you. <a href="https://jaysonestreet.com/" target="_blank" rel="noopener noreferrer">Jayson E. Street</a> once shared the following:</p>
<blockquote>
<p><em>"Every place that I tried to secure. I first assessed how I would steal from it."</em></p>
</blockquote>
<p>When defenders can learn how to think like attackers, they'll be much more prepared to proactively prevent intrusions and reduce vulnerabilities. And I can't think of a better way to learn how a hacker thinks than learning how to hack.</p>
<p>So <strong>yes, hacking skills are important for cybersecurity</strong>. And not every security professional needs to be good at hacking, but we definitely need hackers to help us stay ahead in the perpetual game of <em>cat and mouse</em> that keeps us all on our toes every day.</p>]]></content:encoded>
            <category>Hacking</category>
        </item>
        <item>
            <title><![CDATA[When is hacking 'ethical' - and when is it not?]]></title>
            <link>https://tailoredsec.com/blog/what-makes-hacking-ethical/</link>
            <guid>https://tailoredsec.com/blog/what-makes-hacking-ethical/</guid>
            <pubDate>Sat, 22 Mar 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[Join me as I explore the nuanced world of ethical hacking, the difference between white-hat and black-hat hackers, and the subjective nature of ethics versus morals. Learn why intention and social perception play a critical role in determining whether hacking is considered ethical.]]></description>
            <content:encoded><![CDATA[<p>Almost anyone who listens to the news or watches movies these days has heard the term <strong>hacking</strong>. For many, it evokes images of hoodie-clad criminals with fingerless gloves - furiously scanning through dark screens of green text in search of hidden secrets. But what about the hackers who <strong>aren't criminals</strong> and don't wear hoodies?</p>
<p>You may have heard of so-called <em><strong>ethical</strong> hackers</em>... But what makes them different? And how clear is the line between them and 'the bad guys'?</p>
<p><em>Hint:</em> It's <strong>not as clear</strong> as you might think 😉...</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="isnt-hacking-stealing-aka-bad">Isn't hacking stealing? a.k.a. BAD??<a href="https://tailoredsec.com/blog/what-makes-hacking-ethical/#isnt-hacking-stealing-aka-bad" class="hash-link" aria-label="Direct link to Isn't hacking stealing? a.k.a. BAD??" title="Direct link to Isn't hacking stealing? a.k.a. BAD??">​</a></h2>
<p>That is a fair question that highlights a need to define '<em>hacking</em>'. While many equate hacking with <em>stealing</em>, I prefer another <strong>common definition for hacking</strong>:</p>
<blockquote>
<p><strong>Manipulating technology to make it behave in a way that differs from its original design.</strong></p>
</blockquote>
<p>I believe this is <strong>a more helpful definition</strong> than 'being bad and breaking into computers and stealing stuff,' which seems to be the most commonly implied definition by modern media outlets.</p>
<p>This is a more helpful definition because it still effectively conveys a clear meaning, but it also <strong>promotes a broader understanding</strong> of what it means to hack. It also removes some of the unnecessary <em>stigma</em> around the term.</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>Side Note</div><div class="admonitionContent_BuS1"><p>I had a coworker who once demonstrated a particularly clever manipulation of technology that made his life easier and helped him achieve his goals. I was fascinated and proud of him. However, because of the stigma that surrounds hacking, he very quickly made sure to state: "But I promise I'm definitely NOT a hacker! I don't know anything about hacking..."</p><p>I wish he had understood hacking the way I do so that he could wear the title of 'hacker' proudly. Hackers have the ability to make the world a better place with their unique skills, and I would love to see that represented more often in the way people talk about hackers.</p></div></div>
<p><strong>To reiterate, no. Hacking is not <em>(necessarily)</em> stealing.</strong></p>
<p>Of course, hacking <em>can</em> involve stealing... I think it's pretty clear that <em>manipulating a computer to reveal sensitive information without proper authorization</em> falls under the larger definition of hacking that I mentioned earlier. So is that ever okay, and if so, when?</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="ethical-vs-unethical">'Ethical' vs 'Unethical'<a href="https://tailoredsec.com/blog/what-makes-hacking-ethical/#ethical-vs-unethical" class="hash-link" aria-label="Direct link to 'Ethical' vs 'Unethical'" title="Direct link to 'Ethical' vs 'Unethical'">​</a></h2>
<p>While most of the world will probably always see hackers as nasty bad guys that break into computer systems, we in the security community have a more nuanced perception of <strong>hackers</strong>, often classifying them as <em>'white-hat'</em> or <em>'black-hat'</em> based on whether they have permission to do their hacking.</p>
<p>We'll often call someone a 'white-hat hacker' if we deem their actions to be <strong>ethical</strong> (watch out for that word... we'll talk about it more), but even with our nuanced perceptions, it's often difficult to label someone's actions as purely 'ethical' or 'unethical'.</p>
<p><em>But what is <strong>ethical</strong></em>?</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="the-dilemma">The dilemma<a href="https://tailoredsec.com/blog/what-makes-hacking-ethical/#the-dilemma" class="hash-link" aria-label="Direct link to The dilemma" title="Direct link to The dilemma">​</a></h3>
<p>One doesn't have to spend much time researching the topic of '<strong>ethics</strong>' to find out that it's quite subjective. One of the most generic definitions you'll find for '<em>ethical</em>' behavior is:</p>
<blockquote>
<p><em>"conforming to generally accepted standards of conduct"</em></p>
</blockquote>
<p>So it sounds like <strong>ethical behavior is behavior that conforms to generally accepted standards of conduct.</strong> But doesn't that change wherever you go? Different countries have different laws and cultures, and even different communities in the same region have unique customs. For example, here in the United States, it's perfectly acceptable in many areas to carry a gun in public places. However, there are many countries throughout the world - and even some places in the U.S. - where such behavior is strictly prohibited.</p>
<p><strong>Thus, it seems that <em>ethicality</em> depends a lot on external factors</strong> - and those factors vary greatly between different places and contexts. <strong>The dilemma is: it's hard to know what's ethical and unethical depending on where you are.</strong> (BUT, that doesn't mean it's not <em>important</em>, and I'll talk about why near the end of this post.)</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="ethics-vs-morals">Ethics vs Morals<a href="https://tailoredsec.com/blog/what-makes-hacking-ethical/#ethics-vs-morals" class="hash-link" aria-label="Direct link to Ethics vs Morals" title="Direct link to Ethics vs Morals">​</a></h2>
<p>What would you say is the <strong>difference between ethics and morals?</strong> That's a question that had me thinking hard... and it seems like it's had that effect on others as well. Many dictionaries list <em>ethical</em> and <em>moral</em> as synonyms! But that's really interesting to me, because one such dictionary defines '<em>moral</em>' as:</p>
<blockquote>
<p><strong>conforming to a standard of <em>right</em> behavior</strong> | (as opposed to <strong>wrong</strong> behavior)</p>
</blockquote>
<p>But who decides what's <strong>right and wrong</strong>? As a religious person, I personally believe God is essentially the one that dictates that, so it's <strong>certainly</strong> not up to '<em>the masses</em>' to determine what's right and wrong. Even if everyone in the world <em>thinks</em> something is right, that doesn't make it right.</p>
<p><strong>Even if you don't believe in God, I think you'll agree that <em>other people don't get to decide what's right and wrong for you.</em></strong> And if you don't believe God decides what's right and wrong, I'm willing to bet you probably believe <strong>you</strong> are the one who decides what's right and wrong. (Technically, you might even say that's what I'm doing, because I make decisions based on what <strong>I believe</strong> God would want me to do.)</p>
<p>Therefore: if <strong>ethics</strong> pertain to what's socially acceptable/unacceptable, and <strong>morals</strong> pertain to what's right/wrong, then <strong>I don't think ethics and morals can be the same thing</strong>. Ethics and morals may <em>align</em> sometimes, but they're not the same thing. You may disagree, and that's fine! But that's not really the point I'm trying to make here. I'm setting the background for something much more important. For the purpose of this blog, <strong>I will stipulate that:</strong></p>
<ul>
<li><strong>Ethics</strong> are interpreted by <strong>other people.</strong></li>
<li><strong>Morals</strong> are interpreted by <strong>you</strong> - and <em>only</em> you.</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="the-importance-of-intention">The importance of intention<a href="https://tailoredsec.com/blog/what-makes-hacking-ethical/#the-importance-of-intention" class="hash-link" aria-label="Direct link to The importance of intention" title="Direct link to The importance of intention">​</a></h3>
<p>I'm sure you've heard phrases like these before:</p>
<ul>
<li><em>"It was not my intention to..."</em></li>
<li><em>"I didn't mean it that way."</em></li>
</ul>
<p>These phrases are both referring to the concept of '<em>intention</em>'. Intention refers to the purpose or goal someone has in mind when performing an action. When making a decision between <em>right and wrong</em>, intention can influence interpretation greatly. This is why the concept of 'white lies' exists. A white lie is a lie that is told with <strong>righteous intention.</strong> While most people generally consider lying to be <em>wrong</em>, they recognize that the <em>intention</em> behind a lie bears significant weight when determining whether lying is the right or wrong thing to do.</p>
<p><strong>With ethics, however,</strong> intention doesn't seem to hold quite as much weight. I'll admit that intention seems to have <em>some significance</em> when it comes to ethics, but not as much as morals. Why? I think it's partially because it's much easier for <strong>one person</strong> to decide whether something is acceptable or unacceptable than it is for <strong>multiple people</strong> to agree on such a decision.</p>
<p><strong>Why does this matter?:</strong> I think this is important to understand because - while I believe you should make ALL decisions based on what you think is right (morally correct) - you would be foolish to ignore what other people might interpret as ethical (socially acceptable).</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="why-do-ethics-matter">Why do ethics matter?<a href="https://tailoredsec.com/blog/what-makes-hacking-ethical/#why-do-ethics-matter" class="hash-link" aria-label="Direct link to Why do ethics matter?" title="Direct link to Why do ethics matter?">​</a></h2>
<p>Imagine that you're at a dinner party with a family that has invited you to their home. (And let's assume - for the purpose of this exercise - that you <em>want</em> to be there.) You, as their guest, are expected to behave a certain way. If you do not follow their rules and customs, you risk offending them. Offend them badly enough, and you may just get kicked out of the house.</p>
<p>The fact that what you did offended the family does not make it wrong. But their interpretation of your actions as unacceptable still affected you negatively.</p>
<p>That leads me to the <strong>first reason that ethics matter: Other people will probably attempt to punish you if they think your actions are unacceptable.</strong> You don't get to decide what other people think is right and wrong, and you shouldn't expect them to care about what <em>you</em> think is right and wrong.</p>
<p><strong>Reason number 2 that ethics matter: You get to help decide what's ethical in your community.</strong> I won't focus much on this one because it doesn't pertain much to my argument, but I'll say this... If ethics is something interpreted by the people around you, you play a role in deciding that as a group. It's in your best interest to contribute to the development of your community's ethical standards such that they agree with your own.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="are-you-an-ethical-hacker">Are you an 'ethical' hacker?<a href="https://tailoredsec.com/blog/what-makes-hacking-ethical/#are-you-an-ethical-hacker" class="hash-link" aria-label="Direct link to Are you an 'ethical' hacker?" title="Direct link to Are you an 'ethical' hacker?">​</a></h2>
<p>I've already mentioned how security professionals have terms like 'white hat hacker' and 'black hat hacker.' A white hat hacker is someone who hacks <em>only with permission</em> from the person/entity they're hacking, and generally has good intentions. A black hat hacker hacks without permission and generally has malicious intentions.</p>
<p>But what about the in-between? What about people who hack <strong>without permission</strong> but with <em><strong>good intentions</strong></em>? (or at least benign intentions...) Most would consider them 'grey hat hackers'. Are they ethical or not?</p>
<p>Well, if you agree that <em>ethics</em> are determined by other people, then you can <strong>only</strong> consider yourself an ethical hacker if your hacking is acceptable to others. That may differ from your beliefs about what it means to be an 'ethical hacker.' From my conversations with other hackers, it seems to me that most of them consider themselves 'ethical' hackers because they never hack with malicious intention, <em>even if</em> they sometimes hack without permission. However, I want to warn against this kind of thinking. Many hackers who think this way have gotten themselves arrested over the years, and it's caused them a world of hurt.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="stories-of-grey-hat-hackers-who-got-in-trouble">Stories of grey-hat hackers who got in trouble<a href="https://tailoredsec.com/blog/what-makes-hacking-ethical/#stories-of-grey-hat-hackers-who-got-in-trouble" class="hash-link" aria-label="Direct link to Stories of grey-hat hackers who got in trouble" title="Direct link to Stories of grey-hat hackers who got in trouble">​</a></h3>
<p>Here are some cautionary tales just to drive the point home.</p>
<ul>
<li><a href="https://hacker.albertohill.com/" target="_blank" rel="noopener noreferrer">Alberto Daniel Hill</a> from Montevideo, Uruguay. He found a weak login page on a medical provider's website and hacked it practically by accident. He notified the medical provider in an effort to help them fix it, but he was later arrested and spent 9 months in prison. Listen to his story <a href="https://darknetdiaries.com/transcript/25/" target="_blank" rel="noopener noreferrer">in this podcast</a>.</li>
<li>Martin Gottesfeld, from Andover, Massachusetts. He hacked a hospital (It's a little hard calling him a grey-hat hacker because that's pretty messed up. But he swears he thought he was doing the right thing.) in protest of the hospital's treatment of a 15-year-old patient. Listen to the story <a href="https://darknetdiaries.com/episode/14/" target="_blank" rel="noopener noreferrer">in this podcast</a>.</li>
</ul>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion">Conclusion<a href="https://tailoredsec.com/blog/what-makes-hacking-ethical/#conclusion" class="hash-link" aria-label="Direct link to Conclusion" title="Direct link to Conclusion">​</a></h2>
<p><strong>Are you an ethical hacker?... You don't get to decide.</strong></p>
<p>Only other people can decide that for you.</p>
<p>Since only other people can decide whether you're an ethical hacker, I would say grey-hat hackers should be <strong>very</strong> careful considering themselves 'ethical hackers.'</p>
<p>If you're interested in hacking, that's awesome! I think it's an incredibly rewarding hobby, and you should totally give it a shot. But if you want my advice... You'll do well to <strong>keep your hacking ethical</strong>.</p>
<hr>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="resources-for-learning-ethical-hacking">Resources for learning ethical hacking<a href="https://tailoredsec.com/blog/what-makes-hacking-ethical/#resources-for-learning-ethical-hacking" class="hash-link" aria-label="Direct link to Resources for learning ethical hacking" title="Direct link to Resources for learning ethical hacking">​</a></h2>
<p>Check out these awesome resources that will help you learn hacking safely and ethically!</p>
<ul>
<li><a href="https://tryhackme.com/" target="_blank" rel="noopener noreferrer">TryHackMe</a></li>
<li><a href="https://www.hackthebox.com/" target="_blank" rel="noopener noreferrer">HackTheBox</a></li>
</ul>
<p>There are MANY more, but these are the two that I've used for the most part and I have thoroughly enjoyed them.</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>Further Reading</div><div class="admonitionContent_BuS1"><p>If you liked this post, you'll probably like my other post about <strong><a href="https://tailoredsec.com/blog/black-hat-thinking-for-white-hat-wins/">why ethical hacking skills are important for cybersecurity</a>.</strong></p></div></div>]]></content:encoded>
            <category>Hacking</category>
        </item>
        <item>
            <title><![CDATA[Using Abstraction to Get Better Results From AI]]></title>
            <link>https://tailoredsec.com/blog/using-abstraction-to-get-better-results-from-ai/</link>
            <guid>https://tailoredsec.com/blog/using-abstraction-to-get-better-results-from-ai/</guid>
            <pubDate>Wed, 27 Nov 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[How I use abstraction to improve security, accuracy, and productivity when working with Generative AI (GenAI). This post shares practical examples and a step-by-step process for leveraging patterns and generalized data to achieve better results.]]></description>
            <content:encoded><![CDATA[<p>The internet is built on <strong>layers upon layers</strong> of abstraction. This makes it possible for an immense variety of people and machines to communicate with one another. I want to share some ways I've used abstraction to help me <strong>get better results from artifical intelligence (AI)</strong>.</p>
<!-- -->
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="priorities">Priorities<a href="https://tailoredsec.com/blog/using-abstraction-to-get-better-results-from-ai/#priorities" class="hash-link" aria-label="Direct link to Priorities" title="Direct link to Priorities">​</a></h2>
<p>With the recent surge in the capabilities and prevalence of </p><div class="tooltipContainer_spgG"><span class="tooltipText_X7LF">GenAI</span></div> in the last two years, I've been looking for ways it can make me more productive.<p></p>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary>GenAI vs Generalized AI</summary><div><div class="collapsibleContent_i85q"><p><strong>'GenAI' means Generative AI</strong>, which is a type of artificial intelligence (AI) that can create things like text, code, videos, etc. It is <em>not to be confused with</em> <strong>Generalized Artificial Intelligence (AGI)</strong>, which refers to the theoretical concept of AI that demonstrates human-like intelligence and capabilities across multiple fields or domains. To learn more about AGI, <a href="https://aws.amazon.com/what-is/artificial-general-intelligence/#:~:text=and%20AGI%20efforts%3F-,What%20is%20artificial%20general%20intelligence%3F,necessarily%20trained%20or%20developed%20for" target="_blank" rel="noopener noreferrer">read about it here</a>!</p></div></div></details>
<p>Whenever I use GenAI to create something, I have <strong>two main priorities</strong>:</p>
<ol>
<li>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="security">Security<a href="https://tailoredsec.com/blog/using-abstraction-to-get-better-results-from-ai/#security" class="hash-link" aria-label="Direct link to Security" title="Direct link to Security">​</a></h3>
<ul>
<li>You should treat AI like a stranger, and you <a href="https://agileblue.com/5-things-that-you-should-never-share-with-chat-gpt/" target="_blank" rel="noopener noreferrer">shouldn't share information with it</a> that you wouldn't share with a stranger.</li>
</ul>
</li>
<li>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="accuracy">Accuracy<a href="https://tailoredsec.com/blog/using-abstraction-to-get-better-results-from-ai/#accuracy" class="hash-link" aria-label="Direct link to Accuracy" title="Direct link to Accuracy">​</a></h3>
<ul>
<li>AI has a remarkable ability to produce inaccurate content with astounding confidence. Carefully-crafted prompts can help you increase your chances of getting good results.</li>
</ul>
</li>
</ol>
<p>Because those two things are so important to me, I <em>avoid sharing overly-specific information</em> in my interactions with AI. This originally came from my desire to preserve <em>privacy and security</em>, but I found that it yielded <strong>unexpected improvements</strong> in the area of accuracy as well.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="the-power-of-abstraction">The power of abstraction<a href="https://tailoredsec.com/blog/using-abstraction-to-get-better-results-from-ai/#the-power-of-abstraction" class="hash-link" aria-label="Direct link to The power of abstraction" title="Direct link to The power of abstraction">​</a></h2>
<p>I recently watched a video interview in which computer scientist <strong>David J. Malan</strong> explained how the internet is built on layers upon layers of <em>patterns and ideas</em>, which he calls abstraction.</p>
<p>In the video, he talks about how everything we see on the internet comes from from data like 1s and 0s. That data follows certain patterns that allow it to become something much more rich and meaningful. Thanks to that technology, millions of different kinds of people and machines can communicate with one another in a way they can all understand. I highly suggest watching the 1-minute clip from that video below.</p>
<details class="details_lb9f alert alert--info details_b_Ee" data-collapsed="true"><summary> Watch the video</summary><div><div class="collapsibleContent_i85q"><p>The clip I talked about — 'How do zeros and ones turn into the internet?' — lasts just over a minute.</p><iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/QUNrBEhvXWQ?si=xMeyRl5YrZb9GOQI&amp;start=300&amp;end=378" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" style="display:block;margin:0 auto"></iframe></div></div></details>
<p>By taking a similar approach to communicate with AI, using <strong>patterns instead of specific data</strong>, I have been able to achieve greater security <em>and</em> accuracy.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="examples">Examples<a href="https://tailoredsec.com/blog/using-abstraction-to-get-better-results-from-ai/#examples" class="hash-link" aria-label="Direct link to Examples" title="Direct link to Examples">​</a></h2>
<p>Here are two examples of how I've recently used this strategy to achieve desirable results with AI.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="1-manipulating-a-graph">1) Manipulating a graph<a href="https://tailoredsec.com/blog/using-abstraction-to-get-better-results-from-ai/#1-manipulating-a-graph" class="hash-link" aria-label="Direct link to 1) Manipulating a graph" title="Direct link to 1) Manipulating a graph">​</a></h3>
<p>I recently had to alter the structure of a large graph with tons of nodes with relationships between them. Essentially, my task was to take something that looked like this:</p>
<p><img decoding="async" loading="lazy" alt="A picture of a graph with the old structure" src="https://tailoredsec.com/assets/images/abstraction-old-graph-57dea970af8b7a5933860095177e5a5a.png" width="1223" height="799" class="img_ev3q"></p>
<p>and turn it into this:</p>
<p><img decoding="async" loading="lazy" alt="A picture of a graph with the new structure" src="https://tailoredsec.com/assets/images/abstraction-new-graph-0b662ba5b08841362281a58c04d98917.png" width="1438" height="540" class="img_ev3q"></p>
<p>It seems like it wouldn't take too long, doesn't it? Well, the tricky part is the graph I had to alter looked more like this:</p>
<p><img decoding="async" loading="lazy" alt="A picture of an insanely large graph" src="https://tailoredsec.com/assets/images/abstraction-huge-graph-8a1487e510fb2f0754d2fb6e62b090ab.png" width="1430" height="765" class="img_ev3q"></p>
<p>As I'm sure you can imagine, I knew that it would be impossible for me to do that task unaided. I would surely end up taking tons of time and committing countless errors along the way. So of course, I thought <strong>"Hey, I'll get AI to help!"</strong> But I couldn't just share the data with ChatGPT. First of all, it was way too much data to share with it directly, and second, the data was sensitive, so I had to protect the actual data in the graph.</p>
<p>To solve these problems, I asked AI to write a Python script to edit the data for me! I'm learning Python, but my skills aren't to the point where I could do this myself, and I knew that AI would be able to write and iterate upon the script much more quickly than I could. Here's what the process looked like:</p>
<ol>
<li>To start, I came up with an <em>abstract example</em> of the type of graph I wanted the script to alter (like the simplified examples I showed above). These simplified examples had all the sensitive information stripped out, with just enough structure to help the AI know what I needed it to do.</li>
<li>I crafted a descriptive prompt explaining the type of data I was working with, included the example data, and carefully explained exactly the types of changes I wanted it to make, and the ones I wanted it <strong>not</strong> to make. In this explanation, I made sure to use patterns wherever possible to keep my instructions generalized.</li>
<li>I tested the script and gave feedback, describing the results enough to help the AI understand what went wrong, and kept what worked.</li>
</ol>
<blockquote>
<p>After a little back-and-forth with the AI as I tested the script, I was able to achieve <strong>exactly what I needed</strong> with 100% accuracy, in a fraction of the time it would have taken me to do it myself, and <em>without compromising the confidentiality</em> of the graph data.</p>
</blockquote>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2-organizing-an-email-list">2) Organizing an email list<a href="https://tailoredsec.com/blog/using-abstraction-to-get-better-results-from-ai/#2-organizing-an-email-list" class="hash-link" aria-label="Direct link to 2) Organizing an email list" title="Direct link to 2) Organizing an email list">​</a></h3>
<p>In another project recently, I had to take an unorganized list of 1800 email addresses and group them by domain. The list contained individual email addresses — in no particular order — of people that worked at different organizations. I needed to figure out which email addresses belonged to which organizations, and group them together by organization.</p>
<p>So, once again, I went to AI for help. And instead of giving it the raw data, I asked it for a Python script to help me organize the data. Here's how I did it:</p>
<ol>
<li><strong>I gave the AI an example of the data I had with a general explanation.</strong>
<ul>
<li>"I have a spreadsheet with 1800 email addresses. They're all in a column titled <code>email</code>. . ."</li>
</ul>
</li>
<li><strong>I included a thorough explanation of what I wanted with another example of the outcome data.</strong>
<ul>
<li>". . . I want you to write a Python script to organize the emails by domain. The output file should have 1 column titled <code>domain</code> and another column called <code>emails</code> with the email addresses belonging to that domain separated by semicolons. For example: <code>email1@test.com; email2@test.com; email3@test.com</code></li>
</ul>
</li>
<li><strong>And then I went back and forth with the AI to give it feedback.</strong>
<ul>
<li>In this particular example, I actually got exactly what I wanted on the first try! The iteration came later when my requirements changed, but I was able to simply follow the other steps again to revise my results to fit my needs.</li>
</ul>
</li>
</ol>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="the-process">The Process<a href="https://tailoredsec.com/blog/using-abstraction-to-get-better-results-from-ai/#the-process" class="hash-link" aria-label="Direct link to The Process" title="Direct link to The Process">​</a></h2>
<p>This process I've developed has become one that I regularly follow in my work with AI. Here's how I would break it down:</p>
<ol>
<li><strong>Create an abstract model of your desired outcome.</strong>
<ul>
<li>Give the AI somewhere to start. This helps it get the structure and format right, and helps you protect the specific details of your important data.</li>
<li>If you're <em>manipulating existing data</em>, give it examples of the before <em>and</em> after (again, like you saw with my example above.)</li>
</ul>
</li>
<li><strong>Craft a <em>descriptive prompt</em> that uses patterns to outline requirements.</strong>
<ul>
<li>It's a good idea to give lots of guidance. The more guidance you give, the more reliable your results will be. Luckily, you can edit your prompt and try again if the AI doesn't give you the results you want the first time.</li>
</ul>
</li>
<li><strong>Give feedback and work with the AI to revise your strategy</strong>
<ul>
<li>AI probably won't get it right on the first try. Keep working at it! Tell it what went wrong and what you want it to change. As you make small tweaks, you'll see improved results very quickly.</li>
</ul>
</li>
</ol>
<p>I encourage you to try out that process for yourself! I'm confident that it'll help you increase your productivity, security, and accuracy in your use of GenAI. Lastly, I'll include some bonus tips below that help me when I work with AI.</p>
<div class="theme-admonition theme-admonition-tip admonition_xJq3 alert alert--success"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 12 16"><path fill-rule="evenodd" d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>Bonus Tips</div><div class="admonitionContent_BuS1"><p><strong>Ask for a script you can run on your computer if you're processing large amounts of data.</strong></p><blockquote>
<p>Asking AI to give you a script helps when you're processing large amounts of data, because I've found that AI will mess up and miss details when you ask it to process raw data on its own.</p>
</blockquote><p><strong>Tell it to write debugging statements into the script.</strong></p><blockquote>
<p>Most of the time, AI won't get the script right on the first try. Get it to write debugging statements into the script, and then if you encounter errors, send those errors right back to the AI for it to work on.</p>
</blockquote><p><strong>Save versions of your work as you go.</strong></p><blockquote>
<p>Sometimes when you ask AI to change something, and then change another thing later, it might get rid of previous changes it made based on your feedback. It can help to save a new copy of whatever it gives you every time it makes a change so you can go back to it if the AI messes up. You can also help it by sending the current version of the script again every time you ask for a new change. That way it'll start from where you're at and it's less likely to remove things it added previously.</p>
</blockquote></div></div>]]></content:encoded>
            <category>AI</category>
            <category>Productivity</category>
        </item>
    </channel>
</rss>