Fehler, Verbesserungen oder Anmerkungen können mir gern per Email geschickt werden.

Vorraussetzungen

  • Verständnis von Dateistrukturen.
  • Vorstellung wo wie welche Daten (lokal, On-Site, Off-Site, Cloud/Auftragsdatenverarbeitung) verarbeitet werden können.

tl;dr

Installation auf dem System:

  1. Installation von GoCryptFS
  2. Setup von GoCryptFS
  3. Subscription bei Jottacloud
  4. Installation von Jottacloud
  5. Setup von Jottacloud-Sync

Test auf Zweitsystem:

  1. Installation von GoCryptFS
  2. Setup von GoCryptFS
  3. Installation von Jottacloud
  4. Setup von Jottacloud-Sync
  5. Check auf Gleichheit
    • z.B. mit rsync sollten keine zu synchronisierenden Dateien gefunden werden.
    • rsync --recursive --times --links --perms --verbose --progress --stats --delete -e ssh /local/dir/path/ user@example.net:/server/dir/path/ --dry-run
    • rsync -rtlpv --progress --stats --delete -e ssh /local/dir/path/ user@example.net:/target/dir/path/ --dry-run
    • rsync -rtlpv --progress --stats --delete /source/dir/ /target/dir/ --dry-run

Ergebnis:

Verzeichnisse sind relativ für die Nutzer.

  • /home/${APPUSER} (Home)
  • /home/${APPUSER}/.config/gocryptfs (GoCryptFS-Konfigurationsverzeichnis)
  • /home/${APPUSER}/.config/gocryptfs/${APPUSER}.config (Konfiguration für das GoCryptFS-Verzeichnis des Nutzers)
  • /home/${APPUSER}/.config/gocryptfs/${APPUSER}.pwd (Passwort für das GoCryptFS-Verzeichnis)
  • /etc/systemd/system/gocryptfs@.service (GoCryptFS-Service welche mit obigem Setup funktioniert: # systemctl enable gocryptfs@${APPUSER}.service)
  • /media/storage/${APPUSER} (Verzeichnis mit den unverschlüsselten Daten)
  • /media/storage/${APPUSER}.gcfs(Virtuelles Verzeichnis mit den verschlüsselten Daten)
  • /home/${APPUSER}/.config/jotta (Jottacloud-Konfigurationsverzeichnis)
  • /etc/systemd/system/jottad@.service (Jottacloud-Service welche mit obigem Setup funktioniert: # systemctl enable jottad@${APPUSER}.service)
    • Service ist vonn GoCryptFS-Service abhängig.

Setup

GoCryptFS

Installation

apt install gocryptfs

Setup des Nutzer-Verzeichnisses zur Verschlüsselung

# Vars
APPUSER=frank
DIRNAME=${APPUSER}
CIPHERPATH=/media/storage/${DIRNAME}.gcfs
PLAINPATH=/media/storage/${DIRNAME}

DIRPWDFILE=/home/${APPUSER}/.config/gocryptfs/${DIRNAME}.pwd
touch ${DIRPWDFILE}
chmod 600 ${DIRPWDFILE}

# Dirs
mkdir -p ~/.config/gocryptfs/ ${CIPHERPATH} ${PLAINPATH}
chmod 700 ~/.config/gocryptfs/

# Init
gocryptfs -init -config ~/.config/gocryptfs/${DIRNAME}.conf -reverse ${DIRNAME}
gocryptfs -init -config ~/.config/gocryptfs/${DIRNAME}.conf -reverse ${PLAINPATH}

# Mount
gocryptfs -config ~/.config/gocryptfs/${DIRNAME}.conf -reverse ${PLAINPATH} ${CIPHERPATH}
  #cd ${CIPHERPATH} && gocryptfs -reverse ${DIRNAME} ${PLAINPATH}

# Umount
fusermount -u ${CIPHERPATH}

# Change pwd
gocryptfs -config ~/.config/gocryptfs/${DIRNAME}.conf -passwd ${CIPHERPATH}

WICHTIG: Erstelle ein separates Backup der Datei ~/.config/gocryptfs/${DIRNAME}.conf. Das wird für das Recovery benötigt.

Setup des System-Service für den Nutzer

Nun erstellen wir einen Service, welcher die virtuelle Verschlüsselung bereit stellt, damit beim Booten automatisch dieser und die Cloud-Synchronisation starten kann.

APPUSER=frank

cat > /etc/systemd/system/gocryptfs@.service <<__EOF__
[Unit]
Description=Reverse mount of a folder into a gocryptfs-encryption for %i
ConditionPathIsDirectory=/media/storage/%i
ConditionPathIsDirectory=/media/storage/%i.gcfs
ConditionPathExists=/home/%i/.config/gocryptfs/%i.pwd

[Service]
Type=oneshot
User=%i
RemainAfterExit=yes
ExecStart=gocryptfs -config /home/%i/.config/gocryptfs/%i.conf -passfile /home/%i/.config/gocryptfs/%i.pwd  -reverse /media/storage/%i /media/storage/%i.gcfs
ExecStartPre=mkdir -p /media/storage/%i.gcfs
ExecStop=fusermount -u /media/storage/%i.gcfs

[Install]
WantedBy=multi-user.target
__EOF__

systemctl enable gocryptfs@${APPUSER}
systemctl start gocryptfs@${APPUSER}
systemctl status gocryptfs@${APPUSER}

Jottacloud

Subscription

  • Account erstellen.
    • 5 GB sind kostenlos.
    • Ideal zum Testen des Setups.
  • Einloggen.
  • In den Einstellungen ein Login-Token für das Command-Line-Tool generieren.
  • Bei gefallen empfiehlt sich: Jottacloud Personal [1] für € 7,99/Monat oder € 79,90/Jahr. → Limitierte Bandbreite ab der Nutzung von mehr als 5 TB.

Installation

apt install wget apt-transport-https ca-certificates
curl https://repo.jotta.us/public.gpg | gpg --dearmor > /usr/share/keyrings/apt-jottacloud-key.gpg
echo "deb [signed-by=/usr/share/keyrings/apt-jottacloud-key.gpg] https://repo.jotta.us/debian debian main" | tee /etc/apt/sources.list.d/jottacloud.list
apt update 
apt install jotta-cli

systemctl stop jottad
systemctl disable jottad
systemctl status jottad

Setup des System-Service für den Nutzer

cat > /etc/systemd/system/jottad@.service <<__EOF__
[Unit]
Description=Jottacloud cli for %i
After=network.target
Requires=gocryptfs@%i.service

[Service]
Type=simple
User=%i
EnvironmentFile=-/etc/default/jottad
EnvironmentFile=-/etc/sysconfig/jottad
ExecStart=jottad datadir /home/%i/.config/jotta/
Restart=always
WorkingDirectory=/

[Install]
WantedBy=multi-user.target
__EOF__

APPUSER=frank

systemctl enable jottad@${APPUSER}
systemctl start jottad@${APPUSER}
systemctl status jottad@${APPUSER}

Starting with version 0.4.x jottad will be run as the user jottad.” [1]

Setup des Jotta-Dienstes für den Nutzer

jotta-cli status
jotta-cli help
jotta-cli config get

APPUSER=frank

jotta-cli login
jotta-cli status

jotta-cli add /media/storage/${APPUSER}.gcfs
jotta-cli status

Recovery

  1. Installation von GoCryptFS
  2. Installation von Jotta-CLI
  3. Setup des lokale Jotta-Service
  4. Login ins Jotta-Cloud-Webseite: Generieren des Login-Tokens
  5. Lokales Jotta-Login
  6. Download des Backups
  7. Download der GoCryptFS-Datei
  8. Entschlüsselung als GoCryptFS
APPUSER=frank

jotta-cli login
jotta-cli status
jotta-cli download Backup/${DeviceName}/${APPUSER}.gcfs ~/Downloads/.

mkdir -p ~/Downloads/${APPUSER}

# Decrypt with config
gocryptfs -config ~/.config/gocryptfs/${APPUSER}.conf ~/Downloads/${APPUSER}.gcfs ~/Downloads/${APPUSER}

# Decrypt with master key
gocryptfs -masterkey=stdin ~/Downloads/${APPUSER}.gcfs ~/Downloads/${APPUSER}

Ich habe erhebliche Intergritäts-Probleme, wenn ich mit dem Master-Key entschlüssle. Ich rate daher sehr dazu, die Config gut und sicher zu hinterlegen.

Alternative Einstellungen

Setup des System-Service für den Nutzer

Für das Einrichten eines echten Nutzerdienstes basierend auf einem nicht unter /home liegenden Nutzerverzeichnis.

APPUSER=frank
APPUSERHOME=$(cat /etc/passwd | grep ${APPUSER} | cut -d ":" -f6)

cat > /etc/systemd/user/jottad-frank.service <<__EOF__
[Unit]
Description=Jottacloud cli for ${APPUSER}
After=network.target
Requires=gocryptfs@%i.service

[Service]
Type=simple
User=${APPUSER}
EnvironmentFile=-/etc/default/jottad
EnvironmentFile=-/etc/sysconfig/jottad
ExecStart=jottad datadir ${APPUSERHOME}/.config/jotta/
Restart=always
WorkingDirectory=/

[Install]
WantedBy=multi-user.target
__EOF__

Quellen