summaryrefslogtreecommitdiff
path: root/gemfeed/2022-10-30-installing-dtail-on-openbsd.html
diff options
context:
space:
mode:
Diffstat (limited to 'gemfeed/2022-10-30-installing-dtail-on-openbsd.html')
-rw-r--r--gemfeed/2022-10-30-installing-dtail-on-openbsd.html154
1 files changed, 104 insertions, 50 deletions
diff --git a/gemfeed/2022-10-30-installing-dtail-on-openbsd.html b/gemfeed/2022-10-30-installing-dtail-on-openbsd.html
index fcf023d2..dcadab54 100644
--- a/gemfeed/2022-10-30-installing-dtail-on-openbsd.html
+++ b/gemfeed/2022-10-30-installing-dtail-on-openbsd.html
@@ -9,7 +9,8 @@
</head>
<body>
<h1>Installing DTail on OpenBSD</h1>
-<p class="quote"><i>Published at 2022-10-30T11:03:19+02:00</i></p>
+<span class="quote"><i>Published at 2022-10-30T11:03:19+02:00</i></span><br />
+<br />
<pre>
,_---~~~~~----._
_,,_,*^____ _____``*g*\"*,
@@ -45,52 +46,73 @@
`|/-. \ / \ /,---`\ kat
/ `._____V_____V'
' '
-</pre><br />
-<p>This will be a quick blog post, as I am busy with my personal life now. I have relocated to a different country and am still busy arranging things. So bear with me :-)</p>
-<p> In this post, I want to give a quick overview (or how-to) about installing DTail on OpenBSD, as the official documentation only covers Red Hat and Fedora Linux! And this blog post will also be used as my reference!</p>
+</pre>
+<br />
+This will be a quick blog post, as I am busy with my personal life now. I have relocated to a different country and am still busy arranging things. So bear with me :-)<br />
+<br />
+ In this post, I want to give a quick overview (or how-to) about installing DTail on OpenBSD, as the official documentation only covers Red Hat and Fedora Linux! And this blog post will also be used as my reference!<br />
+<br />
<a class="textlink" href="https://dtail.dev">https://dtail.dev</a><br />
-<p>I am using Rexify for my OpenBSD automation. Check out the following article covering my Rex setup in a little bit more detail:</p>
+<br />
+I am using Rexify for my OpenBSD automation. Check out the following article covering my Rex setup in a little bit more detail:<br />
+<br />
<a class="textlink" href="./2022-07-30-lets-encrypt-with-openbsd-and-rex.html">Let's Encrypt with OpenBSD and Rex</a><br />
-<p>I will also mention some relevant <span class="inlinecode">Rexfile</span> snippets in this post!</p>
+<br />
+I will also mention some relevant <span class="inlinecode">Rexfile</span> snippets in this post!<br />
+<br />
<h2>Compile it</h2>
-<p>First of all, DTail needs to be downloaded and compiled. For that, <span class="inlinecode">git</span>, <span class="inlinecode">go</span>, and <span class="inlinecode">gmake</span> are required:</p>
+First of all, DTail needs to be downloaded and compiled. For that, <span class="inlinecode">git</span>, <span class="inlinecode">go</span>, and <span class="inlinecode">gmake</span> are required:<br />
+<br />
<pre>
$ doas pkg_add git go gmake
-</pre><br />
-<p>I am happy that the Go Programming Language is readily available in the OpenBSD packaging system. Once the dependencies got installed, clone DTail and compile it:</p>
+</pre>
+<br />
+I am happy that the Go Programming Language is readily available in the OpenBSD packaging system. Once the dependencies got installed, clone DTail and compile it:<br />
+<br />
<pre>
$ mkdir git
$ cd git
$ git clone https://github.com/mimecast/dtail
$ cd dtail
$ gmake
-</pre><br />
-<p>You can verify the version by running the following command:</p>
+</pre>
+<br />
+You can verify the version by running the following command:<br />
+<br />
<pre>
$ ./dtail --version
DTail 4.1.0 Protocol 4.1 Have a lot of fun!
$ file dtail
dtail: ELF 64-bit LSB executable, x86-64, version 1
-</pre><br />
-<p>Now, there isn't any need anymore to keep <span class="inlinecode">git</span>, <span class="inlinecode">go</span> and <span class="inlinecode">gmake</span>, so they can be deinstalled now:</p>
+</pre>
+<br />
+Now, there isn't any need anymore to keep <span class="inlinecode">git</span>, <span class="inlinecode">go</span> and <span class="inlinecode">gmake</span>, so they can be deinstalled now:<br />
+<br />
<pre>
$ doas pkg_delete git go gmake
-</pre><br />
-<p>One day I shall create an official OpenBSD port for DTail.</p>
+</pre>
+<br />
+One day I shall create an official OpenBSD port for DTail.<br />
+<br />
<h2>Install it</h2>
-<p>Installing the binaries is now just a matter of copying them to <span class="inlinecode">/usr/local/bin</span> as follows:</p>
+Installing the binaries is now just a matter of copying them to <span class="inlinecode">/usr/local/bin</span> as follows:<br />
+<br />
<pre>
$ for bin in dserver dcat dgrep dmap dtail dtailhealth; do
doas cp -p $bin /usr/local/bin/$bin
doas chown root:wheel /usr/local/bin/$bin
done
-</pre><br />
-<p>Also, we will be creating the <span class="inlinecode">_dserver</span> service user:</p>
+</pre>
+<br />
+Also, we will be creating the <span class="inlinecode">_dserver</span> service user:<br />
+<br />
<pre>
$ doas adduser -class nologin -group _dserver -batch _dserver
$ doas usermod -d /var/run/dserver/ _dserver
-</pre><br />
-<p>The OpenBSD init script is created from scratch (not part of the official DTail project). Run the following to install the bespoke script:</p>
+</pre>
+<br />
+The OpenBSD init script is created from scratch (not part of the official DTail project). Run the following to install the bespoke script:<br />
+<br />
<pre>
$ cat &lt;&lt;'END' | doas tee /etc/rc.d/dserver
#!/bin/ksh
@@ -111,9 +133,11 @@ rc_pre() {
rc_cmd $1 &amp;
END
$ doas chmod 755 /etc/rc.d/dserver
-</pre><br />
+</pre>
+<br />
<h3>Rexification</h3>
-<p>This is the task for setting it up via Rex. Note the <span class="inlinecode">. . . .</span>, that's a placeholder which we will fill up more and more during this blog post:</p>
+This is the task for setting it up via Rex. Note the <span class="inlinecode">. . . .</span>, that's a placeholder which we will fill up more and more during this blog post:<br />
+<br />
<pre>
desc 'Setup DTail';
task 'dtail', group =&gt; 'frontends',
@@ -135,15 +159,19 @@ task 'dtail', group =&gt; 'frontends',
service 'dserver' =&gt; 'restart' if $restart;
service 'dserver', ensure =&gt; 'started';
};
-</pre><br />
+</pre>
+<br />
<h2>Configure it</h2>
-<p>Now, DTail is fully installed but still needs to be configured. Grab the default config file from GitHub ...</p>
+Now, DTail is fully installed but still needs to be configured. Grab the default config file from GitHub ...<br />
+<br />
<pre>
$ doas mkdir /etc/dserver
$ curl https://raw.githubusercontent.com/mimecast/dtail/master/samples/dtail.json.sample |
doas tee /etc/dserver/dtail.json
-</pre><br />
-<p>... and then edit it and adjust <span class="inlinecode">LogDir</span> in the <span class="inlinecode">Common</span> section to <span class="inlinecode">/var/log/dserver</span>. The result will look like this:</p>
+</pre>
+<br />
+... and then edit it and adjust <span class="inlinecode">LogDir</span> in the <span class="inlinecode">Common</span> section to <span class="inlinecode">/var/log/dserver</span>. The result will look like this:<br />
+<br />
<pre>
"Common": {
"LogDir": "/var/log/dserver",
@@ -153,9 +181,11 @@ $ curl https://raw.githubusercontent.com/mimecast/dtail/master/samples/dtail.jso
"SSHPort": 2222,
"LogLevel": "Info"
}
-</pre><br />
+</pre>
+<br />
<h3>Rexification</h3>
-<p>That's as simple as adding the following to the Rex task:</p>
+That's as simple as adding the following to the Rex task:<br />
+<br />
<pre>
file '/etc/dserver',
ensure =&gt; 'directory';
@@ -166,10 +196,13 @@ file '/etc/dserver/dtail.json',
group =&gt; 'wheel',
mode =&gt; '755',
on_change =&gt; sub { $restart = TRUE };
-</pre><br />
+</pre>
+<br />
<h2>Update the key cache for it</h2>
-<p>DTail relies on SSH for secure authentication and communication. However, the system user <span class="inlinecode">_dserver</span> has no permission to read the SSH public keys from the user's home directories, so the DTail server also checks for available public keys in an alternative path <span class="inlinecode">/var/run/dserver/cache</span>. </p>
-<p>The following script, populating the DTail server key cache, can be run periodically via <span class="inlinecode">CRON</span>:</p>
+DTail relies on SSH for secure authentication and communication. However, the system user <span class="inlinecode">_dserver</span> has no permission to read the SSH public keys from the user's home directories, so the DTail server also checks for available public keys in an alternative path <span class="inlinecode">/var/run/dserver/cache</span>. <br />
+<br />
+The following script, populating the DTail server key cache, can be run periodically via <span class="inlinecode">CRON</span>:<br />
+<br />
<pre>
$ cat &lt;&lt;'END' | doas tee /usr/local/bin/dserver-update-key-cache.sh
#!/bin/ksh
@@ -208,14 +241,18 @@ done
echo 'All set...'
END
$ doas chmod 500 /usr/local/bin/dserver-update-key-cache.sh
-</pre><br />
-<p>Note that the script above is a slight variation of the official DTail script. The official DTail one is a <span class="inlinecode">bash</span> script, but on OpenBSD, there's <span class="inlinecode">ksh</span>. I run it once daily by adding it to the <span class="inlinecode">daily.local</span>:</p>
+</pre>
+<br />
+Note that the script above is a slight variation of the official DTail script. The official DTail one is a <span class="inlinecode">bash</span> script, but on OpenBSD, there's <span class="inlinecode">ksh</span>. I run it once daily by adding it to the <span class="inlinecode">daily.local</span>:<br />
+<br />
<pre>
$ echo /usr/local/bin/dserver-update-key-cache.sh | doas tee -a /etc/daily.local
/usr/local/bin/dserver-update-key-cache.sh
-</pre><br />
+</pre>
+<br />
<h3>Rexification</h3>
-<p>That's done by adding ...</p>
+That's done by adding ...<br />
+<br />
<pre>
file '/usr/local/bin/dserver-update-key-cache.sh',
content =&gt; template('./scripts/dserver-update-key-cache.sh.tpl'),
@@ -224,10 +261,13 @@ file '/usr/local/bin/dserver-update-key-cache.sh',
mode =&gt; '500';
append_if_no_such_line '/etc/daily.local', '/usr/local/bin/dserver-update-key-cache.sh';
-</pre><br />
-<p>... to the Rex task!</p>
+</pre>
+<br />
+... to the Rex task!<br />
+<br />
<h2>Start it</h2>
-<p>Now, it's time to enable and start the DTail server:</p>
+Now, it's time to enable and start the DTail server:<br />
+<br />
<pre>
$ sudo rcctl enable dserver
$ sudo rcctl start dserver
@@ -248,8 +288,10 @@ INFO|1022-090739|86050|stats.go:53|2|11|7|||MAPREDUCE:STATS|currentConnections=0
.
.
Ctr+C
-</pre><br />
-<p>As we don't want to wait until tomorrow, let's populate the key cache manually:</p>
+</pre>
+<br />
+As we don't want to wait until tomorrow, let's populate the key cache manually:<br />
+<br />
<pre>
$ doas /usr/local/bin/dserver-update-key-cache.sh
Updating SSH key cache
@@ -260,10 +302,13 @@ Caching /home/git/.ssh/authorized_keys -&gt; /var/cache/dserver/git.authorized_k
Caching /home/paul/.ssh/authorized_keys -&gt; /var/cache/dserver/paul.authorized_keys
Caching /home/rex/.ssh/authorized_keys -&gt; /var/cache/dserver/rex.authorized_keys
All set...
-</pre><br />
+</pre>
+<br />
<h2>Use it</h2>
-<p>The DTail server is now ready to serve connections. You can use any DTail commands, such as <span class="inlinecode">dtail</span>, <span class="inlinecode">dgrep</span>, <span class="inlinecode">dmap</span>, <span class="inlinecode">dcat</span>, <span class="inlinecode">dtailhealth</span>, to do so. Checkout out all the usage examples on the official DTail page.</p>
-<p>I have installed DTail server this way on my personal OpenBSD frontends <span class="inlinecode">blowfish</span>, and <span class="inlinecode">fishfinger</span>, and the following command connects as user <span class="inlinecode">rex</span> to both machines and greps the file <span class="inlinecode">/etc/fstab</span> for the string <span class="inlinecode">local</span>:</p>
+The DTail server is now ready to serve connections. You can use any DTail commands, such as <span class="inlinecode">dtail</span>, <span class="inlinecode">dgrep</span>, <span class="inlinecode">dmap</span>, <span class="inlinecode">dcat</span>, <span class="inlinecode">dtailhealth</span>, to do so. Checkout out all the usage examples on the official DTail page.<br />
+<br />
+I have installed DTail server this way on my personal OpenBSD frontends <span class="inlinecode">blowfish</span>, and <span class="inlinecode">fishfinger</span>, and the following command connects as user <span class="inlinecode">rex</span> to both machines and greps the file <span class="inlinecode">/etc/fstab</span> for the string <span class="inlinecode">local</span>:<br />
+<br />
<pre>
❯ ./dgrep -user rex -servers blowfish.buetow.org,fishfinger.buetow.org --regex local /etc/fstab
CLIENT|earth|WARN|Encountered unknown host|{blowfish.buetow.org:2222 0xc0000a00f0 0xc0000a61e0 [blowfish.buetow.org]:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9ZnF/LAk14SgqCzk38yENVTNfqibcluMTuKx1u53cKSp2xwHWzy0Ni5smFPpJDIQQljQEJl14ZdXvhhjp1kKHxJ79ubqRtIXBlC0PhlnP8Kd+mVLLHYpH9VO4rnaSfHE1kBjWkI7U6lLc6ks4flgAgGTS5Bb7pLAjwdWg794GWcnRh6kSUEQd3SftANqQLgCunDcP2Vc4KR9R78zBmEzXH/OPzl/ANgNA6wWO2OoKKy2VrjwVAab6FW15h3Lr6rYIw3KztpG+UMmEj5ReexIjXi/jUptdnUFWspvAmzIl6kwzzF8ExVyT9D75JRuHvmxXKKjyJRxqb8UnSh2JD4JN [23.88.35.144]:2222 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC9ZnF/LAk14SgqCzk38yENVTNfqibcluMTuKx1u53cKSp2xwHWzy0Ni5smFPpJDIQQljQEJl14ZdXvhhjp1kKHxJ79ubqRtIXBlC0PhlnP8Kd+mVLLHYpH9VO4rnaSfHE1kBjWkI7U6lLc6ks4flgAgGTS5Bb7pLAjwdWg794GWcnRh6kSUEQd3SftANqQLgCunDcP2Vc4KR9R78zBmEzXH/OPzl/ANgNA6wWO2OoKKy2VrjwVAab6FW15h3Lr6rYIw3KztpG+UMmEj5ReexIjXi/jUptdnUFWspvAmzIl6kwzzF8ExVyT9D75JRuHvmxXKKjyJRxqb8UnSh2JD4JN 0xc0000a2180}
@@ -274,24 +319,33 @@ CLIENT|earth|INFO|STATS:STATS|cgocalls=11|cpu=8|connected=2|servers=2|connected%
CLIENT|earth|INFO|Added hosts to known hosts file|/home/paul/.ssh/known_hosts
REMOTE|blowfish|100|7|fstab|31bfd9d9a6788844.h /usr/local ffs rw,wxallowed,nodev 1 2
REMOTE|fishfinger|100|7|fstab|093f510ec5c0f512.h /usr/local ffs rw,wxallowed,nodev 1 2
-</pre><br />
-<p>Running it the second time, and given that you trusted the keys the first time, it won't prompt you for the host keys anymore:</p>
+</pre>
+<br />
+Running it the second time, and given that you trusted the keys the first time, it won't prompt you for the host keys anymore:<br />
+<br />
<pre>
❯ ./dgrep -user rex -servers blowfish.buetow.org,fishfinger.buetow.org --regex local /etc/fstab
REMOTE|blowfish|100|7|fstab|31bfd9d9a6788844.h /usr/local ffs rw,wxallowed,nodev 1 2
REMOTE|fishfinger|100|7|fstab|093f510ec5c0f512.h /usr/local ffs rw,wxallowed,nodev 1 2
-</pre><br />
+</pre>
+<br />
<h2>Conclusions</h2>
-<p>It's a bit of manual work, but it's ok on this small scale! I shall invest time in creating an official OpenBSD port, though. That would render most of the manual steps obsolete, as outlined in this post!</p>
-<p>Check out the following for more information:</p>
+It's a bit of manual work, but it's ok on this small scale! I shall invest time in creating an official OpenBSD port, though. That would render most of the manual steps obsolete, as outlined in this post!<br />
+<br />
+Check out the following for more information:<br />
+<br />
<a class="textlink" href="https://dtail.dev">https://dtail.dev</a><br />
<a class="textlink" href="https://github.com/mimecast/dtail">https://github.com/mimecast/dtail</a><br />
<a class="textlink" href="https://www.rexify.org">https://www.rexify.org</a><br />
-<p>Other related posts are:</p>
+<br />
+Other related posts are:<br />
+<br />
<a class="textlink" href="./2022-10-30-installing-dtail-on-openbsd.html">2022-10-30 Installing DTail on OpenBSD (You are currently reading this)</a><br />
<a class="textlink" href="./2022-03-06-the-release-of-dtail-4.0.0.html">2022-03-06 The release of DTail 4.0.0</a><br />
<a class="textlink" href="./2021-04-22-dtail-the-distributed-log-tail-program.html">2021-04-22 DTail - The distributed log tail program</a><br />
-<p>E-Mail your comments to hi@paul.cyou :-)</p>
+<br />
+E-Mail your comments to hi@paul.cyou :-)<br />
+<br />
<a class="textlink" href="../">Back to the main site</a><br />
<p class="footer">
Generated with <a href="https://codeberg.org/snonux/gemtexter">Gemtexter</a> |