👨💻 about me home CV/Resume 🖊️ Contact Github LinkedIn I’m a Haskeller 📝 Blog Freedom, privacy, tutorials… 🏆 Best of LuaX Calculadoira panda upp Haskell todo pwd TPG Nextcloud Git BitTorrent
I don’t like GAFAM’s way of eating my personal data. So I decided to self-host my personal cloud to protect my privacy and have full powers on my data instead of Google.
This page describes a basic Raspberry Pi installation:
All being run on a small pretty Raspberry Pi ;-)
The server will run 24/7 so running on a regular desktop PC is no good idea. We are going to install it on a Rapsberry Pi connected to the local network.
For this you will need:
My own data center is also equipped with a nice aluminium open case with two fans:
Just plug everything and let’s continue with the software setup.
The software setup is completely made from a Linux PC connected to the same local network than the Raspberry Pi (Ethernet or WiFi).
The whole installation is scripted. My script is available here: rrpi-config.
rrpi-config
connects to the Raspberry Pi with ssh. The
Raspberry Pi hostname shall be given on the command line. The default
host name is raspberrypi.local
. The script shows a menu for
a step-by-step installation.
WARNING: This script is provided for free and with no guaranty. Please read it before using it. It may fail and you may have to fix issues that are not described here.
rrpi-config
and select Prepare
.~/raspios
).rrpi-config
and select Flash
.rrpi-config
should
auto-detect it).We will start by configuring the Raspberry Pi with
raspi-config
.
rrpi-config
and select Configure
pi
user password
and choose a strong password.rrpi-config
in the next
steps, e.g. mypi
).To connect with SSH keys instead of password, you need to push your keys to the Raspberry Pi.
ssh-keygen
to create your SSH keys if you don’t
have one.rrpi-config
and select Keys
to push
your public key to the Raspberry Pi.Ssh
to try your SSH configuration. You should
now be connected to the Raspberry Pi.sudo reboot
to reboot with the new configuration
(hostname, …).From now on you shall start rrpi-config
with the right
hostname (e.g. rrpi-config mypi.local
).
The following steps use a configuration files that must be created on the Linux PC used to configure the Raspberry Pi:
~/.myconf
This file is a Lua script that shall be executable and define the following parameters:
-------------------------------------------------------------------------------
-- GANDI API
-------------------------------------------------------------------------------
= {
gandi = "Your Gandi API key here",
api_key = "your domaine name",
domain = "subdomain pointing to the Raspberry Pi (e.g. mypi)",
subdomain }
-------------------------------------------------------------------------------
-- Network monitor
-------------------------------------------------------------------------------
= {
netmon = "local IP of the local router (may be your ISP modem or a local router)",
router = "local IP of your ISP modem",
box = {
web "first Internet server to ping",
"second Internet server to ping",
"third Internet server to ping",
},
}
-------------------------------------------------------------------------------
-- AbuseIPDB
-------------------------------------------------------------------------------
= {
abuseipdb = {
api_key = "Key used to report SSH attacks",
ssh = "Key used to report Apache attacks",
web }
}
gdns
)If the server shall be accessed from Internet, it shall have a fixed
IP or a domain named. rrpi-config
can configure a DNS entry
on a Gandi DNS record. You will need to
buy a domain name at Gandi (or adapt the script for your own needs) and
create a configuration table with Gandi API key
(~/.myconf
).
The script bin/gdns
will be created on the Raspberry Pi.
It regularly checks the external IP and updates the Gandi DNS record
when the external IP changes.
netmon
)rrpi-config
creates two scripts used to monitor the
Internet connectivity and the Raspberry Pi:
~/bin/status
: updates
/var/www/html/status.html
(some statistics about the
Raspberry Pi).~/bin/netmon
: updates
/var/www/html/netmon.html
(regularly pings some servers to
check Internet is reachable). To reset this file, please delete
/var/www/html/netmon.csv
.netmon
is configured by ~/..myconf
.
My ISP modem is very bad and regularly looses Internet connection. A
simple workaround is to reboot the modem every night at 4 AM.
netmon
ignores errors around 4 AM. This behaviour can be
changed in rrpi-config
.
Fail2ban is used to ban IP that
try to hack the Raspberry Pi. Its configuration is hard-coded in
rrpi-config
. Banned IPs are reported to AbuseIPDB. AbuseIPDB keys shall be
defined in ~/.myconf
.
Run rrpi-config mypi.local
and select
Install
.
This will install some Debian packages:
and configure:
The Apache web server can be used to host an HTTP server on the Raspberry Pi. Its is also required if you plan to install Nextcloud.
rrpi-config mypi.local
and select
Apache
.Ssh
to connect to the Raspberry Pi.sudo certbot --apache
to configure and install SSL
certificates.Radicale is a small but powerful CalDAV (calendars, to-do lists) and CardDAV (contacts) server. You can install Radicale if you don’t need Nextcloud.
rrpi-config mypi.local
and select
Radicale
.Nextcloud is a complete alternative to Google (calendars, contacts, drive, …) and Dropbox (file synchronization). It works pretty well and integrates perfectly with Thunderbird, Android, … I have a 500 Gb cloud for just the price of a 500 Gb SSD and my data remain mine.
rrpi-config mypi.local
and select
Nextcloud
./var/www/html/nextcloud/config/config.php
(see
rrpi-config
output).http:mypi.local/nextcloud
to configure the
Nextcloud server.The Debian packet minidlna
can be used to store and
shared media files (music, video, …). Shared files will be stored in
/home/pi/dlna
.
rrpi-config mypi.local
and select
UPnP
.rrpi-config mypi.local
and select
qBittorrent
.qbittorrent-nox
on the Raspberry Pi to start the
qBittorrent server (Ctrl-C
to stop it).This script is constantly updated and the documentation may be outdated. The best is always to read the sources and change them to fit your requirements.