<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Georgijs Radovs on Medium]]></title>
        <description><![CDATA[Stories by Georgijs Radovs on Medium]]></description>
        <link>https://medium.com/@georgijsr?source=rss-80353fb7ad97------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GH8nOns6pMrsQnwvjdNGpA.jpeg</url>
            <title>Stories by Georgijs Radovs on Medium</title>
            <link>https://medium.com/@georgijsr?source=rss-80353fb7ad97------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 22:46:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@georgijsr/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Manage Passwords in CLI with Pass and Tomb]]></title>
            <link>https://medium.com/swlh/manage-passwords-with-pass-and-tomb-in-cli-80aab0bc3d80?source=rss-80353fb7ad97------2</link>
            <guid isPermaLink="false">https://medium.com/p/80aab0bc3d80</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[how-to]]></category>
            <category><![CDATA[sysadmin]]></category>
            <dc:creator><![CDATA[Georgijs Radovs]]></dc:creator>
            <pubDate>Sun, 17 Jul 2022 21:11:37 GMT</pubDate>
            <atom:updated>2022-07-17T22:06:11.119Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, everyone.<br>Just wanted to share my experience on how I manage passwords in a CLI environment.</p><h3>Tools</h3><p>To setup our environment, we are going to use the following tools:</p><h4>Pass</h4><p><a href="https://www.passwordstore.org/">Website</a>:</p><blockquote>Password management should be simple and follow <a href="http://en.wikipedia.org/wiki/Unix_philosophy">Unix philosophy</a>. With pass, each password lives inside of a <a href="http://en.wikipedia.org/wiki/GNU_Privacy_Guard">gpg</a> encrypted file whose filename is the title of the website or resource that requires the password. These encrypted files may be organized into meaningful folder hierarchies, copied from computer to computer, and, in general, manipulated using standard command line file management utilities.</blockquote><h4>Tomb</h4><p><a href="https://www.dyne.org/software/tomb/">Website</a>:</p><blockquote>Tomb is an <strong>100% free</strong> and open source system for file encryption on GNU/Linux, facilitating the backup of secret files. Tomb is written in code that is easy to review and links commonly shared components.</blockquote><blockquote>Tomb generates encrypted storage folders to be opened and closed using their associated keyfiles, which are also protected with a password chosen by the user.</blockquote><blockquote>A tomb is like a locked folder that can be safely transported and hidden in a filesystem; its keys can be kept separate, for instance keeping the tomb file on your computer harddisk and the key files on a USB stick.</blockquote><h4>Pass Extensions</h4><p><a href="https://github.com/tadfisher/pass-otp"><strong>pass-otp</strong></a> — to manage OTP-tokens.<br><a href="https://github.com/roddhjav/pass-tomb"><strong>pass-tomb </strong></a>— to store passwords in an encrypted container.</p><h3>Setting Up</h3><h4>Install Packages</h4><p>Ubuntu:</p><pre># apt install pass pass-extension-otp pass-extension-tomb tomb</pre><p>openSUSE:</p><pre># zypper install password-store pass-otp</pre><p>pass-tomb extension is not available in openSUSE repositories, so we will get it directly from the <a href="https://github.com/roddhjav/pass-tomb">repository</a> and install it manually:</p><pre>$ git clone <a href="https://github.com/roddhjav/pass-tomb">https://github.com/roddhjav/pass-tomb</a> ~/Downloads<br>$ cd ~/Downloads/pass-tomb &amp;&amp; sudo make install</pre><p>tomb package is also not available in the default openSUSE repositories, so we have two choices:</p><ul><li>Use tomb package from openSUSE security <a href="https://build.opensuse.org/package/show/security/tomb">project</a></li><li>Use tomb release archive directly from <a href="https://files.dyne.org/tomb/releases/Tomb-2.9.tar.gz">files.dyne.org</a></li></ul><p>I use openSUSE Tumbleweed on my laptop and I chose the second option:</p><pre>$ cd ~/Downloads &amp;&amp; wget <a href="https://files.dyne.org/tomb/releases/Tomb-2.9.tar.gz">https://files.dyne.org/tomb/releases/Tomb-2.9.tar.gz</a><br>$ tar xvf Tomb-2.9.tar.gz<br>$ cd Tomb-2.9 &amp;&amp; $ sudo make install</pre><p>After packages have been installed, it is time to configure and initialize the password-store.</p><h4>Initialization</h4><p>First, we create GPG keys, which will be used to encrypt password files and tomb files. You can use a single GPG key for both tomb and password-store, for convenience.<br>Generate keys using gpg2 :</p><pre>$ gpg2  --generate-key</pre><p>When GPG asks, you can use Name and Email fields to distinguish, which key is used for what purpose:</p><pre>gpg2 --list-keys tomb@localhost<br>pub   ed25519 2022-07-17 [SC] [expires: 2024-07-16]<br>      CEA18C257AE7F8EE6BEE1DFAB812D4B2351F850A                                                         <br>uid           [ultimate] Tomb Encryption Key &lt;tomb@localhost&gt;                                          <br>sub   cv25519 2022-07-17 [E] [expires: 2024-07-16]</pre><pre>gpg2 --list-keys pass@localhost <br>pub   ed25519 2022-07-17 [SC] [expires: 2024-07-16] <br>      9A5C25FBBC97DA06A72FE53CEBA4150C580DBF49 <br>uid           [ultimate] Password Store &lt;pass@localhost&gt; <br>sub   cv25519 2022-07-17 [E] [expires: 2024-07-16]</pre><p>After GPG keys are ready for use, we will configure pass-tomb extension.</p><p>Create a directory where you will store your .pass.tomb and .pass.tomb.key files:</p><pre>$ mkdir /home/user/definitely_not_passwords</pre><p>Export environment variables for pass-tomb to be able to find the password-store directory, .pass.tomb and .pass.tomb.key files:</p><pre>$ export PASSWORD_STORE_DIR=/home/user/.password-store<br>$ export PASSWORD_STORE_TOMB_FILE=/home/user/definitely_not_passwords/.pass.tomb<br>$ export PASSWORD_STORE_TOMB_KEY=/home/user/definitely_not_passwords/.pass.tomb.key</pre><p>Initialize pass-tomb:</p><pre>pass tomb --no-init --verbose --force tomb@localhost <br>  <strong>.</strong>  pass Creating a password tomb with the GPG key(s): tomb@localhost <br>  <strong>.</strong>  tomb  .  Commanded to dig tomb <br>  <strong>.</strong>  tomb (*) Creating a new tomb in /home/user/definitely_not_passwords/.pass.tomb <br>  <strong>.</strong>  tomb  .  Generating /home/user/definitely_not_passwords/.pass.tomb of 10MiB <br>  <strong>.</strong>  10+0 records in <br>  <strong>.</strong>  10+0 records out <br>  <strong>.</strong>  10485760 bytes (10 MB, 10 MiB) copied, 0.0206397 s, 508 MB/s <br>  <strong>.</strong>  -rw------- 1 user user10M jul 17 16:51 /home/user/definitely_not_passwords/.pass.tomb <br>  <strong>.</strong>  tomb (*) Done digging /home/user/definitely_not_passwords/.pass.tomb <br>  <strong>.</strong>  tomb  .  Your tomb is not yet ready, you need to forge a key and lock it: <br>  <strong>.</strong>  tomb  .  tomb forge /home/user/definitely_not_passwords/.pass.tomb.key <br>  <strong>.</strong>  tomb  .  tomb lock /home/user/definitely_not_passwords/.pass.tomb -k /home/user/definitely_not_passwords/.pass.tomb.key <br>  <strong>.</strong>  tomb  .  Commanded to forge key /home/user/definitely_not_passwords/.pass.tomb.key with cipher algorithm AES256 <br>  <strong>.</strong>  tomb [W] This operation takes time. Keep using this computer on other tasks. <br>  <strong>.</strong>  tomb [W] Once done you will be asked to choose a password for your tomb. <br>  <strong>.</strong>  tomb [W] To make it faster you can move the mouse around. <br>  <strong>.</strong>  tomb [W] If you are on a server, you can use an Entropy Generation Daemon. <br>  <strong>.</strong>  512+0 records in <br>  <strong>.</strong>  512+0 records out <br>  <strong>.</strong>  512 bytes copied, 0.000389054 s, 1.3 MB/s <br>  <strong>.</strong>  tomb (*) Using GnuPG key(s) to encrypt your key: /home/user/definitely_not_passwords/.pass.tomb.key <br>  <strong>.</strong>  tomb  .  (You can also change it later using &#39;tomb passwd&#39;.) <br>  <strong>.</strong>  tomb [W] You are going to encrypt a tomb key with 1 recipient(s). <br>  <strong>.</strong>  tomb [W] It is your responsibility to check these fingerprints. <br>  <strong>.</strong>  tomb [W] The fingerprints are: <br>  <strong>.</strong>  tomb [W]     CEA18C257AE7F8EE6BEE1DFAB812D4B2351F850A :: Tomb Encryption Key &lt;tomb@localhost&gt; <br>  <strong>.</strong>  tomb  .  Key is valid. <br>  <strong>.</strong>  tomb  .  Done forging /home/user/definitely_not_passwords/.pass.tomb.key <br>  <strong>.</strong>  tomb (*) Your key is ready: <br>  <strong>.</strong>  -rw------- 1 user user 971 jul 17 16:51 /home/user/definitely_not_passwords/.pass.tomb.key <br>  <strong>.</strong>  tomb [W] File is not yet a tomb: /home/user/definitely_not_passwords/.pass.tomb <br>  <strong>.</strong>  tomb  .  Valid tomb file found: /home/user/definitely_not_passwords/.pass.tomb <br>  <strong>.</strong>  tomb  .  Commanded to lock tomb .pass.tomb <br>  <strong>.</strong>  tomb  .  Checking if the tomb is empty (we never step on somebody else&#39;s bones). <br>  <strong>.</strong>  tomb  .  Fine, this tomb seems empty. <br>  <strong>.</strong>  tomb  .  Key is valid. <br>  <strong>.</strong>  tomb  .  Locking using cipher: aes-xts-plain64 <br>  <strong>.</strong>  tomb (*) Locking .pass.tomb with /home/user/definitely_not_passwords/.pass.tomb.key <br>  <strong>.</strong>  tomb  .  Formatting Luks mapped device. <br>  <strong>.</strong>  tomb  .  Formatting your Tomb with ext4 filesystem. <br>  <strong>.</strong>  tomb  .  Done locking .pass using Luks dm-crypt aes-xts-plain64 <br>  <strong>.</strong>  tomb (*) Your tomb is ready in /home/user/definitely_not_passwords/.pass.tomb and secured with key /home/user/definitely_not_passwords/.pass.tomb.key <br>  <strong>.</strong>  tomb  .  Commanded to open tomb /home/user/definitely_not_passwords/.pass.tomb <br>  <strong>.</strong>  tomb  .  Valid tomb file found: /home/user/pdefinitely_not_passwords/.pass.tomb <br>  <strong>.</strong>  tomb  .  Key is valid. <br>  <strong>.</strong>  tomb (*) Opening .pass on /home/user/.password-store/ <br>  <strong>.</strong>  tomb  .  This tomb is a valid LUKS encrypted device. <br>  <strong>.</strong>  tomb  .  Cipher is &quot;aes&quot; mode &quot;xts-plain64&quot; hash &quot;sha512&quot; <br>  <strong>.</strong>  DM-UUID for device tomb..pass-test.eecf947f8a477774194d3cd4d12ebbab026c257ed7f2658714910ee4c2bf1fb9.loop1 was truncated. <br>  <strong>.</strong>  tomb (*) Success unlocking tomb .pass <br>  <strong>.</strong>  tomb  .  Filesystem detected: ext4 <br>  <strong>.</strong>  tomb  .  Checking filesystem via /dev/loop1 <br>  <strong>.</strong>  fsck from util-linux 2.37.4 <br>  <strong>.</strong>  .pass: clean, 11/2048 files, 1618/8192 blocks <br>  <strong>.</strong>  tomb (*) Success opening .pass.tomb on /home/user/.password-store/ <br>  <strong>.</strong>  pass Setting user permissions on /home/user/.password-store/ <br> <strong>(*)</strong> Your password tomb has been created and opened in /home/user/.password-store. <br>  <strong>.</strong>  Your tomb is: /home/user/definitely_not_passwords/.pass.tomb <br>  <strong>.</strong>  Your tomb key is: /home/user/definitely_not_passwords/.pass.tomb.key <br>  <strong>.</strong>  You need to initialise the store with &#39;pass init gpg-id...&#39;. <br>  <strong>.</strong>  When finished, close the password tomb using &#39;pass close&#39;.</pre><p>If you would like to initialize using a single GPG key for both tomb and password-store — omit --no-init flag. This way, tomb will initialize password-store automatically.</p><p>Initialize password-store:</p><pre>$ pass init pass@localhost &amp;&amp; cd /home/user/.password-store<br>$ ls -l <br>total 22 <br>drwxr-xr-x  3 user user  1024 jul 17 20:40 . <br>drwx------ 34 user user  4096 jul 17 21:13 .. <br>-rw-------  1 user user    15 jul 17 20:37 .gpg-id <br>-rw-r--r--  1 user user    10 jul 17 16:51 .host <br>-rw-r--r--  1 user user    11 jul 17 16:51 .last <br>drwx------  2 user user 12288 jul 17 16:51 lost+found <br>-rw-r--r--  1 user user    12 jul 17 16:51 .tty <br>-rw-r--r--  1 user user     5 jul 17 16:51 .uid<br>$ cat .gpg-id<br>pass@localhost<br>$ pass <br>Password Store <br>└── <strong>lost+found</strong></pre><p>After this, initialization should be complete.</p><h4>Configuration</h4><p>A quote from pass <a href="https://www.passwordstore.org/">website</a> about data organization in password store:</p><blockquote>The password store does not impose any particular schema or type of organization of your data, as it is simply a flat text file, which can contain arbitrary data. Though the most common case is storing a single password per entry, some power users find they would like to store more than just their password inside the password store, and additionally store answers to secret questions, website URLs, and other sensitive information or metadata. Since the password store does not impose a scheme of it’s own, you can choose your own organization. There are many possibilities.</blockquote><p>Here is how I structure data in my password store:</p><pre>$ pass generate personal/finance/crypto/example.com/password<br>$ pass otp insert personal/finance/crypto/example.com/otp</pre><pre>$ pass<br>Password Store <br>├── <strong>lost+found</strong> <br>└── <strong>personal</strong><br>    ├── <strong>finance</strong> <br>    │   ├── <strong>crypto</strong> <br>    │   │   ├── <strong>example.com</strong> <br>    │   │   │   ├── otp <br>    │   │   │   └── password<br>$ ls -l /home/user/.password-store/personal/finance/crypto/example.com<br>total 2 <br>-rw------- 1 user user 580 jul  3 19:48 otp.gpg <br>-rw-r--r-- 1 user user 475 jul  3 19:48 password.gpg</pre><p>You can configure it in the same manner or try something that suits you better. :)</p><p>Now, that everything is initialized and configured, It is recommended to create a shell alias for pass, specifying shell variables we’ve exported earlier, so you don’t have to export them all the time:</p><pre>$ touch /home/user/.aliases<br>$ vim /home/user/.aliases</pre><pre>alias pass=&#39;PASSWORD_STORE_TOMB_FILE=~/definitely_not_passwords/.pass-test.tomb PASSWORD_STORE_TOMB_KEY=~/definitely_not_passwords/.pass-test.tomb.key PASSWORD_STORE_DIR=~/.password-store&#39;</pre><p>Add this line to your shell’s rc file, for example, .bashrc:</p><pre>test -s ~/.aliases &amp;&amp; source ~/.aliases || true</pre><p>Separate .aliases file allows us to have an uncluttered shell rc file and shell aliases defined in a clean way.</p><p>After all is done, you should be able to run pass close command, close your password-store and store all your passwords in .pass.tomb file:</p><pre>$ pass close -v -f <br>  <strong>.</strong>  pass Closing the password tomb /home/user/definitely_not_passwords/.pass.tomb <br> <br>[sudo] Enter password for user user to gain superuser privileges <br> <br> <br>  <strong>.</strong>  tomb  .  Closing tomb [.pass] mounted on /home/user/.password-store<br>  <strong>.</strong>  tomb (*) Tomb [.pass] closed: your bones will rest in peace. <br> <strong>(*)</strong> Your password tomb has been closed. <br>  <strong>.</strong>  Your passwords remain present in /home/user/definitely_not_passwords/.pass.tomb.</pre><pre>$ ls ~/.password-store-test  <br>$ pass<br>Password Store</pre><p>What is cool is that now, you can store .pass.tomb file with your passwords in git or any other storage solution!<br>Thanks to tomb and pass-tomb extension, our password store is encrypted in .pass.tomb file and its password-file structure is not exposed to prying eyes.</p><p>Password store after pass open:</p><pre>$ pass<br>Password Store <br>├── <strong>lost+found</strong> <br>└── <strong>personal</strong><br>    ├── <strong>finance</strong> <br>    │   ├── <strong>crypto</strong> <br>    │   │   ├── <strong>example.com</strong> <br>    │   │   │   ├── otp <br>    │   │   │   └── password</pre><p>Password store after pass close:</p><pre>$ pass<br>Password Store</pre><p>That is it!</p><p>Don’t forget to run pass open after you reboot your PC. :)</p><p>Thank you for your attention and have a nice day!</p><p>P.S</p><p>If you notice any typos or mistakes — drop a comment and I will fix it. Thank you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80aab0bc3d80" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/manage-passwords-with-pass-and-tomb-in-cli-80aab0bc3d80">Manage Passwords in CLI with Pass and Tomb</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Running Hashicorp Nomad, Consul, Pihole and Gitea on Raspberry Pi 3 B+]]></title>
            <link>https://medium.com/swlh/running-hashicorp-nomad-consul-pihole-and-gitea-on-raspberry-pi-3-b-f3f0d66c907?source=rss-80353fb7ad97------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3f0d66c907</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[gitea]]></category>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[hashicorp]]></category>
            <category><![CDATA[pihole]]></category>
            <dc:creator><![CDATA[Georgijs Radovs]]></dc:creator>
            <pubDate>Sat, 23 May 2020 08:48:18 GMT</pubDate>
            <atom:updated>2020-09-15T22:28:37.523Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*XnBGVMRnZZMxb1p63prHlw.png" /><figcaption><a href="https://www.raspberrypi.org/">https://www.raspberrypi.org/</a></figcaption></figure><p>Hello, everyone!<br>I’d like to share my experience of setting up some useful services for my LAN, using Raspberry Pi 3 B+ and Hashicorp Nomad.</p><h3>Hardware</h3><p>I think, by now, everyone knows about <a href="https://www.raspberrypi.org/">Raspberry Pi</a> single-board computer, not much to say about it. :)<br>Here are the specs of the Model 3 B+ which I currently use:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/512/1*kowZ3qwHVF4827LYJM3kUg.png" /><figcaption>Raspberry Pi 3 Model B+ Specification</figcaption></figure><p>For data storage, I strongly suggest to invest into an external storage solution.<br>For example, a NAS or a <a href="https://raidsonic.de/products/external_cases/soho_raid/index_en.php?we_objectID=3239">RAID enclosure</a>.<br>Attach the data storage to Raspberry Pi and mount it somewhere on the filesystem, for example: /mnt/storage , it will be used to store data related to Nomad and Consul.</p><h3>OS/Software</h3><p>For OS, I’m using <a href="https://en.opensuse.org/Portal:ARM">openSUSE Tumbleweed ARM,</a> because — why not? :)<br>Haven’t encountered any issues yet running it.<br>You should be able to use any OS as long as it has support for ARM and software stack we’re going to be using.</p><h4>Software Stack</h4><p>After you’ve installed an OS and finished initial configuration of your Raspberry Pi, it’s time to install the software stack that we will use to run and manage our services.<br>We will use the following software:</p><ul><li><a href="https://www.docker.com/">Docker</a></li><li><a href="https://nomadproject.io/">Nomad</a></li><li><a href="https://www.consul.io/">Consul</a></li></ul><h4>Docker</h4><p>We’re going to use Docker to run <a href="https://hub.docker.com/r/gitea/gitea">Gitea</a> and <a href="https://hub.docker.com/r/pihole/pihole">Pihole</a> containers.<br>Both Gitea and Pihole have official Docker images available, so it’s a good starting point.</p><h4>Nomad</h4><p>Nomad will be used as a container manager and resources/task scheduler.<br>Initially, I was looking to try the <a href="https://k3s.io/">K3S</a> project for the aforementioned purpose,<br>but, after some usage, I found it to be a bit of an overkill. Also, I’m not very familiar with Kubernetes, and Nomad had a less steep learning curve.<br>After some research and playing around, Nomad seemed to be better suited for the task.</p><h4>Consul</h4><p>Consul will be used mainly for service-discovery purposes.<br>Nomad does not provide any service-discovery functionality by itself, but relies on Consul to provide that functionality.</p><h3>Software Installation/Configuration</h3><h4>Docker</h4><p>If you’re running openSUSE Tumbleweed, you can <a href="https://en.opensuse.org/SDB:Zypper_usage">install</a> Docker CE from openSUSE repositories. Docker package version should be fairly close with Docker release notes.<br>If you’re running Raspbian/Ubuntu Core, you will have to add a <a href="https://docs.docker.com/engine/install/debian/">Debian Docker repository</a> or <a href="https://docs.docker.com/engine/install/ubuntu/">Ubuntu Docker repository</a> and install Docker from there.<br>If you’re running Windows… Sorry, can’t help with that. :)</p><p>After Docker has been installed, start and enable docker service and add your user to docker group.</p><h4>Nomad</h4><p><a href="https://releases.hashicorp.com/nomad/0.11.0/nomad_0.11.0_linux_arm64.zip">Download</a> Nomad ZIP-archive and unpack the binary to /usr/bin or /usr/local/bin:</p><pre>user@raspberrypi:~&gt; nomad -version<strong><br></strong>Nomad v0.11.0 (5f8fe0afc894d254e4d3baaeaee1c7a70a44fdc6)</pre><p>For storing Nomad configuration, create the following directories in the data directory created earlier:</p><ul><li>conf</li><li>data</li><li>jobs</li><li>nomad.d</li></ul><p>For example:</p><pre>user@raspberrypi:~&gt;/mnt/storage/nomad # tree -L 1<br>.<br>├── conf<br>├── data<br>├── jobs<br>└── nomad.d</pre><p>After directories have been created, cd into nomad.d and create the following files:</p><ul><li><strong>server.hcl</strong> — Nomad server configuration:</li></ul><pre>server {<br>  enabled = true<br>}</pre><pre>data_dir  = &quot;/mnt/storage/nomad/conf&quot;<br>datacenter = &quot;DC0&quot;</pre><pre>bind_addr = &quot;0.0.0.0&quot;</pre><pre>ports {<br>  http = 4646<br>  rpc  = 4647<br>  serf = 4648<br>}</pre><pre>consul {<br>  address = &quot;127.0.0.1:8500&quot;<br>}</pre><pre>acl {<br>  enabled    = false<br>  token_ttl  = &quot;30s&quot;<br>  policy_ttl = &quot;60s&quot;<br>}</pre><ul><li><strong>client.hcl</strong> — Nomad client configuration:</li></ul><pre>client {<br>  enabled = true<br>  network_interface = &quot;eth0&quot;<br>  server_join {<br>    retry_join = [<br>      &quot;127.0.0.1&quot;<br>    ]<br>    retry_max = 3<br>    retry_interval = &quot;15s&quot;<br>  }<br>  host_volume &quot;gitea-data&quot; {<br>    path      = &quot;/mnt/storage/nomad/data/gitea/data&quot;<br>    read_only = false<br>  }<br>  host_volume &quot;gitea-db&quot; {<br>    path      = &quot;/mnt/storage/nomad/data/gitea/db&quot;<br>    read_only = false<br>  }<br>}</pre><p>Create nomad user and change Nomad directory ownership:</p><pre>useradd nomad -s /bin/false -d /mnt/storage/nomad/nomad.d -G docker<br>chown -R nomad:nomad /mnt/storage/nomad</pre><p>After Nomad has been configured, add <a href="https://github.com/hashicorp/nomad/blob/master/dist/systemd/nomad.service">nomad.service</a> systemd service file in /etc/systemd/system/:</p><pre>[Unit]<br>Description=Nomad<br>Documentation=<a href="https://nomadproject.io/docs/">https://nomadproject.io/docs/</a><br>Wants=network-online.target<br>After=network-online.target</pre><pre># When using Nomad with Consul it is not necessary to start Consul first. These<br># lines start Consul before Nomad as an optimization to avoid Nomad logging<br># that Consul is unavailable at startup.<br>Wants=consul.service<br>After=consul.service</pre><pre>[Service]<br>Type=simple<br>User=nomad<br>Group=nomad<br>ExecReload=/bin/kill -HUP $MAINPID<br>ExecStart=/usr/bin/nomad agent -config /mnt/storage/nomad/nomad.d<br>ExecStop=/bin/kill $MAINPID<br>KillMode=process<br>KillSignal=SIGINT<br>LimitNOFILE=65536<br>LimitNPROC=infinity<br>Restart=on-failure<br>RestartSec=2<br>StartLimitBurst=3<br>TasksMax=infinity<br>OOMScoreAdjust=-1000</pre><pre>[Install]<br>WantedBy=multi-user.target</pre><p>Run systemctl enable nomad to enable it to run on boot.</p><h4>Consul</h4><p><a href="https://releases.hashicorp.com/consul/1.7.2/consul_1.7.2_linux_arm64.zip">Download</a> Nomad ZIP-archive and unpack the binary to /usr/bin or /usr/local/bin :</p><pre>user@raspberrypi:~&gt; consul version<br>Consul v1.7.1<br>Protocol 2 spoken by default, understands 2 to 3 (agent will automatically use protocol &gt;2 when speaking to compatible agents)</pre><p>For storing Consul configuration, create the following directories in the data directory create earlier:</p><ul><li>conf</li><li>consul.d</li><li>data</li></ul><p>For example:</p><pre>user@raspberrypi:/mnt/storage/consul&gt; tree -L 1<br>.<br>├── conf<br>├── consul.d<br>└── data</pre><p>After directories have been created, cd into consul.d and create the following file:</p><p><strong>server.json</strong> — Consul server configuration:</p><pre>{<br>  &quot;server&quot;: true,<br>  &quot;datacenter&quot;: &quot;DC0&quot;,<br>  &quot;data_dir&quot;: &quot;/mnt/storage/consul/data&quot;,<br>  &quot;ui&quot;: true,<br>  &quot;bind_addr&quot;: &quot;127.0.0.1&quot;,<br>  &quot;bootstrap_expect&quot;: 1,<br>  &quot;ports&quot;: {<br>    &quot;grpc&quot;: 8502<br>  },<br>  &quot;connect&quot;: {<br>    &quot;enabled&quot;: true<br>  },<br>  &quot;encrypt&quot;: &quot;<a href="https://www.consul.io/docs/agent/encryption.html">generated_encrypt_key</a>&quot;<br>}</pre><p>Create consul user and change Consul directory ownership:</p><pre>useradd consul -s /bin/false -d /mnt/storage/consul/consul.d<br>chown -R consul:consul /mnt/storage/consul</pre><p>After Consul has been configured, add <a href="https://github.com/hashicorp/nomad/blob/master/dist/systemd/nomad.service">consul.service</a> systemd service file in /etc/systemd/system/:</p><pre>[Unit]<br>Description=&quot;HashiCorp Consul - A service mesh solution&quot;<br>Documentation=https://www.consul.io/<br>Requires=network-online.target<br>After=network-online.target<br>ConditionFileNotEmpty=/mnt/storage/consul/consul.d/server.json<br><br>[Service]<br>Type=simple<br>User=consul<br>Group=consul<br>ExecStart=/usr/bin/consul agent -config-dir=/mnt/storage/consul/consul.d/<br>ExecReload=/usr/bin/consul reload<br>KillMode=process<br>Restart=on-failure<br>LimitNOFILE=65536<br><br>[Install]<br>WantedBy=multi-user.target</pre><p>Run systemctl enable consul to enable it to run on boot.</p><p>After Nomad and Consul have been configured — run systemctl start nomad</p><p>Check if Nomad is running:</p><pre>user@raspberrypi:/mnt/storage/nomad&gt; systemctl status nomad<br>● nomad.service - Nomad<br>   Loaded: loaded (/etc/systemd/system/nomad.service; enabled; vendor preset: disabled)<br>   Active: active (running) since Mon 2020-04-13 22:28:16 UTC; 52min ago<br>     Docs: <a href="https://nomadproject.io/docs/">https://nomadproject.io/docs/</a><br> Main PID: 6872 (nomad)<br>    Tasks: 159<br>   CGroup: /system.slice/nomad.service<br>           ├─ 5774 /usr/bin/nomad logmon<br>           ├─ 5775 /usr/bin/nomad logmon<br>           ├─ 5777 /usr/bin/nomad logmon<br>           ├─ 6188 /usr/bin/nomad docker_logger<br>           ├─ 6190 /usr/bin/nomad docker_logger<br>           ├─ 6257 /usr/bin/nomad docker_logger<br>           ├─ 6872 /usr/bin/nomad agent -config /mnt/storage/nomad/nomad.d<br>           ├─16878 /usr/bin/nomad logmon<br>           ├─17056 /usr/bin/nomad docker_logger<br>           ├─20441 /usr/bin/nomad logmon<br>           ├─20442 /usr/bin/nomad logmon<br>           ├─20739 /usr/bin/nomad docker_logger<br>           ├─20775 /usr/bin/nomad docker_logger<br>           ├─28289 /usr/bin/nomad logmon<br>           └─28537 /usr/bin/nomad docker_logger</pre><p>Open <a href="http://raspberrypi_ip_address:4646/">http://raspberrypi_ip_address:4646</a> in your web-browser, you should see Nomad <a href="https://learn.hashicorp.com/nomad/getting-started/ui">web-ui</a>.</p><h3>Adding Nomad Jobs</h3><h4>Gitea</h4><p><a href="https://gitea.io/en-us/">Gitea</a> is a very nice and lightweight git-server written in Go.<br>I’m using Gitea to host and manage my personal projects and anything code-related.</p><p>To add a Nomad job for Gitea server, do the following:</p><ul><li>Create gitea directory in /mnt/storage/nomad/jobs/</li><li>Create tpl directory in /mnt/storage/nomad/jobs/gitea</li><li>Create job.nomad file in /mnt/storage/nomad/jobs/gitea</li></ul><pre>user@raspberrypi:/mnt/storage/nomad&gt; tree -L 1 gitea/<br>gitea/<br>├── job.nomad<br>└── tpl</pre><ul><li>Create <a href="https://learn.hashicorp.com/nomad/stateful-workloads/host-volumes">host volumes</a> to store persistent data for Gitea application and database:</li></ul><pre>mkdir /mnt/storage/nomad/data/gitea/data<br>mkdir /mnt/storage/nomad/data/gitea/db</pre><ul><li>Add the following to gitea/job.nomad:</li></ul><pre>job &quot;gitea&quot; {<br>  region = &quot;global&quot;</pre><pre>datacenters = [<br>    &quot;DC0&quot;,<br>  ]</pre><pre>type = &quot;service&quot;</pre><pre>group &quot;svc&quot; {<br>    count = 1</pre><pre>volume &quot;gitea-data&quot; {<br>      type      = &quot;host&quot;<br>      source    = &quot;gitea-data&quot;<br>      read_only = false<br>    }</pre><pre>volume &quot;gitea-db&quot; {<br>      type      = &quot;host&quot;<br>      source    = &quot;gitea-db&quot;<br>      read_only = false<br>    }</pre><pre>restart {<br>      attempts = 5<br>      delay    = &quot;30s&quot;<br>    }</pre><pre>task &quot;app&quot; {<br>      driver = &quot;docker&quot;</pre><pre>volume_mount {<br>        volume      = &quot;gitea-data&quot;<br>        destination = &quot;/data&quot;<br>        read_only   = false<br>      }</pre><pre>config {<br>        image = &quot;gitea/gitea:linux-arm64&quot;</pre><pre>port_map {<br>          http     = 3000<br>          ssh_pass = 22<br>        }<br>      }</pre><pre>env = {<br>        &quot;APP_NAME&quot;   = &quot;Gitea: Git with a cup of tea&quot;<br>        &quot;RUN_MODE&quot;   = &quot;prod&quot;<br>        &quot;SSH_DOMAIN&quot; = &quot;git.example.com&quot;<br>        &quot;SSH_PORT&quot;   = &quot;22&quot;<br>        &quot;ROOT_URL&quot;   = &quot;<a href="http://git.rpisrv0.lan0/">http://git.example.com/</a>&quot;<br>        &quot;USER_UID&quot;   = &quot;1002&quot;<br>        &quot;USER_GID&quot;   = &quot;1002&quot;<br>        &quot;DB_TYPE&quot;    = &quot;postgres&quot;<br>        &quot;DB_HOST&quot;    = &quot;${NOMAD_ADDR_db_db}&quot;<br>        &quot;DB_NAME&quot;    = &quot;gitea&quot;<br>        &quot;DB_USER&quot;    = &quot;gitea&quot;<br>        &quot;DB_PASSWD&quot;  = &quot;gitea&quot;<br>      }</pre><pre>resources {<br>        cpu    = 200<br>        memory = 256</pre><pre>network {<br>          port &quot;http&quot; {}</pre><pre>port &quot;ssh_pass&quot; {<br>            static = &quot;2222&quot;<br>          }<br>        }<br>      }</pre><pre>service {<br>        name = &quot;gitea-gui&quot;<br>        port = &quot;http&quot;<br>      }<br>    }</pre><pre>task &quot;db&quot; {<br>      driver = &quot;docker&quot;</pre><pre>volume_mount {<br>        volume      = &quot;gitea-db&quot;<br>        destination = &quot;/var/lib/postgresql/data&quot;<br>        read_only   = false<br>      }</pre><pre>config {<br>        image = &quot;postgres:10-alpine&quot;</pre><pre>port_map {<br>          db = 5432<br>        }<br>      }</pre><pre>env {<br>        &quot;POSTGRES_USER&quot;     = &quot;gitea&quot;<br>        &quot;POSTGRES_PASSWORD&quot; = &quot;gitea&quot;<br>        &quot;POSTGRES_DB&quot;       = &quot;gitea&quot;<br>      }</pre><pre>resources {<br>        cpu    = 200<br>        memory = 128</pre><pre>network {<br>          port &quot;db&quot; {}<br>        }<br>      }<br>    }<br>  }<br>}</pre><ul><li>Run nomad plan job.nomad</li><li>You should see something like this:</li></ul><pre>+/- Job: &quot;gitea&quot;<br>+/- Stop: &quot;true&quot; =&gt; &quot;false&quot;<br>    Task Group: &quot;svc&quot; (1 create)<br>      Task: &quot;app&quot;<br>      Task: &quot;db&quot;</pre><pre>Scheduler dry-run:<br>- All tasks successfully allocated.</pre><pre>Job Modify Index: 50291<br>To submit the job with version verification run:</pre><pre>nomad job run -check-index 50291 job.nomad</pre><pre>When running the job with the check-index flag, the job will only be run if the<br>server side version matches the job modify index returned. If the index has<br>changed, another user has modified the job and the plan&#39;s results are<br>potentially invalid.</pre><ul><li>Run nomad run job.nomad</li><li>You should see something like this:</li></ul><pre>==&gt; Monitoring evaluation &quot;d92bfc68&quot;<br>    Evaluation triggered by job &quot;gitea&quot;<br>    Evaluation within deployment: &quot;d3896093&quot;<br>    Allocation &quot;b3bd095a&quot; created: node &quot;e79c2d81&quot;, group &quot;svc&quot;<br>    Evaluation status changed: &quot;pending&quot; -&gt; &quot;complete&quot;<br>==&gt; Evaluation &quot;d92bfc68&quot; finished with status &quot;complete&quot;</pre><ul><li>Open Nomad UI in web-browser, you should see gitea job allocation running:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QAtAzD_xP7oVl4C5fufmCw.png" /><figcaption>Gitea Job Allocation</figcaption></figure><ul><li>Press http link, it should redirect you to Gitea UI:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SMPbpwuUzCm8ApIoKw0PxA.png" /></figure><ul><li>Press Sign In button and follow installation instructions</li><li>For SSH pass-through configuration, follow the official Gitea <a href="https://docs.gitea.io/en-us/install-with-docker/">documentation</a></li></ul><h4>Pihole</h4><p><a href="https://docs.pi-hole.net/">Pihole</a> is a lot of cool tools in a single package:</p><ul><li>A <a href="https://discourse.pi-hole.net/t/how-do-i-configure-my-devices-to-use-pi-hole-as-their-dns-server/245">DNS</a> server</li><li>A <a href="https://discourse.pi-hole.net/t/how-do-i-use-pi-holes-built-in-dhcp-server-and-why-would-i-want-to/3026">DHCP</a> server</li><li>A <a href="https://en.wikipedia.org/wiki/DNS_sinkhole">DNS</a> sinkhole</li><li>Probably something else… a <a href="https://www.thepieholela.com/">Pie</a> maybe? :)</li></ul><p>I’m using Pihole to:</p><ul><li>Filter ads and other unwanted traffic on my network</li><li>DNS cache</li></ul><p>To add a Nomad job for Pihole server, repeat the same steps as for Gitea server, the only difference being, we will use Docker <a href="https://www.nomadproject.io/docs/drivers/docker/#mounts">bind mounts</a> instead of <a href="https://learn.hashicorp.com/nomad/stateful-workloads/host-volumes">host volumes</a>; There was a reason, why I didn’t use host volumes for Pihole server, but I forgot it :)<br>I assume, Nomad host volumes should work fine with Pihole.</p><ul><li>Add the following to pihole/job.nomad:</li></ul><pre>job &quot;pihole&quot; {<br>  region = &quot;global&quot;</pre><pre>datacenters = [<br>    &quot;lan0&quot;,<br>  ]</pre><pre>type = &quot;service&quot;</pre><pre>group &quot;svc&quot; {<br>    count = 1</pre><pre>restart {<br>      attempts = 5<br>      delay    = &quot;15s&quot;<br>    }</pre><pre>task &quot;app&quot; {<br>      driver = &quot;docker&quot;</pre><pre>config {<br>        image = &quot;pihole/pihole:latest&quot;</pre><pre>mounts = [<br>          {<br>            type     = &quot;bind&quot;<br>            target   = &quot;/etc/pihole&quot;<br>            source   = &quot;/mnt/storage/nomad/data/pihole/pihole&quot;<br>            readonly = false<br>          },<br>          {<br>            type     = &quot;bind&quot;<br>            target   = &quot;/etc/dnsmasq.d&quot;<br>            source   = &quot;/mnt/storage/nomad/data/pihole/dnsmasq.d&quot;<br>            readonly = false<br>          },<br>        ]</pre><pre>port_map {<br>          dns  = 53<br>          http = 80<br>        }</pre><pre>dns_servers = [<br>          &quot;127.0.0.1&quot;,<br>          &quot;1.1.1.1&quot;,<br>        ]<br>      }</pre><pre>env = {<br>        &quot;TZ&quot;           = &quot;insert_your_timezone&quot;<br>        &quot;WEBPASSWORD&quot;  = &quot;insert_your_password&quot;<br>        &quot;DNS1&quot;         = &quot;insert_your_dns_server_ip&quot;<br>        &quot;DNS2&quot;         = &quot;no&quot;<br>        &quot;INTERFACE&quot;    = &quot;eth0&quot;<br>        &quot;VIRTUAL_HOST&quot; = &quot;insert_your_virtual_host_fqdn&quot;<br>        &quot;ServerIP&quot;     = &quot;insert_your_raspberry_pi_server_ip&quot;<br>      }</pre><pre>resources {<br>        cpu    = 100<br>        memory = 128</pre><pre>network {<br>          port &quot;dns&quot; {<br>            static = 53<br>          }</pre><pre>port &quot;http&quot; {}<br>        }<br>      }</pre><pre>service {<br>        name = &quot;pihole-gui&quot;<br>        port = &quot;http&quot;<br>      }<br>    }<br>  }<br>}</pre><ul><li>Run nomad plan job.nomad</li><li>You should see something like this:</li></ul><pre>+/- Job: &quot;pihole&quot;<br>+/- Stop: &quot;true&quot; =&gt; &quot;false&quot;<br>    Task Group: &quot;svc&quot; (1 create)<br>      Task: &quot;app&quot;</pre><pre>Scheduler dry-run:<br>- All tasks successfully allocated.</pre><pre>Job Modify Index: 50291<br>To submit the job with version verification run:</pre><pre>nomad job run -check-index 50291 job.nomad</pre><pre>When running the job with the check-index flag, the job will only be run if the<br>server side version matches the job modify index returned. If the index has<br>changed, another user has modified the job and the plan&#39;s results are<br>potentially invalid.</pre><ul><li>Run nomad run job.nomad</li><li>You should see something like this:</li></ul><pre>==&gt; Monitoring evaluation &quot;d92bfc68&quot;<br>    Evaluation triggered by job &quot;pihole&quot;<br>    Evaluation within deployment: &quot;d3896093&quot;<br>    Allocation &quot;b3bd095a&quot; created: node &quot;e79c2d81&quot;, group &quot;svc&quot;<br>    Evaluation status changed: &quot;pending&quot; -&gt; &quot;complete&quot;<br>==&gt; Evaluation &quot;d92bfc68&quot; finished with status &quot;complete&quot;</pre><ul><li>Open Nomad UI in web-browser, you should see pihole job allocation running:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rWxIBiR-fZSuBdrGc-ilUA.png" /></figure><ul><li>Press http link and it should redirect you to Pihole admin console:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bLxKEzsWV0z82qN38r0YcA.png" /></figure><ul><li>Login to the admin console using password specified in job.nomad file for Pihole Nomad task</li><li>Proceed to configure everything to your liking and enjoy using these awesome tools! :)</li></ul><p>UPDATE: 2020/05/26</p><h4>Ingress</h4><p>So, you’ve configured your Raspberry Pi, deployed Gitea and Pihole applications, your ex-girlfriend somehow found out about this and now wants to get back together :)</p><p>But, something is missing?<br>Fabulous DNS names for your services instead of cold-hard IP addresses and randomly-assigned ports!</p><p>To achieve this, you would need the following:</p><ul><li><a href="https://hub.docker.com/_/nginx">Nginx</a> container as a reverse-proxy</li><li>A couple of <a href="https://www.nomadproject.io/docs/job-specification/template/">Nomad</a>/<a href="https://github.com/hashicorp/consul-template">Consul</a> templates with required configuration</li><li>Fabulous DNS names configured on the router pointing to your Raspberry Pi</li></ul><p>Adding Nginx job is the same as adding Gitea and Pihole, with the execption that we’re going to be using Nomad/Consul templates for Nginx configuration:</p><ul><li>Create ingress and tpl directoies in /mnt/storage/nomad/jobs/</li><li>Create job.nomad file in /mnt/storage/nomad/jobs/ingress</li></ul><pre>user@raspberrypi:/mnt/storage/nomad&gt; tree -L 1 ingress/<br>ingress/<br>├── job.nomad<br>└── tpl</pre><ul><li>Add the following to ingress/tpl/nginx.conf.tpl:</li></ul><pre>user  nginx;<br>worker_processes  1;</pre><pre>error_log  /var/log/nginx/error.log warn;<br>pid        /var/run/nginx.pid;<br><br>events {<br>    worker_connections  1024;<br>}<br><br><br>http {<br>    include       /etc/nginx/mime.types;<br>    default_type  application/octet-stream;<br><br>    log_format  main  &#39;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &#39;<br>                      &#39;$status $body_bytes_sent &quot;$http_referer&quot; &#39;<br>                      &#39;&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;&#39;;<br><br>    access_log  /var/log/nginx/access.log  main;<br><br>    sendfile        on;<br><br>    keepalive_timeout  65;<br><br>    gzip  on;<br><br>    include /etc/nginx/conf.d/*.conf;<br>}</pre><ul><li>Add the following to ingress/tpl/proxy.conf.tpl:</li></ul><pre>server {<br>  listen 80;<br>  server_name git.example.lan;<br>  {{ range service &quot;gitea-gui&quot; }}<br>  set $upstream {{ .Address }}:{{ .Port }};<br>  {{ end }}<br>  location / {<br>            proxy_pass          http://$upstream;<br>            proxy_set_header    Host $host;<br>            proxy_set_header    X-Real-IP $remote_addr;<br>            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;<br>            proxy_set_header    X-Forwarded-Host $server_name;<br>            proxy_read_timeout  90;<br>  }<br>}<br><br>server {<br>  listen 80;<br>  server_name pihole.example.lan;<br>  {{ range service &quot;pihole-gui&quot; }}<br>  set $upstream {{ .Address }}:{{ .Port }};<br>  {{ end }}<br>  location / {<br>            proxy_pass          http://$upstream;<br>            proxy_set_header    Host $host;<br>            proxy_set_header    X-Real-IP $remote_addr;<br>            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;<br>            proxy_set_header    X-Forwarded-Host $server_name;<br>            proxy_read_timeout  90;<br>  }<br>}</pre><ul><li>Add the following to ingress/job.nomad:</li></ul><pre>job &quot;ingress&quot; {<br>  region = &quot;global&quot;<br><br>  datacenters = [<br>    &quot;lan0&quot;,<br>  ]<br><br>  type = &quot;service&quot;<br><br>  group &quot;svc&quot; {<br>    count = 1<br><br>    restart {<br>      attempts = 5<br>      delay    = &quot;15s&quot;<br>    }<br><br>    task &quot;app&quot; {<br>      driver = &quot;docker&quot;<br><br>      config {<br>        image = &quot;nginx:stable-alpine&quot;<br><br>        mounts = [<br>          {<br>            type   = &quot;bind&quot;<br>            target = &quot;/etc/nginx/nginx.conf&quot;<br>            source = &quot;local/ingress/nginx.conf&quot;<br>          },<br>          {<br>            type   = &quot;bind&quot;<br>            target = &quot;/etc/nginx/conf.d/proxy.conf&quot;<br>            source = &quot;local/ingress/proxy.conf&quot;<br>          },<br>        ]<br><br>        port_map {<br>          http = 80<br>        }<br>      }<br><br>      template {<br>        source        = &quot;/mnt/storage/nomad/jobs/ingress/tpl/nginx.conf.tpl&quot;<br>        destination   = &quot;local/ingress/nginx.conf&quot;<br>        change_mode   = &quot;signal&quot;<br>        change_signal = &quot;SIGINT&quot;<br>      }<br><br>      template {<br>        source        = &quot;/mnt/storage/nomad/jobs/ingress/tpl/proxy.conf.tpl&quot;<br>        destination   = &quot;local/ingress/proxy.conf&quot;<br>        change_mode   = &quot;signal&quot;<br>        change_signal = &quot;SIGINT&quot;<br>      }<br><br>      resources {<br>        cpu    = 100<br>        memory = 128<br><br>        network {<br>          port &quot;http&quot; {<br>            static = 80<br>          }<br>        }<br>      }<br><br>      service {<br>        name = &quot;ingress&quot;<br>        port = &quot;http&quot;<br>      }<br>    }<br>  }<br>}</pre><ul><li>After you’ve deployed ingress job to Nomad, you should be able to see nginx.conf.tpl and proxy.conf.tpl templates rendered to nginx.conf and proxy.conf in app/files/local tab in job allocation configuration screen:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iMu5dJ6JFxlWtbJUBT_fzg.png" /></figure><ul><li>You also can view rendered files using <a href="https://www.nomadproject.io/docs/commands/">Nomad CLI</a>:</li></ul><pre>user@raspberrypi:/mnt/storage/nomad/jobs/ingress # nomad alloc fs 6d722fd7 app/local/ingress/proxy.conf<br>server {<br>  listen 80;<br>  server_name git.example.lan;<br>  <br>  set $upstream 192.168.88.31:21127;<br>  <br>  location / {<br>            proxy_pass          http://$upstream;<br>            proxy_set_header    Host $host;<br>            proxy_set_header    X-Real-IP $remote_addr;<br>            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;<br>            proxy_set_header    X-Forwarded-Host $server_name;<br>            proxy_read_timeout  90;<br>  }<br>}<br><br>server {<br>  listen 80;<br>  server_name pihole.example.lan;<br>  <br>  set $upstream 192.168.88.31:30963;<br>  <br>  location / {<br>            proxy_pass          http://$upstream;<br>            proxy_set_header    Host $host;<br>            proxy_set_header    X-Real-IP $remote_addr;<br>            proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;<br>            proxy_set_header    X-Forwarded-Host $server_name;<br>            proxy_read_timeout  90;<br>  }<br>}</pre><ul><li>After nginx.conf and proxy.conf have been created, they are mounted inside the Nginx container as Docker bind-mounts.</li><li>Configure some DNS names for your services on your router and add them to proxy.conf.tpl</li><li>If needed, restart ingress Nomad job</li><li>Ingress service now should be ready to serve the applications</li><li>Have a piece of Pie to celebrate :)</li></ul><p>P.s<br>If you notice any typos or wrong information — ping me in the comments and I will update it. Thank you :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3f0d66c907" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/running-hashicorp-nomad-consul-pihole-and-gitea-on-raspberry-pi-3-b-f3f0d66c907">Running Hashicorp Nomad, Consul, Pihole and Gitea on Raspberry Pi 3 B+</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SSO-session failover with Keycloak and AWS S3]]></title>
            <link>https://medium.com/@georgijsr/sso-session-failover-with-keycloak-and-aws-s3-e0b1db985e12?source=rss-80353fb7ad97------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0b1db985e12</guid>
            <category><![CDATA[failover]]></category>
            <category><![CDATA[amazon-s3]]></category>
            <category><![CDATA[sso]]></category>
            <category><![CDATA[keycloak]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Georgijs Radovs]]></dc:creator>
            <pubDate>Sun, 11 Feb 2018 15:58:57 GMT</pubDate>
            <atom:updated>2018-02-11T15:58:57.870Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*fK7U56Q-MRzEkuWHmMRn1Q.png" /></figure><p>Hello, everyone!</p><p>As you may or may not know, <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server supports <a href="https://en.wikipedia.org/wiki/High_availability"><strong>High Availability</strong> </a>cluster configurations — <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/standalone-ha.html"><strong>Standalone Clustered mode</strong></a> and <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/domain.html"><strong>Domain clustered mode</strong></a>.</p><p>In this article, I’m going to describe <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/standalone-ha.html"><strong>Standalone Clustered mode</strong></a> setup.</p><p><a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/standalone-ha.html"><strong>Standalone Clustered</strong> <strong>mode</strong></a> is used in small <a href="https://en.wikipedia.org/wiki/Single_sign-on"><strong>SSO-environments</strong></a> with no more than 2–4 <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> servers running, because <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/standalone-ha.html"><strong>Standalone Clustered mode</strong></a> requires manual server configuration file management on each of the cluster nodes. For example, if you have at least 2 <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> servers running in your environment, then you’ll have to manually manage <strong>standalone-ha.xml</strong> configuration file on both servers.</p><p>If your environment, has no more than 2–4 <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> servers running, then <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/standalone-ha.html"><strong>Standalone Clustered mode</strong></a> will be easier to configure and deploy. If your environment is bigger, then I’d suggest, you configure <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/domain.html"><strong>Domain Clustered mode</strong></a>.</p><p>In <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/domain.html"><strong>Domain Clustered mode</strong></a>, you will have a <strong>Domain controller</strong>, which will distribute <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server configuration to a <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server group. I tried to configure <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/domain.html"><strong>Domain Clustered mode</strong></a> in my environment, but I failed =)<br>If you would like to try <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/domain.html"><strong>Domain Clustered mode</strong></a>, please refer to <a href="http://www.keycloak.org/docs/3.3/server_installation/topics/operating-mode/domain.html"><strong>Keycloak</strong></a> and <a href="https://docs.jboss.org/author/display/WFLY10/Clustering+and+Domain+Setup+Walkthrough"><strong>Wildfly10 documentation</strong></a> on this topic</p><p>So, let’s start with <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/standalone-ha.html"><strong>Standalone Clustered mode</strong></a> setup.</p><p>If your environment is running in <a href="https://aws.amazon.com/"><strong>AWS</strong></a> cloud or other environment, where multicast is not supported, default <a href="https://docs.jboss.org/author/display/WFLY10/JGroups+Subsystem"><strong>JGroups</strong></a> configuration will not work, <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> servers won’t be able to communicate with each other.</p><p>One of the possible ways to resolve this is to use <a href="https://developer.jboss.org/wiki/JGroupsS3PING?_sscc=t"><strong>S3_PING</strong></a> protocol and <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>AWS S3</strong></a> service.</p><p>A quote from<strong> </strong><a href="http://www.jgroups.org/manual/html/protlist.html#d0e5330"><strong>jgroups.org</strong></a> about what is <a href="http://www.jgroups.org/manual/html/protlist.html#d0e5330"><strong>S3_PING</strong></a>:</p><blockquote><a href="http://www.jgroups.org/manual/html/protlist.html#d0e5330"><strong>S3_PING</strong></a> uses <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>Amazon S3</strong></a> to discover initial members. New joiners read all addresses from this bucket and ping each of the elements of the resulting set of members. When a member leaves, it deletes its corresponding file.</blockquote><blockquote>It’s designed specifically for members running on <a href="https://aws.amazon.com/ec2/?hp=tile&amp;so-exp=below"><strong>Amazon EC2</strong></a>, where multicast traffic is not allowed and thus <a href="http://www.jgroups.org/manual/html/protlist.html#MPING"><strong>MPING</strong></a> or <a href="http://www.jgroups.org/manual/html/protlist.html#PING"><strong>PING</strong></a> will not work. When <a href="https://aws.amazon.com/rds/?nc2=h_l3_db"><strong>Amazon RDS</strong></a><strong> </strong>is preferred over <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a>, or if a shared database is used, an alternative is to use <a href="http://www.jgroups.org/manual/html/protlist.html#d0e5196"><strong>JDBC_PING</strong></a>.</blockquote><blockquote>Each instance uploads a small file to an <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> bucket and each instance reads the files out of this bucket to determine the other members.</blockquote><p>So, basically, you need to have a <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>AWS S3</strong></a> bucket where <a href="https://en.wikipedia.org/wiki/Single_sign-on"><strong>SSO-session</strong></a> files will be stored, and your <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> servers configured to use <a href="http://www.jgroups.org/manual/html/protlist.html#d0e5330"><strong>S3_PING</strong></a> pointed at the bucket to read the <a href="https://en.wikipedia.org/wiki/Single_sign-on"><strong>SSO-session</strong></a> file from.</p><h3><strong>AWS S3 Configuration</strong></h3><p>To create and configure <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>AWS S3</strong></a> bucket, please, refer to <a href="https://docs.aws.amazon.com/AmazonS3/latest/gsg/CreatingABucket.html"><strong>AWS S3</strong> <strong>documentation</strong></a></p><p>There are multiple ways, how you can configure <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>AWS S3</strong></a> bucket access.<br>Again, a quote from <a href="http://www.jgroups.org/manual/html/protlist.html#d0e5330"><strong>jgroups.org</strong></a>:</p><blockquote>Private buckets, Amazon <a href="https://aws.amazon.com/?nc2=h_lg"><strong>AWS</strong></a> credentials given to each instance</blockquote><blockquote>Public readable and writable buckets, no credentials given to each instance</blockquote><blockquote>Public readable but private writable buckets, pre-signed URLs given to each instance</blockquote><p>In this article, I’m going to describe how to configure private buckets with <a href="https://aws.amazon.com/?nc2=h_lg"><strong>AWS</strong></a> credentials on each instance.</p><p>When you create a new <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> bucket, it should be private by default:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*j0WPa5gSMbiofRXXS6V6mA.png" /><figcaption>s3-ping-keycloak-example-com</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*N9hDa4FNcWJAjsODPZp9eQ.png" /><figcaption>S3 bucket public permissions disabled</figcaption></figure><p>With <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> bucket created, you will need to create a <a href="https://aws.amazon.com/iam/?hp=tile&amp;so-exp=below"><strong>IAM</strong></a> user, which will have Read/Write access to the previously created <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> bucket.</p><p>To create a <a href="https://aws.amazon.com/iam/?hp=tile&amp;so-exp=below"><strong>IAM</strong></a> user, do the following:</p><ul><li>Login to <a href="https://console.aws.amazon.com/"><strong>AWS console</strong></a> and go to <a href="https://aws.amazon.com/iam/?hp=tile&amp;so-exp=below"><strong>IAM Managemen Console</strong></a></li><li>In <a href="https://aws.amazon.com/iam/?hp=tile&amp;so-exp=below"><strong>IAM console</strong></a>, go to <strong>Users </strong>and create a user for <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> bucket access</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*4mFNDTXwjfVCs9AVIDdN9g.png" /><figcaption>User creation for Keycloak to use S3_PING</figcaption></figure><ul><li>Create Access keys for <strong>keycloak_s3_ping_user</strong>, so <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server can access <a href="https://aws.amazon.com/?nc2=h_lg"><strong>AWS</strong></a> using this user</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/968/1*r4hVvEOPiXZvpuX1N1eM0Q.png" /></figure><p>With <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> bucket and user created, you will need to create and attach a <a href="https://aws.amazon.com/iam/?hp=tile&amp;so-exp=below"><strong>IAM</strong></a> policy to this user, so he can access the <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> bucket:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/939/1*AktPdgNJICnZEFmcsA66XQ.png" /><figcaption>keycloak_s3_ping_user permissions</figcaption></figure><p>And here is the <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> bucket access policy:</p><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:GetObjectVersion&quot;,<br>                &quot;s3:DeleteObject&quot;,<br>                &quot;s3:DeleteObjectVersion&quot;,<br>                &quot;s3:GetObject&quot;,<br>                &quot;s3:PutObject&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::s3-ping-keycloak-example-com/*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:ListBucketVersions&quot;,<br>                &quot;s3:ListBucket&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:s3:::s3-ping-keycloak-example-com&quot;<br>        }<br>    ]<br>}</pre><p>After the <a href="https://aws.amazon.com/iam/?hp=tile&amp;so-exp=below"><strong>IAM</strong></a> user and <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> bucket have been created, <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> policy attached, and access keys configured — it is time to configure <a href="http://www.jgroups.org/manual/html/protlist.html#d0e5330"><strong>S3_PING</strong></a> on the <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server!</p><h3>Keycloak configuration</h3><ul><li>SSH-login to your <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server and change directory to where your <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server is installed, to configuration directory which contains standalone-ha.xml file:</li></ul><pre>ssh user@keycloak.example.com<br>cd [keycloak_install_dir]/standalone/configuration<br>vim standalone-ha.xml</pre><p>This file contains the usual <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server configuration with the addition of <strong>WildFly10</strong> <a href="https://en.wikipedia.org/wiki/High_availability"><strong>High Availability</strong></a> extensions like <a href="https://docs.jboss.org/author/display/WFLY10/Infinispan+Subsystem"><strong>Infinispan HA cache</strong></a> and <a href="https://docs.jboss.org/author/display/WFLY10/JGroups+Subsystem"><strong>JGroups HA communication channels</strong></a> and their configuration settings.</p><ul><li>Open standalone-ha.xml file in a text editor, and find the line which starts with &lt;subsystem xmlns=&quot;urn:jboss:domain:jgroups:4.0&quot;&gt;</li></ul><p>This subsystem block contains configuration for <a href="https://docs.jboss.org/author/display/WFLY10/JGroups+Subsystem"><strong>Wildfly10 JGroups </strong></a>functionality, in which we are going to enable <a href="http://www.jgroups.org/manual/html/protlist.html#d0e5330"><strong>S3_PING</strong></a>.</p><p>By default it should look something like this:</p><pre>&lt;subsystem xmlns=&quot;urn:jboss:domain:jgroups:4.0&quot;&gt;<br>            &lt;channels default=&quot;ee&quot;&gt;<br>                &lt;channel name=&quot;ee&quot; stack=&quot;tcp&quot;/&gt;<br>            &lt;/channels&gt;<br>            &lt;stacks&gt;<br>                &lt;stack name=&quot;udp&quot;&gt;<br>                    &lt;transport type=&quot;UDP&quot; socket-binding=&quot;jgroups-udp&quot; site=&quot;example.com&quot; machine=&quot;keycloak.example.com&quot;/&gt;<br>                    &lt;protocol type=&quot;PING&quot;/&gt;<br>                    &lt;protocol type=&quot;MERGE3&quot;/&gt;<br>                    &lt;protocol type=&quot;FD_SOCK&quot; socket-binding=&quot;jgroups-udp-fd&quot;/&gt;<br>                    &lt;protocol type=&quot;FD_ALL&quot;/&gt;<br>                    &lt;protocol type=&quot;VERIFY_SUSPECT&quot;/&gt;<br>                    &lt;protocol type=&quot;pbcast.NAKACK2&quot;/&gt;<br>                    &lt;protocol type=&quot;UNICAST3&quot;/&gt;<br>                    &lt;protocol type=&quot;pbcast.STABLE&quot;/&gt;<br>                    &lt;protocol type=&quot;pbcast.GMS&quot;/&gt;<br>                    &lt;protocol type=&quot;UFC&quot;/&gt;<br>                    &lt;protocol type=&quot;MFC&quot;/&gt;<br>                    &lt;protocol type=&quot;FRAG2&quot;/&gt;<br>                &lt;/stack&gt;<br>                &lt;stack name=&quot;tcp&quot;&gt;<br>                    &lt;transport type=&quot;TCP&quot; socket-binding=&quot;jgroups-tcp&quot; site=&quot;example.com&quot; machine=&quot;keycloak.example.com&quot;/&gt;<br>                   &lt;protocol type=&quot;MPING&quot; socket-binding=&quot;jgroups-mping&quot;/&gt;<br>                   &lt;protocol type=&quot;MERGE3&quot;/&gt;<br>                    &lt;protocol type=&quot;FD_SOCK&quot; socket-binding=&quot;jgroups-tcp-fd&quot;/&gt;<br>                    &lt;protocol type=&quot;FD&quot;/&gt;<br>                    &lt;protocol type=&quot;VERIFY_SUSPECT&quot;/&gt;<br>                    &lt;protocol type=&quot;pbcast.NAKACK2&quot;/&gt;<br>                    &lt;protocol type=&quot;UNICAST3&quot;/&gt;<br>                    &lt;protocol type=&quot;pbcast.STABLE&quot;/&gt;<br>                    &lt;protocol type=&quot;pbcast.GMS&quot;/&gt;<br>                    &lt;protocol type=&quot;MFC&quot;/&gt;<br>                    &lt;protocol type=&quot;FRAG2&quot;/&gt;<br>                &lt;/stack&gt;<br>            &lt;/stacks&gt;<br>        &lt;/subsystem&gt;</pre><p>To enable <a href="http://www.jgroups.org/manual/html/protlist.html#d0e5330"><strong>S3_PING</strong></a>, we need to edit tcp stack:</p><pre>&lt;subsystem xmlns=&quot;urn:jboss:domain:jgroups:4.0&quot;&gt;<br>            &lt;channels default=&quot;ee&quot;&gt;<br>                &lt;channel name=&quot;ee&quot; stack=&quot;tcp&quot;/&gt;<br>            &lt;/channels&gt;<br>            &lt;stacks&gt;<br>                &lt;stack name=&quot;tcp&quot;&gt;<br>                    &lt;transport type=&quot;TCP&quot; socket-binding=&quot;jgroups-tcp&quot; site=&quot;example.com&quot; machine=&quot;keycloak.example.com&quot;/&gt;<br>                   &lt;protocol type=&quot;MPING&quot; socket-binding=&quot;jgroups-mping&quot;/&gt;<br>                   &lt;protocol type=&quot;MERGE3&quot;/&gt;<br>                    &lt;protocol type=&quot;FD_SOCK&quot; socket-binding=&quot;jgroups-tcp-fd&quot;/&gt;<br>                    &lt;protocol type=&quot;FD&quot;/&gt;<br>                    &lt;protocol type=&quot;VERIFY_SUSPECT&quot;/&gt;<br>                    &lt;protocol type=&quot;pbcast.NAKACK2&quot;/&gt;<br>                    &lt;protocol type=&quot;UNICAST3&quot;/&gt;<br>                    &lt;protocol type=&quot;pbcast.STABLE&quot;/&gt;<br>                    &lt;protocol type=&quot;pbcast.GMS&quot;/&gt;<br>                    &lt;protocol type=&quot;MFC&quot;/&gt;<br>                    &lt;protocol type=&quot;FRAG2&quot;/&gt;<br>                &lt;/stack&gt;<br>            &lt;/stacks&gt;<br>        &lt;/subsystem&gt;</pre><ul><li>All you have to do is add new protocol block:</li></ul><pre>&lt;protocol type=”S3_PING”&gt;<br>      &lt;property name=”access_key”&gt;<br>          keycloak_s3_ping_user AWS IAM access key<br>      &lt;/property&gt;<br>      &lt;property name=”secret_access_key”&gt;<br>          keycloak_s3_ping_user AWS IAM secret key<br>      &lt;/property&gt;<br>      &lt;property name=”location”&gt;<br>          s3-ping-keycloak-example-com &lt;-- AWS S3 bucket name<br>      &lt;/property&gt;<br>&lt;/protocol&gt;</pre><ul><li>So now, tcp stack with <a href="http://www.jgroups.org/manual/html/protlist.html#d0e5330"><strong>S3_PING</strong></a> added should look like this:</li></ul><pre>&lt;stack name=&quot;tcp&quot;&gt;<br>    &lt;transport type=&quot;TCP&quot; socket-binding=&quot;jgroups-tcp&quot; site=&quot;example.com&quot; machine=&quot;keycloak.example.com&quot;/&gt;<br>    &lt;protocol type=&quot;MPING&quot; socket-binding=&quot;jgroups-mping&quot;/&gt;<br><strong>       &lt;protocol type=”S3_PING”&gt;<br>           &lt;property name=”access_key”&gt;<br>               keycloak_s3_ping_user AWS IAM access key<br>           &lt;/property&gt;<br>           &lt;property name=”secret_access_key”&gt;<br>               keycloak_s3_ping_user AWS IAM secret key<br>           &lt;/property&gt;<br>           &lt;property name=”location”&gt;<br>               s3-ping-keycloak-example-com<br>           &lt;/property&gt;<br>       &lt;/protocol&gt;</strong><br>       &lt;protocol type=&quot;MERGE3&quot;/&gt;<br>       &lt;protocol type=&quot;FD_SOCK&quot; socket-binding=&quot;jgroups-tcp-fd&quot;/&gt;<br>       &lt;protocol type=&quot;FD&quot;/&gt;<br>       &lt;protocol type=&quot;VERIFY_SUSPECT&quot;/&gt;<br>       &lt;protocol type=&quot;pbcast.NAKACK2&quot;/&gt;<br>       &lt;protocol type=&quot;UNICAST3&quot;/&gt;<br>       &lt;protocol type=&quot;pbcast.STABLE&quot;/&gt;<br>       &lt;protocol type=&quot;pbcast.GMS&quot;/&gt;<br>       &lt;protocol type=&quot;MFC&quot;/&gt;<br>       &lt;protocol type=&quot;FRAG2&quot;/&gt;<br>&lt;/stack&gt;</pre><ul><li>Save and close standalone-ha.xml file.</li></ul><p>To test new configuration, you can run <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server in foreground:</p><ul><li>cd to standalone/bin directory:</li></ul><p>user@keycloak_server_fqdn:~ cd /opt/keycloak-3.0.0.Final/bin</p><ul><li>Execute standalone.sh script with standalone-ha.xml file:</li></ul><p>./standalone.sh -c standalone-ha.xml</p><p>When <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server starts, you should see something like this in the output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2VT10O5pVP2V3yK7QiMYNw.png" /><figcaption>Keycloak running in foreground with <strong>JGroups</strong> enabled</figcaption></figure><p>Notice, there is only one <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server detected - keycloak.example.com</p><p>Also, s3-ping-keycloak-example-com <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> bucket should contain something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*Zl8hNm6h9CkDO7AnppuaCw.png" /></figure><p>Inside the s3-ping-keycloak-example-com bucket, there should be ee directory which is used by ee stack configuration from standalone-ha.xml:</p><pre>&lt;channels default=&quot;ee&quot;&gt;<br>    &lt;channel name=&quot;ee&quot; stack=&quot;tcp&quot;/&gt;<br>&lt;/channels&gt;</pre><p>Inside ee directory, there should be a .list file or files, containing information about <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/standalone-ha.html#"><strong>Keycloak HA-cluster</strong></a> members:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/987/1*jqK9BSNXy8fTiRMrr96_Xw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*WX-v44Q0qBm47C10D--KXQ.png" /></figure><p>These text files, are used by <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> to keep track of the <a href="http://www.keycloak.org/docs/3.0/server_installation/topics/operating-mode/standalone-ha.html#"><strong>Keycloak HA-cluster</strong></a> members, which will pick up <a href="https://en.wikipedia.org/wiki/Single_sign-on"><strong>SSO-sessions</strong></a> from <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> servers that went offline.</p><p>So, <a href="https://aws.amazon.com/s3/?hp=tile&amp;so-exp=below"><strong>S3</strong></a> bucket and the first <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server is configured for <a href="https://en.wikipedia.org/wiki/Single_sign-on"><strong>SSO-session</strong></a> failover. Now, it is time to add a second <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server!</p><p>Edit standalone-ha.xml file on the second <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server the same way as the first <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server. Now, assuming your first <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server is still running in foreground — launch the second <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server and watch the output of the first <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> server:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cj9trGnqd3Ws9I2t4JeSMQ.png" /><figcaption>Had to truncate the output because it would not fit the screen</figcaption></figure><p>As you can see, keycloak2.example.com has joined the party =)</p><p>And here is what happens, when keycloak.example.com left the party =( :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A35TKaOwm0MCNaEDojiFyw.png" /></figure><p>Now, you can create a scenario where one of the <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> servers goes offline, and test if the <a href="https://en.wikipedia.org/wiki/Single_sign-on"><strong>SSO-session</strong></a> failover works as expected.</p><p>Thank you for reading this lenghty article, I hope it will be of some use to you. If you notice any mistakes or incorrect information — please, write in the comments and I will update it.</p><p>May the Gods give you strenght and provide wisdom.<br><a href="https://media2.giphy.com/media/IL4iTvQH0MjS/giphy.gif">Live long and prosper</a>! =)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0b1db985e12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FreeRADIUS (2.1.12, Ubuntu 14.04) server with LDAP authentication and LDAP fail-over.]]></title>
            <link>https://medium.com/@georgijsr/freeradius-2-1-12-ubuntu-14-04-server-with-ldap-authentication-and-ldap-fail-over-6611624ff2c9?source=rss-80353fb7ad97------2</link>
            <guid isPermaLink="false">https://medium.com/p/6611624ff2c9</guid>
            <category><![CDATA[freeipa]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[ldap]]></category>
            <category><![CDATA[freeradius]]></category>
            <dc:creator><![CDATA[Georgijs Radovs]]></dc:creator>
            <pubDate>Sun, 16 Apr 2017 18:17:24 GMT</pubDate>
            <atom:updated>2024-08-26T16:10:43.329Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Es5VnOhPzeHp3CUDZkH-bQ.png" /></figure><p>Hello again.</p><p>This post will be about the exciting process of setting up <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> server with <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> authentication and <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> <strong>server failover</strong>.</p><p>Some time ago, I had a project to upgrade company’s WiFi network with <a href="https://en.wikipedia.org/wiki/RADIUS"><strong>RADIUS</strong></a> authentication.</p><p>As soon as the time frame for the project has been approved and requirements for completion set, the project began.</p><h3><strong>Part One:</strong> <a href="https://en.wikipedia.org/wiki/RADIUS"><strong>RADIUS</strong></a></h3><p>If you ever have the need to set up a <a href="https://en.wikipedia.org/wiki/RADIUS"><strong>RADIUS</strong></a> server, the obvious choice for this is <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a>.</p><p>Why is it the obvious choice?</p><p>Here’s quote from <a href="http://freeradius.org/"><strong>freeradius.org</strong></a>:</p><blockquote>FreeRADIUS is the <a href="http://freeradius.org/press/survey.html">most widely deployed</a> RADIUS server in the world. It is the basis for multiple commercial offerings. It supplies the AAA needs of many Fortune-500 companies and Tier 1 ISPs.</blockquote><p>And it’s open source, so a win by default :)</p><p>So, let’s start!</p><h4><a href="http://freeradius.org/">FreeRADIUS</a> packages install</h4><p>This part of the guide is based on <strong>freeradius 2.1.12+dfsg-1.2ubuntu8.1 </strong>packages from <a href="https://www.ubuntu.com/"><strong>Ubuntu</strong></a><strong> 14.04</strong>, because that is what was available at the time and, why not? :)</p><p>After you have your <a href="https://www.ubuntu.com/"><strong>Ubuntu</strong></a><strong> 14.04</strong> environment up and running, install the following packages:</p><p><strong>$ sudo apt install freeradius</strong></p><p><strong>$ sudo apt install freeradius-ldap</strong></p><p><strong>freeradius</strong> is the server itself, and <strong>freeradius-ldap</strong>, you guessed it correctly —the <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> module! :)</p><p>After the packages have been installed, proceed to server setup.</p><h4><a href="http://freeradius.org/">FreeRADIUS</a> setup and configuration</h4><p>For all you awesome <a href="https://en.wikipedia.org/wiki/Sysop"><strong>SysOps</strong></a> <a href="https://media3.giphy.com/media/v1.Y2lkPTc5MGI3NjExZjZoZWhyMDRjMDYxd2J1MHd4MDdxcHJ3a25mM292Zm85cjhjMjVheCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/dbtDDSvWErdf2/giphy.webp">guys</a> and <a href="https://media.giphy.com/media/nj0XPti0kpg5i/giphy.gif">girls</a> who will jump straight into plowing through config files and deleting important information like comments, unused functionality and punctuation marks, here’s a quote/warning from <a href="https://wiki.freeradius.org/guide/Basic-configuration-HOWTO"><strong>wiki.freeradius.org</strong></a>:</p><blockquote>“Always start with the “default” configuration. It will work everywhere, and do almost everything you need. The only change you will need to make is to define users and passwords.</blockquote><blockquote>Making a lot of changes to the configuration files is the best way to break the server. Don’t do that.”</blockquote><p>I myself did not abide by this warning the first time, so I spent a couple of extra hours “debugging” my own awesomeness that I’ve done. :)</p><p>Anyway, let’s start configuring <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> authentication in <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a>!</p><p>You’ll need to edit the following files:</p><p><strong>clients.conf</strong> (/etc/freeradius/clients.conf) — here you define your “clients” (Access points, routers etc.)</p><p>For example:</p><pre>client %router_name% {<br>ipaddr = %router_ip%<br>secret = %router_password%<br>limit {<br>max_connections = 50<br>lifetime = 0<br>idle_timeout = 30<br>  }<br>}</pre><p><strong>radiusd.conf</strong> (/etc/freeradius/radiusd.conf) — main <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> config file.</p><p>This LOOONG text file contains all the possible settings, like working directories, <strong>freeradius</strong> process user/group, library/module includes etc.</p><p>In most cases, default settings in <strong>radiusd.conf</strong> work well and you should not tinker with them without a good reason.</p><p><a href="https://wiki.freeradius.org/modules/Rlm_ldap"><strong>ldap</strong></a> (/etc/freeradius/modules/ldap) — this file contains settings for <a href="https://wiki.freeradius.org/modules/Rlm_ldap"><strong>ldap</strong></a> module and settings to connect to <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> directory.</p><p>For example:</p><pre>ldap {<br> server = %ldap_server_fqdn%<br> port = %ldap_server_port%<br> identity = “uid=%bind_user%,cn=users,cn=accounts,dc=example,dc=com”<br> password = %bind_user_password%<br> basedn = “cn=users,cn=accounts,dc=example,dc=com”<br> filter = “(uid=%{%{Stripped-User-Name}:-%{User-Name}})”<br> authtype = ldap<br> groupname_attribute = cn<br> groupmembership_filter = “(|(&amp;(objectClass=GroupOfNames)(member=%{Ldap-UserDn}))(&amp;(objectClass=GroupOfUniqueNames)(uniquemember=%{Ldap-UserDn})))”<br> dictionary_mapping = ${raddbdir}/ldap.attrmap<br> set_auth_type = yes<br> auto_header = yes<br> password_header = “{ssha}”<br> password_attribute = userPassword</pre><pre>}</pre><p>Site configuration file in <strong>/etc/freeradius/sites-enabled</strong></p><p>In <strong>sites-enabled</strong> you should have 2 config files:</p><pre>inner-tunnel</pre><pre>%site_name%</pre><p><a href="http://networkradius.com/doc/3.0.10/raddb/sites-available/inner-tunnel.html"><strong>inner-tunnel</strong></a> is a virtual server and handles <strong>only</strong> inner tunnel requests for <a href="https://en.wikipedia.org/wiki/Extensible_Authentication_Protocol#EAP_Tunneled_Transport_Layer_Security_.28EAP-TTLS.29"><strong>EAP-TTLS</strong></a> and <a href="https://en.wikipedia.org/wiki/Protected_Extensible_Authentication_Protocol"><strong>PEAP</strong></a> types. We won’t be using these protocols, so leave this file at it’s defaults.</p><p><a href="https://wiki.freeradius.org/config/Virtual-server"><strong>%site-name%</strong></a> — in this file you define your virtual host.</p><p>If you ever had to configure <a href="https://www.nginx.com/"><strong>nginx</strong></a> web server <a href="https://www.nginx.com/resources/wiki/start/topics/examples/server_blocks/"><strong>virtual hosts</strong></a>, you’ll see the similarities and similar configuration principals.</p><p>This file is heavily commented and has multiple configuration sections.</p><p>For <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> authentication to work, you should checkout <strong>Authorize</strong> and <strong>Authenticate</strong> sections.</p><blockquote><strong>Authorize</strong></blockquote><p>In this section, make sure the <a href="https://en.wikipedia.org/wiki/MS-CHAP"><strong>mschap</strong></a> option is not commented out.</p><p><a href="https://en.wikipedia.org/wiki/MS-CHAP"><strong>mschap</strong></a> protocol will be used in authentication requests from <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> user accounts.</p><blockquote><strong>Authenticate</strong></blockquote><p>In this section, make sure the <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> option is not commented out:</p><pre>Auth-Type LDAP {<br> ldap <br> }</pre><p><a href="https://wiki.freeradius.org/modules/Rlm_ldap"><strong>ldap</strong></a> is a refrence to <a href="https://wiki.freeradius.org/modules/Rlm_ldap"><strong>ldap</strong></a> module configuration in /etc/freeradius/modules.</p><p><a href="https://wiki.freeradius.org/modules/Rlm_ldap#user-profile-attribute"><strong>ldap.attrmap</strong></a> (/etc/freeradius/ldap.attrmap) — in this file you map <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> attributes to <a href="https://en.wikipedia.org/wiki/RADIUS"><strong>RADIUS</strong></a> dictionary attributes.</p><p>For example:</p><pre>checkItem Auth-Type radiusAuthType<br>checkItem User-Password userPassword<br>checkItem Simultaneous-Use radiusSimultaneousUse<br>checkItem Called-Station-Id radiusCalledStationId<br>checkItem Calling-Station-Id radiusCallingStationId<br>checkItem LM-Password lmPassword<br>checkItem LM-Password ipaNThash<br>checkItem NT-Password ipaNThash<br>checkItem NT-Password ntPassword<br>checkItem LM-Password sambaLmPassword<br>checkItem NT-Password sambaNtPassword<br>checkItem LM-Password dBCSPwd<br>checkitem Password-With-Header userPassword<br>checkItem SMB-Account-CTRL-TEXT acctFlags<br>checkItem Expiration radiusExpiration<br>checkItem NAS-IP-Address radiusNASIpAddress</pre><p>Initial <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> server configuration is complete.</p><h3>Part Two: <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol">LDAP</a> setup</h3><p><a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> setup guide will be based on <a href="http://directory.fedoraproject.org/"><strong>389 Directory Server</strong></a> as a part of <a href="https://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> server.</p><p>Of course, you can use a standalone <a href="http://directory.fedoraproject.org/"><strong>389 Directory Server</strong></a>, but using <a href="https://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> is easier and more efficient.</p><h4>Bind user setup</h4><p>For <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> to be able to communicate with <a href="http://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> server and retrieve user account information, you’ll need to set up a bind user.</p><p>Log in to your <a href="http://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> server, create a new user for <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a>, for example: <strong>uid=freeradius.bind,cn=users,cn=accounts,dc=example,dc=com</strong>, then <a href="https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Linux_Domain_Identity_Authentication_and_Policy_Guide/defining-roles.html">create new or use existing role/privilege/permission policies</a>, so this user can read attributes from <strong>cn=users,cn=accounts,dc=example,dc=com</strong> and <strong>cn=groups,cn=accounts,dc=example,dc=com</strong> containers, and assign those policies to the newly created bind user.</p><h4>EAP-MSCHAPv2 setup</h4><p><a href="https://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> stores user account passwords in <a href="https://en.wikipedia.org/wiki/Secure_Hash_Algorithms"><strong>SSHA</strong></a> form, so they can’t be used with <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> module and <a href="https://en.wikipedia.org/wiki/Password_Authentication_Protocol"><strong>PAP</strong></a> protocol which supports only clear-text passwords.</p><p>For <a href="http://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> user accounts to be able to authenticate with <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> server, in this guide, we’ll use <a href="https://en.wikipedia.org/wiki/Protected_Extensible_Authentication_Protocol#PEAPv0_with_EAP-MSCHAPv2"><strong>EAP-MSCHAPv2</strong></a> protocol, but for this to work, we need to generate some <a href="https://en.wikipedia.org/wiki/NT_LAN_Manager"><strong>NTLM</strong></a> password hashes for <a href="https://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> user accounts.</p><p>To generate additional <a href="https://en.wikipedia.org/wiki/NT_LAN_Manager"><strong>NTLM</strong></a> password hashes for <a href="http://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> user accounts, do the following:</p><blockquote>log in to your <a href="https://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> server</blockquote><blockquote>install <strong>ipa-server-trust-ad</strong> package</blockquote><blockquote>run <strong>ipa-adtrust-install</strong> command</blockquote><p><a href="https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Windows_Integration_Guide/active-directory-trust.html"><strong>ipa-adtrust-install</strong></a> command will create a new attribute for <a href="https://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> user accounts — <strong>ipaNThash</strong>.</p><p>This attribute will contain <a href="https://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> user account’s password in <a href="https://en.wikipedia.org/wiki/NT_LAN_Manager"><strong>NTLM</strong></a> hash.</p><p>To generate <a href="https://en.wikipedia.org/wiki/NT_LAN_Manager"><strong>NTLM</strong></a> hash, each user needs to reset his/hers password.</p><p>After <a href="https://en.wikipedia.org/wiki/NT_LAN_Manager"><strong>NTLM</strong></a> hashes have been generated, you can try to authenticate in <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> using <a href="https://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> user account’s credentials</p><p>For testing purposes, I recommend to run <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> server in debug mode, like this:</p><pre>freeradius -X</pre><p>After server has been started, run this command to test user authentication:</p><pre>radtest -t mschap %user_name% %user_password% localhost 1812 %nas_password%</pre><p>If your user does not have <strong>ipaNThash</strong> attribute, you’ll see something like this:</p><pre>[mschap] No Cleartext-Password configured. Cannot create LM-Password.<br>[mschap] No Cleartext-Password configured. Cannot create NT-Password.<br>[mschap] Told to do MS-CHAPv1 with NT-Password<br>[mschap] FAILED: No NT/LM-Password. Cannot perform authentication.<br>[mschap] MS-CHAP-Response is incorrect.<br>++[mschap] returns reject<br>Failed to authenticate the user.</pre><p>But, if your user does have <strong>ipaNThash</strong> attribute and it contains <a href="https://en.wikipedia.org/wiki/NT_LAN_Manager"><strong>NTLM</strong></a><strong> </strong>password<strong> </strong>hash, you should see something like this:</p><pre>[ldap1] performing user authorization for %user_name%<br>[ldap1] expand: %{Stripped-User-Name} -&gt; <br>[ldap1] … expanding second conditional<br>[ldap1] expand: %{User-Name} -&gt; %user_name%<br>[ldap1] expand: (uid=%{%{Stripped-User-Name}:-%{User-Name}}) -&gt; (uid=%user_name%)<br>[ldap1] expand: cn=users,cn=accounts,dc=example,dc=com -&gt; cn=users,cn=accounts,dc=example,dc=com<br> [ldap1] ldap_get_conn: Checking Id: 0<br> [ldap1] ldap_get_conn: Got Id: 0<br> [ldap1] attempting LDAP reconnection<br> [ldap1] (re)connect to %ldap_server_fqdn%:%ldap_port%, authentication 0<br> [ldap1] setting TLS mode to 1<br> [ldap1] setting TLS CACert File to %ca_cert%<br> [ldap1] bind as uid=%bind_user%,cn=users,cn=accounts,dc=example,dc=com/%bind_password% to %ldap_server%:%ldap_port%<br> [ldap1] waiting for bind result …<br> [ldap1] Bind was successful<br> [ldap1] performing search in cn=users,cn=accounts,dc=example,dc=com, with filter (uid=%bind_user%)<br>[ldap1] Added SSHA1-Password = %ssha_password% == in check items<br>[ldap1] No default NMAS login sequence<br>[ldap1] looking for check items in directory…<br> [ldap1] userPassword -&gt; Password-With-Header == “%ssha_password%”<br> [ldap1] ipaNThash -&gt; NT-Password == %nt_hash%<br> [ldap1] ipaNThash -&gt; LM-Password == %lm_hash%<br> [ldap1] userPassword -&gt; User-Password == %ssha_password%<br>[ldap1] looking for reply items in directory…<br>[ldap1] user %user_name% authorized to use remote access<br> [ldap1] ldap_release_conn: Release Id: 0<br>+++[ldap1] returns ok<br>++- group LDAP returns ok<br>++[expiration] returns noop<br>++[logintime] returns noop<br>[pap] Normalizing SSHA1-Password from base64 encoding<br>[pap] Normalizing SSHA1-Password from base64 encoding<br>[pap] WARNING: Auth-Type already set. Not setting to PAP<br>++[pap] returns noop<br>Found Auth-Type = MSCHAP<br># Executing group from file /etc/freeradius/sites-enabled/%site_name%<br>+- entering group MS-CHAP {…}<br>[mschap] Found LM-Password<br>[mschap] Found NT-Password<br>[mschap] Told to do MS-CHAPv1 with NT-Password<br>[mschap] adding MS-CHAPv1 MPPE keys<br>++[mschap] returns ok<br>Login OK: [%user_name%] (from client localhost port 1812)<br># Executing section post-auth from file /etc/freeradius/sites-enabled/%site_name%<br>+- entering group post-auth {…}<br>++[exec] returns noop<br>Sending Access-Accept of id 200 to 127.0.0.1 port 57889<br> MS-CHAP-MPPE-Keys = %ms-chap-mppe-key% <br> MS-MPPE-Encryption-Policy = %ms-mppe-encryption-policy%<br> MS-MPPE-Encryption-Types = %ms-mppe-encryption-types%<br>Finished request 0.<br>Going to the next request</pre><p>So, if <a href="https://wiki.freeradius.org/guide/Radtest"><strong>radtest</strong></a> command succeeded, you can proceed to testing <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> authentication with real devices.</p><h3>Part Three: <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol">LDAP</a> fail-over setup</h3><p>After you’ve successfully authenticated with a single <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> server, it’s time to add another <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> server, so you’ll have some <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> server fail-over.</p><p>In case the primary <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> server will go offline, <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> can query the second <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> server for authentication credentials.</p><p>To add second <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> server to your authentication setup, do the following:</p><p>Go to <strong>/etc/freeradius/modules.</strong></p><p>Create a copy of the <strong>ldap</strong> module file named, for example: <strong>ldap2.</strong></p><p>Rename the original <strong>ldap</strong> module file to <strong>ldap1</strong>, so you’ll have 2 module files in <strong>/etc/freeradius/modules</strong>:</p><p><strong>ldap1</strong> and <strong>ldap2</strong>.</p><p><strong>ldap1</strong> file will be used for the first <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> server and <strong>ldap2</strong> file will be used for the second <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> server.</p><p>Open <strong>ldap1</strong> file in your favorite text editor and change the beginning of the <a href="https://en.wikipedia.org/wiki/Lightweight_Directory_Access_Protocol"><strong>LDAP</strong></a> server configuration array from this:</p><pre>ldap {<br> server = ‘%freeipa_server_fqdn%’<br> port = %ldap_port%</pre><pre>…</pre><pre>}</pre><p>to this:</p><pre>ldap <strong>ldap1 </strong>{<br> server = ‘%freeipa_server_fqdn%’<br> port = %ldap_port%</pre><pre>…</pre><pre>}</pre><p>Do the same changes in <strong>ldap2</strong> file, only instead of <strong>ldap1</strong>, add <strong>ldap2.</strong></p><p>After you’ve configured both ldap modules, go to <strong>/etc/freeradius/sites-enabled</strong>.</p><p>Open your <strong>site</strong> configuration file in text editor.</p><p>Go to <strong>authorize</strong> section, find <strong>ldap</strong> option and comment it out.</p><p>Add this configuration directive beneath commented out <strong>ldap</strong> option:</p><pre>…</pre><pre>#ldap<br> redundant LDAP {<br> ldap1<br> ldap2<br> }</pre><pre>…</pre><p>Instead of single <strong>ldap</strong> module, we’ve enabled <a href="http://freeradius.org/"><strong>FreeRADIUS’s</strong></a> <a href="https://wiki.freeradius.org/config/Fail-over"><strong>redundant</strong></a> function, which will enable <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> to use both <strong>ldap1</strong> and <strong>ldap2</strong> modules we’ve defined in <strong>/etc/freeradius/modules</strong>.</p><p>Now, go to <strong>authenticate</strong> section, find <strong>ldap</strong> configuration section:</p><pre>…</pre><pre>Auth-Type LDAP {<br> ldap</pre><pre>{</pre><pre>…</pre><p>and comment it out.</p><p>Beneath commented out <strong>ldap</strong> configuration, add this:</p><pre>Auth-Type LDAP {<br> ldap1 {<br> fail = 1<br> ok = return<br> }</pre><pre>ldap2 {<br> fail = 1<br> ok = return<br> }<br>}</pre><p>After you’ve updated site configuration, launch <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> server in debug mode, and you should see this in server’s output:</p><p><strong>ldap1</strong> enabled:</p><pre>…</pre><pre>Module: Instantiating module “ldap1” from file /etc/freeradius/modules/ldap1<br> ldap ldap1 {<br> server = “%freeipa_fqdn%”<br> port = %ldap_port%<br> password = “%bind_password”<br> identity = “uid=%bind_user%,cn=users,cn=accounts,dc=example,dc=com”<br> net_timeout = 1<br> timeout = 4<br> timelimit = 3<br> tls_mode = no<br> start_tls = no<br> tls_require_cert = “allow”</pre><pre>…</pre><p><strong>ldap2</strong> enabled:</p><pre>…</pre><pre>Module: Instantiating module “ldap2” from file /etc/freeradius/modules/ldap2<br> ldap ldap2 {<br> server = “%freeipa_fqdn%”<br> port = %ldap_port%<br> password = “%bind_password”<br> identity = “uid=%bind_user%,cn=users,cn=accounts,dc=example,dc=com”<br> net_timeout = 1<br> timeout = 4<br> timelimit = 3<br> tls_mode = no<br> start_tls = no<br> tls_require_cert = “allow”</pre><pre>…</pre><p>If everything went well, now, when clients will try to authenticate using your <a href="https://en.wikipedia.org/wiki/RADIUS"><strong>RADIUS</strong></a> server, you should see something like this:</p><pre>…</pre><pre>++- entering group LDAP {…}<br>[ldap1] performing user authorization for user.test<br>[ldap1] expand: %{Stripped-User-Name} -&gt; <br>[ldap1] … expanding second conditional<br>[ldap1] expand: %{User-Name} -&gt; user.test<br>[ldap1] expand: (uid=%{%{Stripped-User-Name}:-%{User-Name}}) -&gt; (uid=user.test)<br>[ldap1] expand: cn=users,cn=accounts,dc=example,dc=com -&gt; cn=users,cn=accounts,dc=example,dc=com<br> [ldap1] ldap_get_conn: Checking Id: 0<br> [ldap1] ldap_get_conn: Got Id: 0<br> [ldap1] attempting LDAP reconnection<br> [ldap1] (re)connect to %freeipa_fqdn%:%ldap_port%, authentication 0<br> [ldap1] setting TLS mode to 1<br> [ldap1] setting TLS CACert File to %ca_file%<br> [ldap1] setting TLS Require Cert to demand<br> [ldap1] bind as uid=%bind_user%,cn=users,cn=accounts,dc=example,dc=com/%bind_password% to %freeipa_fqdn%:%ldap_port%<br> [ldap1] waiting for bind result …<br> [ldap1] Bind was successful<br> [ldap1] performing search in cn=users,cn=accounts,dc=example,dc=com, with filter (uid=%ldap_user%)<br>[ldap1] Added SSHA1-Password =%user_password_hash% == in check items<br>[ldap1] No default NMAS login sequence<br>[ldap1] looking for check items in directory…<br> [ldap1] userPassword -&gt; Password-With-Header == %user_password_hash% ==”<br> [ldap1] userPassword -&gt; User-Password == “%user_password_hash%==”<br>[ldap1] looking for reply items in directory…<br>[ldap1] user user.test authorized to use remote access</pre><pre>…</pre><p>As you can see, <a href="http://www.freeipa.org/page/Main_Page"><strong>FreeIPA</strong></a> user account has successfully authenticated using our <a href="https://en.wikipedia.org/wiki/RADIUS"><strong>RADIUS</strong></a> server using <strong>ldap1</strong> module.</p><p>If, for some reason, <strong>ldap1</strong> module can’t connect to the first <strong>LDAP</strong> server, <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> will switch to <strong>ldap2</strong> module in a second or two.</p><p>I hope you’ve enjoyed reading this lengthy article, and I hope, it will help you with <a href="http://freeradius.org/"><strong>FreeRADIUS</strong></a> configuration.</p><p>See you next time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6611624ff2c9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sign in to Google Apps using SAML protocol and Keycloak as Identity Provider]]></title>
            <link>https://medium.com/magento-magicians/sign-in-to-google-apps-using-saml-protocol-and-keycloak-as-identity-provider-79227fd2e063?source=rss-80353fb7ad97------2</link>
            <guid isPermaLink="false">https://medium.com/p/79227fd2e063</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[saml]]></category>
            <category><![CDATA[keycloak]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[sso]]></category>
            <dc:creator><![CDATA[Georgijs Radovs]]></dc:creator>
            <pubDate>Tue, 27 Dec 2016 15:42:43 GMT</pubDate>
            <atom:updated>2020-10-06T12:41:09.889Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*WWDwg84fYnWVuonCZlsG4Q.png" /></figure><p>Hello again!</p><p>Following the “huge success” :) of the article about <a href="https://stories.scandiweb.com/sign-in-to-amazon-aws-using-saml-protocol-and-keycloak-as-identity-provider-e3798387de99"><strong>Amazon AWS and Keycloak</strong></a><strong>, </strong>I would like to share an article on configuring <a href="https://en.wikipedia.org/wiki/Single_sign-on"><strong>SSO</strong></a> access to <a href="https://gsuite.google.com/"><strong>Google Apps</strong></a> using <a href="https://en.wikipedia.org/wiki/Security_Assertion_Markup_Language"><strong>SAML</strong></a> protocol and <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> as an <a href="https://en.wikipedia.org/wiki/Identity_provider"><strong>Identity Provider</strong></a>.</p><p>…</p><p><a href="https://scandiweb.com/blog/sign-in-to-google-apps-using-saml-protocol-and-keycloak-as-identity-provider/"><strong>To check out my comprehensive guide, please head to our blog!</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=79227fd2e063" width="1" height="1" alt=""><hr><p><a href="https://medium.com/magento-magicians/sign-in-to-google-apps-using-saml-protocol-and-keycloak-as-identity-provider-79227fd2e063">Sign in to Google Apps using SAML protocol and Keycloak as Identity Provider</a> was originally published in <a href="https://medium.com/magento-magicians">Scandiweb Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sign in to Amazon AWS using SAML protocol and Keycloak as Identity Provider]]></title>
            <link>https://medium.com/magento-magicians/sign-in-to-amazon-aws-using-saml-protocol-and-keycloak-as-identity-provider-e3798387de99?source=rss-80353fb7ad97------2</link>
            <guid isPermaLink="false">https://medium.com/p/e3798387de99</guid>
            <category><![CDATA[sso]]></category>
            <category><![CDATA[aml]]></category>
            <category><![CDATA[keycloak]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Georgijs Radovs]]></dc:creator>
            <pubDate>Thu, 08 Dec 2016 12:18:39 GMT</pubDate>
            <atom:updated>2020-10-05T12:12:35.364Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*WWDwg84fYnWVuonCZlsG4Q.png" /></figure><p>Hey there!</p><p>I’d like to share my experience setting up <a href="https://en.wikipedia.org/wiki/Single_sign-on"><strong>SSO</strong></a> for <a href="https://aws.amazon.com/"><strong>Amazon AWS</strong></a> using <a href="https://en.wikipedia.org/wiki/Security_Assertion_Markup_Language"><strong>SAML</strong></a> protocol and <a href="http://www.keycloak.org/"><strong>Keycloak</strong></a> as Identity Provider.</p><p><a href="http://www.keycloak.org/about.html"><strong>Keycloak</strong></a> is a <a href="https://www.redhat.com/en"><strong>Red Hat</strong></a> developed Identity and Access management solution, which supports multiple <a href="https://en.wikipedia.org/wiki/Single_sign-on"><strong>SSO</strong></a> protocols like <a href="https://en.wikipedia.org/wiki/Security_Assertion_Markup_Language"><strong>SAML</strong></a>, <a href="https://en.wikipedia.org/wiki/OpenID"><strong>OpenID</strong></a> and <a href="https://en.wikipedia.org/wiki/OAuth"><strong>OAuth2</strong></a>.</p><p>…</p><p><a href="https://scandiweb.com/blog/sign-in-to-amazon-aws-using-saml-protocol-and-keycloak-as-identity-provider"><strong>Check our blog for a detailed guide about how it’s done!</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e3798387de99" width="1" height="1" alt=""><hr><p><a href="https://medium.com/magento-magicians/sign-in-to-amazon-aws-using-saml-protocol-and-keycloak-as-identity-provider-e3798387de99">Sign in to Amazon AWS using SAML protocol and Keycloak as Identity Provider</a> was originally published in <a href="https://medium.com/magento-magicians">Scandiweb Stories</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>