<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.opensourceecology.org/index.php?action=history&amp;feed=atom&amp;title=Install_Nextcloud_on_Arch_Linux</id>
	<title>Install Nextcloud on Arch Linux - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.opensourceecology.org/index.php?action=history&amp;feed=atom&amp;title=Install_Nextcloud_on_Arch_Linux"/>
	<link rel="alternate" type="text/html" href="https://wiki.opensourceecology.org/index.php?title=Install_Nextcloud_on_Arch_Linux&amp;action=history"/>
	<updated>2026-04-14T18:10:50Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.13</generator>
	<entry>
		<id>https://wiki.opensourceecology.org/index.php?title=Install_Nextcloud_on_Arch_Linux&amp;diff=226150&amp;oldid=prev</id>
		<title>Pieter: /* Introduction */</title>
		<link rel="alternate" type="text/html" href="https://wiki.opensourceecology.org/index.php?title=Install_Nextcloud_on_Arch_Linux&amp;diff=226150&amp;oldid=prev"/>
		<updated>2020-06-23T20:23:21Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Introduction&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:23, 23 June 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot;&gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Introduction =&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Introduction =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This document describes how to set up Nextcloud on a virtual private server (VPS) hosted by a cloud service provider that provides images for Arch Linux. We assume there is a DNS record in place that points the address &amp;lt;code&amp;gt;cloud.mydomain.net&amp;lt;/code&amp;gt; to the IP address provided by the cloud service provider.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This document describes how to set up Nextcloud on a virtual private server (VPS) hosted by a cloud service provider that provides images for Arch Linux. We assume there is a DNS record in place that points the address &amp;lt;code&amp;gt;cloud.mydomain.net&amp;lt;/code&amp;gt; to the IP address provided by the cloud service provider&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;.  Note that this is not a hardened installation, it is merely used for experimentation.  More configuration is required to harden the installation&lt;/ins&gt;.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Basic setup Arch Linux =&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;= Basic setup Arch Linux =&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Pieter</name></author>
	</entry>
	<entry>
		<id>https://wiki.opensourceecology.org/index.php?title=Install_Nextcloud_on_Arch_Linux&amp;diff=226148&amp;oldid=prev</id>
		<title>Pieter: Change source tags to pre</title>
		<link rel="alternate" type="text/html" href="https://wiki.opensourceecology.org/index.php?title=Install_Nextcloud_on_Arch_Linux&amp;diff=226148&amp;oldid=prev"/>
		<updated>2020-06-23T20:21:08Z</updated>

		<summary type="html">&lt;p&gt;Change source tags to pre&lt;/p&gt;
&lt;a href=&quot;https://wiki.opensourceecology.org/index.php?title=Install_Nextcloud_on_Arch_Linux&amp;amp;diff=226148&amp;amp;oldid=226147&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Pieter</name></author>
	</entry>
	<entry>
		<id>https://wiki.opensourceecology.org/index.php?title=Install_Nextcloud_on_Arch_Linux&amp;diff=226147&amp;oldid=prev</id>
		<title>Pieter: Add the Nextcloud installation part</title>
		<link rel="alternate" type="text/html" href="https://wiki.opensourceecology.org/index.php?title=Install_Nextcloud_on_Arch_Linux&amp;diff=226147&amp;oldid=prev"/>
		<updated>2020-06-23T20:17:38Z</updated>

		<summary type="html">&lt;p&gt;Add the Nextcloud installation part&lt;/p&gt;
&lt;a href=&quot;https://wiki.opensourceecology.org/index.php?title=Install_Nextcloud_on_Arch_Linux&amp;amp;diff=226147&amp;amp;oldid=226145&quot;&gt;Show changes&lt;/a&gt;</summary>
		<author><name>Pieter</name></author>
	</entry>
	<entry>
		<id>https://wiki.opensourceecology.org/index.php?title=Install_Nextcloud_on_Arch_Linux&amp;diff=226145&amp;oldid=prev</id>
		<title>Pieter: Basic setup of Arch Linux</title>
		<link rel="alternate" type="text/html" href="https://wiki.opensourceecology.org/index.php?title=Install_Nextcloud_on_Arch_Linux&amp;diff=226145&amp;oldid=prev"/>
		<updated>2020-06-23T20:15:03Z</updated>

		<summary type="html">&lt;p&gt;Basic setup of Arch Linux&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Comment =&lt;br /&gt;
&lt;br /&gt;
For some reason the &amp;lt;source&amp;gt; tags don&amp;#039;t work, will fix it later.&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
This document describes how to set up Nextcloud on a virtual private server (VPS) hosted by a cloud service provider that provides images for Arch Linux. We assume there is a DNS record in place that points the address &amp;lt;code&amp;gt;cloud.mydomain.net&amp;lt;/code&amp;gt; to the IP address provided by the cloud service provider.&lt;br /&gt;
&lt;br /&gt;
= Basic setup Arch Linux =&lt;br /&gt;
&lt;br /&gt;
== Initial setup ==&lt;br /&gt;
&lt;br /&gt;
Since the system comes preinstalled with Arch Linux on it, the first thing to do is to update the system:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;pacman -Syu&lt;br /&gt;
&lt;br /&gt;
reboot&lt;br /&gt;
&lt;br /&gt;
pacman -S base base-devel&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Add an administration user ==&lt;br /&gt;
&lt;br /&gt;
We add a day-to-day administrator account:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;useradd -m -g users -s /bin/bash admin&lt;br /&gt;
passwd admin&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Make sure that &amp;lt;code&amp;gt;pacman&amp;lt;/code&amp;gt; can be executed as user &amp;lt;code&amp;gt;admin&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;visudo&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And add the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;admin ALL=(ALL) NOPASSWD: /usr/bin/pacman&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Create a swap partition ==&lt;br /&gt;
&lt;br /&gt;
The swap partition has already been activated, so there is nothing to do.&lt;br /&gt;
&lt;br /&gt;
== Configure the language and locales ==&lt;br /&gt;
&lt;br /&gt;
In file &amp;lt;code&amp;gt;/etc/locale.gen&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;en_US.UTF-8 UTF-8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Then execute:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;locale-gen&lt;br /&gt;
&lt;br /&gt;
echo LANG=en_US.UTF-8 &amp;gt; /etc/locale.conf&lt;br /&gt;
export LANG=en_US.UTF-8&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Add the correct time zone, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;commonlisp&amp;quot;&amp;gt;ln -s /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== Time configuration ==&lt;br /&gt;
&lt;br /&gt;
Since Arch sits in a virtual machine, we assume that the time is always correct.&lt;br /&gt;
&lt;br /&gt;
== Random number generation ==&lt;br /&gt;
&lt;br /&gt;
Random number generation is important for security, so we install the following tools:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;pacman -S rng-tools&lt;br /&gt;
&lt;br /&gt;
systemctl start rngd&lt;br /&gt;
systemctl enable rngd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To check the level of entropy we can do:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;cat /proc/sys/kernel/random/entropy_available&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Since it runs on a virtual machine, we are not really sure how representative the entropy is.&lt;br /&gt;
&lt;br /&gt;
We can also run the following tests which should have very few failures:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;cat /dev/random | rngtest -c 1000&lt;br /&gt;
cat /dev/urandom | rngtest -c 1000&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The &amp;lt;code&amp;gt;rng-tools&amp;lt;/code&amp;gt; service is preferred over &amp;lt;code&amp;gt;haveged&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Setting the hostname ==&lt;br /&gt;
&lt;br /&gt;
Assuming we have a hostname &amp;lt;code&amp;gt;mydomainname.net&amp;lt;/code&amp;gt; that points to our server&amp;#039;s IP address:&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;/etc/hostname&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;cloud.mydomainname.net&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
In &amp;lt;code&amp;gt;/etc/hosts&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;127.0.1.1 cloud.mydomainname.net&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
After a reboot, we can check whether everything is set with the command &amp;lt;code&amp;gt;hostname -f&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Setting up the network ==&lt;br /&gt;
&lt;br /&gt;
The network has been set up fine by the cloud provider.&lt;br /&gt;
&lt;br /&gt;
== Setting up the firewall ==&lt;br /&gt;
&lt;br /&gt;
We use &amp;lt;code&amp;gt;iptables&amp;lt;/code&amp;gt; to set up the firewall. A chain is a set of rules. The chain INPUT is predefined for packets that enter the system.&lt;br /&gt;
&lt;br /&gt;
First we set the policy for chain INPUT to target ACCEPT:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -P INPUT ACCEPT&lt;br /&gt;
ip6tables -P INPUT ACCEPT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We then flush all the chains:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -F&lt;br /&gt;
ip6tables -F&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
A table in this context is a packet matching table. There are five predefined tables. The default table &amp;#039;&amp;#039;filter&amp;#039;&amp;#039;, the tables &amp;#039;&amp;#039;nat&amp;#039;&amp;#039;, &amp;#039;&amp;#039;mangle&amp;#039;&amp;#039;, &amp;#039;&amp;#039;raw&amp;#039;&amp;#039;, and &amp;#039;&amp;#039;security&amp;#039;&amp;#039;. We flush the table &amp;#039;&amp;#039;nat&amp;#039;&amp;#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -t nat -F&lt;br /&gt;
ip6tables -t nat -F&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We then delete all the user-defined chains:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -X&lt;br /&gt;
ip6tables -X&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We then set the policy to drop every packet that enters the system (make sure you are logged in via a video display and not SSH):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -P INPUT DROP&lt;br /&gt;
ip6tables -P INPUT DROP&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We append to chain INPUT on the loopback interface &amp;lt;code&amp;gt;lo&amp;lt;/code&amp;gt; to jump to target ACCEPT. This is important for applications that use local servers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -A INPUT -i lo -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -i lo -j ACCEPT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We then append to chain INPUT on interface &amp;lt;code&amp;gt;ens3&amp;lt;/code&amp;gt; a rule to accept connections with states ESTABLISHED and RELATED:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -A INPUT -i ens3 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;
ip6tables -A INPUT -i ens3 -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We then make sure that incomming TCP connections are SYN packets to prevent SYN flooding:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP&lt;br /&gt;
ip6tables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We also drop packets with incoming fragments. This is only for IPv4:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -A INPUT -f -j DROP&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We also drop bogons:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP&lt;br /&gt;
iptables -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP&lt;br /&gt;
iptables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP&lt;br /&gt;
ip6tables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP&lt;br /&gt;
ip6tables -A INPUT -p tcp --tcp-flags ALL FIN,PSH,URG -j DROP&lt;br /&gt;
ip6tables -A INPUT -p tcp --tcp-flags ALL SYN,RST,ACK,FIN,URG -j DROP&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We also reject malformed NULL packets:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP&lt;br /&gt;
ip6tables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We can then store the firewall rules with the following commands:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables-save &amp;gt; /etc/iptables/iptables.rules&lt;br /&gt;
ip6tables-save &amp;gt; /etc/iptables/ip6tables.rules&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
To make the changes permanent, we can enable and start the Systemd service:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;systemctl start iptables.service&lt;br /&gt;
systemctl enable iptables.service&lt;br /&gt;
systemctl status iptables.service&lt;br /&gt;
&lt;br /&gt;
systemctl start ip6tables.service&lt;br /&gt;
systemctl enable ip6tables.service&lt;br /&gt;
systemctl status ip6tables.service&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Fail2ban ==&lt;br /&gt;
&lt;br /&gt;
The service fail2ban is a service for detecting login attempts and blocking it.&lt;br /&gt;
&lt;br /&gt;
We install it with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;pacman -S fail2ban&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Using &amp;lt;code&amp;gt;systemd&amp;lt;/code&amp;gt; we can sandbox the fail2ban service with capabilities. To do so, we create a new file &amp;lt;code&amp;gt;/etc/systemd/system/fail2ban.service.d/capabilities.conf&amp;lt;/code&amp;gt; with the following contents:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;[Service]&lt;br /&gt;
PrivateDevices=yes&lt;br /&gt;
PrivateTmp=yes&lt;br /&gt;
ProtectHome=read-only&lt;br /&gt;
ProtectSystem=strict&lt;br /&gt;
NoNewPrivileges=yes&lt;br /&gt;
ReadWritePaths=-/var/run/fail2ban&lt;br /&gt;
ReadWritePaths=-/var/lib/fail2ban&lt;br /&gt;
ReadWritePaths=-/var/log/fail2ban&lt;br /&gt;
ReadWritePaths=-/var/spool/postfix/maildrop&lt;br /&gt;
ReadWritePaths=-/run/xtables.lock&lt;br /&gt;
CapabilityBoundingSet=CAP_AUDIT_READ CAP_DAC_READ_SEARCH CAP_NET_ADMIN CAP_NET_RAW&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Create configuration file &amp;lt;code&amp;gt;/etc/fail2ban/fail2ban.local&amp;lt;/code&amp;gt; with the correct logtarget path:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;[Definition]&lt;br /&gt;
logtarget = /var/log/fail2ban/fail2ban.log&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Create the &amp;lt;code&amp;gt;/var/log/fail2ban/&amp;lt;/code&amp;gt; directory as root.&lt;br /&gt;
&lt;br /&gt;
We have to set up paths for Arch Linux in a &amp;lt;code&amp;gt;jail.local&amp;lt;/code&amp;gt; file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;[INCLUDES]&lt;br /&gt;
before = paths-arch.conf&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Yay ==&lt;br /&gt;
&lt;br /&gt;
With yay, we can keep also the AUR packages up to date.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;git clone https://aur.archlinux.org/yay.git&lt;br /&gt;
tar xvzf yay.tar.gz&lt;br /&gt;
cd yay&lt;br /&gt;
makepkg -s&lt;br /&gt;
pacman -U yay*.pkg.tar.xz&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
= SSH access =&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
&lt;br /&gt;
The first service we would like to set up is SSH. We first configure the SSH daemon itself in file &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;PermitRootLogin no&lt;br /&gt;
TCPKeepAlive no&lt;br /&gt;
ClientAliveInterval 60&lt;br /&gt;
Ciphers aes256-ctr,aes192-ctr,aes128-ctr&lt;br /&gt;
MACs hmac-sha2-512,hmac-sha2-256&lt;br /&gt;
KexAlgorithms diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1,diffie-hellman-group-exchange-sha1&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
We then restart the daemon:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;systemctl restart sshd&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== The firewall ==&lt;br /&gt;
&lt;br /&gt;
We have to open port 22 for SSH in our firewall:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables -A INPUT -i ens3 -p tcp --dport 22 -j ACCEPT&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;iptables-save &amp;gt; /etc/iptables/iptables.rules&lt;br /&gt;
ip6tables-save &amp;gt; /etc/iptables/ip6tables.rules&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Fail2ban ==&lt;br /&gt;
&lt;br /&gt;
We add the following jails in &amp;lt;code&amp;gt;/etc/fail2ban/jail.d/&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;sshd.conf&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;[sshd]&lt;br /&gt;
enabled = true&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Pieter</name></author>
	</entry>
</feed>