Verschlüsselten File-Container mittels cryptsetup und LUKS erstellen


Datenschutz wird im Jahr 2018 so groß geschrieben wie nie zuvor. Verschiedene Anforderungen an die Absicherung der Daten zwingen Admins, sich elegante und sichere Setups einfallen zu lassen. Ich nehme das zum Anlass, eine neue Serie zur Dateiverschlüsselung zu eröffnen, bei der es um die verschiedensten Möglichkeiten geht, die gespeicherten Daten gegen den Zugriff Unbefugter abzusichern.
Oftmals ist eine Verschlüsselung der Daten aufgrund bestehender Infrastrukturen oder mangels Rechten (z. B. bei extern angemieteten Storages) nicht so einfach möglich. Früher war hier ECryptFS im Linux-Umfeld und TrueCrypt bei Windows State of the Art. Heute haben sich die Anforderungen geändert und ECryptFS ist wegen einer zu restriktiven Beschränkungen der Dateinamen nicht mehr alltagstauglich. Daher stelle ich hier eine moderne Alternative mit cryptsetup in Ergänzung mit LUKS vor.

Vorbereitung

Installation von cryptsetup (Beispiel Debian-Derivate)

sudo apt-get install cryptsetup

Laden des Kernel-Moduls (nur bei initialer Einrichtung)

sudo modprobe dm-crypt

File-Container erstellen

Zunächst wird mittels dd ein File-Container mit 1GB Größe erstellt, der Wert kann natürlich je nach Anforderung angepasst werden

dd if=/dev/zero of=/storage/my_container bs=1M count=1024

File-Container mittels cryptsetup initialisieren

 cryptsetup -y luksFormat /storage/my_container

Nun die gewünschte Passphrase eingeben. Aber Achtung, ohne ein gut gewähltes Passwort nutzt die stärkste Verschlüsselung nichts!
Verschlüsselten Container öffnen und Dateisystem erstellen

cryptsetup luksOpen /storage/my_container my_mount

hier wird das Kennwort abgefragt, dies sollte man sich natürlich zuvor gut merken. Der Container ist nun unter /dev/mapper/my_mount eingebunden.  Anschließend wird ein ext4-Dateisystem in dem Container erzeugt.

mkfs.ext4 -j /dev/mapper/my_mount

File-Container am Wunschort mounten

Ordner zum mounten erstellen

mkdir /my_data
mount /dev/mapper/my_mount /my_data

Fertig – alle Daten die nun in /my_data erzeugt werden, landen am Ende verschlüsselt im Container, wie in meinem Beispiel unter /storage/my_container

Mount aushängen und File-Container schließen

Damit die Daten während der Nichtnutzung auch wirklich sicher sind, empfehle ich, den Container wieder abzuschließen.

umount /my_data
cryptsetup luksClose my_mount

Protip

Ich habe auf diese Art der Verschlüsselung bei meiner Nextcloud zurückgegriffen, da mir die Bordmittel von Nextcloud nicht gefallen, oder zu langsam sind. Im nächsten Artikel werde ich auch erklären, wie man den Container entsprechend vergrößern kann. Alle mit my_ verwendeten Variablen, können natürlich auf die jeweiligen Bedürfnisse angepasst werden.

Haben wollen?

Wir bieten natürlich bei uns im Managed-Hosting individuelle Lösungen an. Falls unsere (potentiellen) Kunden ein solches Setup wünschen, so sind wir natürlich für jeden Spaß zu haben.

Disclaimer

LUKS verwaltet die Verschlüsselungsdaten im Header. Ohne den Header (oder im Falle einer Beschädigung), ist ein Zugriff auf die Daten nicht mehr möglich. Es gibt verschiedene Tools, wie beispielsweise zuluCrypt, mit denen die Schlüssel und Header verwaltet und gesichert werden können, doch dazu in einem späteren Artikel mehr. Die Anleitung wurde nach bestem Wissen und Gewissen erstellt, testet bitte jedoch selbst ausreichend, bevor diese Lösung in die Produktion geht, damit das ihr die Funktionsweise versteht und Datenverlust vermeidet.

Georg Mimietz
Georg Mimietz
Lead Senior Systems Engineer

Georg kam im April 2009 zu NETWAYS, um seine Ausbildung als Fachinformatiker für Systemintegration zu machen. Nach einigen Jahren im Bereich Managed Services ist er in den Vertrieb gewechselt und kümmerte sich dort überwiegend um die Bereiche Shop und Managed Services. Seit 2015 ist er als Teamlead für den Support verantwortlich und kümmert sich um Kundenanfragen und die Ressourcenplanung. Darüber hinaus erledigt er in Nacht-und-Nebel-Aktionen Dinge, für die andere zwei Wochen brauchen.

April Snap 2018 > OSDC, OSCamp- Speakers, NETWAYS Web Services, Slack- Notification, WordPress


Hello May!! In April we expressed our gratitude to our OSDC sponsors for their support! Nicole reviewed GitLab security update. Jean offered solutions for a personal Linux backup. Markus promised more content for NETWAYS’ Graphing training. Marius announced NETWAYS Web Services: WordPress now up and running!
Keya asked if you are going to the OSDC Berlin!! And then she urged you to Join the OSCamp on June 14! Florian talked about Was kann eigentlich CSS-Grid? Max taught us how to Synchronize configuration with lsyncd. Then we reported on NETWAYS` Support to film project of TH Nuremberg. Marius brought us up to speed on Running Icinga in NWS with Slack notifications.
Philipp talked about Hard disk benchmark with bonnie ++Pamela told you to get ready for the OSDC 2018 Berlin! Marius shared his thoughts on Anpassungen der Nextcloud Login Seite werden nicht geladen. Keya announced the OSCamp 2018 – Speakers Line-up.

Keya Kher
Keya Kher
Marketing Manager

Keya ist seit Oktober 2017 in unserem Marketing Team. Sie kennt sich mit Social Media Marketing aus und ist auf dem Weg, ein Grafikdesign-Profi zu werden. Wenn sie sich nicht kreativ auslebt, entdeckt sie andere Städte oder schmökert in einem Buch. Ihr Favorit ist “The Shiva Trilogy”.  

February Snap 2018 > Icinga camp, Open Source Datacenter Conference 2018, Ceph, Braintower , NETWAYS Monitor


Freezing February !! And we froze our selection for Open Source Datacenter Conference 2018’s speaker listAlexander said Apple Pi is simple and secure, have you tried it yet? Philipp was happy to celebrate his six -month anniversary at NETWAYS with his fellow trainees Afeef and KillianJulia announced a 25% discount for Ceph training in March.
Marius showed us how to upgrade MariaDB from 10.0.x to 10.2.x. in 10 easy steps. Jean-Marcel talked about the quest for su on Windows. Lennart educated us all with Icinga 2 “Eat or Die”, the variable scope. Nicole announced detailes on the Nextcloud 13 update. Dirk recapped the Configuration Management Camp Ghent 2018.
Isabel invited you to NETWAYS – Monitor your server rooms with us! And told us about MultiTech MTD- H5-2.0 USB powered- easy SMS sending, and, also about the Braintower SMS Gateway with 2 variants. Blerim had the honor of presenting the program for the Icinga Camp Berlin 2018. And, last, but not least,Christoph wanted to Samba Samba all night!!

Keya Kher
Keya Kher
Marketing Manager

Keya ist seit Oktober 2017 in unserem Marketing Team. Sie kennt sich mit Social Media Marketing aus und ist auf dem Weg, ein Grafikdesign-Profi zu werden. Wenn sie sich nicht kreativ auslebt, entdeckt sie andere Städte oder schmökert in einem Buch. Ihr Favorit ist “The Shiva Trilogy”.  

NETWAYS Web Services: Nextcloud 13 now up and running!


A lot of Nextcloud users have waited for the new Nextcloud 13 version to be available. Now our NWS team has implemented it for all Nextcloud apps on our platform.
Nextcloud 13 will bring you the following enhanced functions to your cloud:

  • Video and Text chat
  • End-to-end Encryption
  • Refined User Interface
  • Improved Performance
  • Improved File Sync and Share

 
Nextcloud users will now profit from a new app called Nextcloud Talk which provides an Open Source platform for audio, video and text communication in real-time as well as in asynchronous mode. Push notifications will help you to never miss a message! Absolute privacy is guaranteed by implementation of end-to-end encrypted calls that are 100% secure peer-to-peer.
Another big innovation is the End-to-End Encryption of content which can now be controlled by the users themselves. In the current Tech Preview release in version 13 it is now possible to encrypt single folders chosen by the users via their Nextcloud client. This prohibits the server side from accessing and seeing the folder or file content. The preview is available in mobile clients for Android and iOS as well as in desktop clients for Windows, Mac and Linux. Nextcloud will continue to enhance its encryption functionality over the next months.

Performance is also an important subject when it comes to the daily use of a certain software. The Nextcloud team has done a lot to make your work and collaboration faster and more comfortable by decreasing for example page load times as well as improving Server-Side-Encryption and external storage performance. For more information on performance enhancements please have a look at Nextcloud’s own blog article
 
For more detailed information on the new Nextcloud release you should visit the Nextcloud website or start your own Nextcloud instance on our NWS platform. Please remember that we offer a 30 day free trial period for every app!
 
 
 
 

NETWAYS Web Services: Connect to your own Domain!

Our team has continued to improve the NETWAYS Web Services products for providing more comfort to our customers. Now any app can be run under its own Domain Name in combination with its own SSL certificate. This option is available for the following products:

The implementation within the product is quite simple. After your app has been created successfully, you will find a new webform in your app’s Access tab. Here is an example of a Request Tracker app:

As the webform shows, customers simply have to enter a registered Domain Name and their SSL Certificate as well as their SSL Key. The implementation in the app will be done by our NWS platform fully automated. Customers only need to take care about the quality and correctness of the certificate and to make sure they enter the DNS record correctly on their Domain Name Server. The IP address needed will be indicated underneath the webform in the information section. Furthermore, it is still possible to set an additional CName for your app. This means that your customized Domain Name and the CName can be used in parallel. Furthermore, the platform generated standard URL will stay valid and customers can always go back to the initial settings by removing their entries from the webform.
After clicking the save button, the app will be restarted and all changes will be taken into production immediately.
The bonus of this option is clear: Anybody working with your apps will be glad to use easy to read and memorize URLs. Furthermore, company identity and culture is even more important today than ever. So why not also provide your SuiteCRM, Rocket.Chat or Nextcloud with a well branded URL?
More information can be found on our NWS homepage, in any of our product sections or by contacting us via the NWS livechat.
Important note: All NWS products are up for a 30 day free trial!

Setting up a TURN Server for Nextcloud Video Calls

We recently had an support inquiry from one of our Nextcloud customers at Netways Web Services. He told us that he had installed the Nextcloud Video Calls app from the Nextcloud Appstore but was not able to make any video calls. He and the person on the other end always got a black video screen when attempting to call each other.
After some research I identified the potential cause of the problem. It turned out that a TURN server was required (pardon the pun).
 

TURN – what is that?

The Nextcloud Video Calls app contains a WebRTC-based server called spreed. WebRTC uses the ICE (Interactive Connectivity Establishment) framework to overcome networking complexities (like NATs) where connecting the participating clients directly isn’t possible. But it will need at least a STUN server to accomplish that. STUN standing for “Session Traversal Utilities for NAT” will enable the clients to discover their public IP addresses and the NAT where they are behind. Note that this server is only used to initially establish the connection. Once the connection is set up the media will stream directly between the clients. The Nextcloud Video Calls app is preconfigured with “stun.nextcloud.com:443” as STUN server. But this doesn’t always work – just like our customer experienced it, for some clients a STUN server won’t be enough to establish the connection. That might be the case if one or multiple participants are behind a symmetric NAT where UDP hole punching does not work. And that’s where the TURN server comes in. “Traversal Using Relay NAT” (TURN) extends STUN capabilities to make media traversal possible even if the clients are behind symmetric NATs. But that means that the whole traffic will flow through the TURN server since it is acting as a relay. Therefore most TURN servers use credential or shared secret mechanisms to authenticate the clients. So after all you end up having two options: either you find a TURN server provider that you can trust and who is willing to grant you access to his service or you set up your own TURN server.
 

How to set up a TURN Server

We decided to set up our own TURN. Like most of the tutorials recommend we installed Coturn. Our “TURN-VM” is running Ubuntu 16.04 and has a public IP address – this is actually quite important since the TURN server needs at least one dedicated public IP address to work properly. In order to have full STUN/TURN server functionality it’s even required to have two public IP addresses.
Now let’s start – first install coturn:

apt-get install coturn

Next enable coturn as service (use the editor of your choice):

vim /etc/default/coturn

Now uncomment the last line, save and close the file:

#
# Uncomment it if you want to have the turnserver running as
# an automatic system service daemon
#
TURNSERVER_ENABLED=1

We will have a look at the config file of Coturn. It has a lot of lines so I will only go over settings that are relevant in conjunction with Nextcloud’s spreed video calls. Open the turnserver.conf with an editor

vim /etc/turnserver.conf

and have a look at the following lines

#listening-port=3478
#tls-listening-port=5349

Those are the default listening ports coturn will use. In my case I changed them to

listening-port=80
tls-listening-port=443

because I don’t have a webserver running on the VM and I already had the ports open in the firewall. This is important – make sure that the server is reachable on these ports and no firewall is blocking them.
Note that the tls-listening-port is only relevant if you plan on using TLS-encrypted connections.
You’ll find the following line a couple of lines below the tls-listening-port:

#listening-ip=172.17.19.101

If you leave it as a comment then Coturn will listen on all the IP addresses available for this host. I uncommented it and changed it to the actual public IP address of this server

listening-ip=185.XX.XXX.XXX

Further down I did the same for the relay-ip:

relay-ip=185.XX.XXX.XXX

Now look for “fingerprint” and “lt-cred-mech” and uncomment:

fingerprint
lt-cred-mech

A couple of lines below you’ll find

#use-auth-secret

and

#static-auth-secret=north

uncomment both, then open up another shell window and generate a secret for example with

openssl rand -hex 32
751c45cae60a2839711a94c8d6bf0089e78b2149ca602fdXXXXXXXXXXXXXXXXX

copy the generated secret string and paste it into the turnserver.conf

use-auth-secret
static-auth-secret=751c45cae60a2839711a94c8d6bf0089e78b2149ca602fdXXXXXXXXXXXXXXXXX

Enabling “use-auth-secret” and setting a “static-auth-secret” will prevent unauthorized usage of your TURN server and is highly recommended!
Head further down and look for

#realm=mycompany.org

then uncomment and change it to the FQDN of the TURN server

realm=xxxxx.netways.de

The next line to uncomment and change is

total-quota=100

then uncomment

stale-nonce

If you want to use TLS then you should get a SSL certificate and key for example via Letsencrypt and then set the following lines of the turnserver.conf to the path where those files are located, in my case:

cert=/ssl/nws.crt
pkey=/ssl/nws.pem

also set cipher-list to

cipher-list="ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5"

If you don’t plan on using this TURN server as STUN then you can uncomment

no-stun

Now some last uncommenting

no-loopback-peers
no-multicast-peers

and you should be ready to start your coturn server. Save the file and close the editor.
Start/restart coturn for example with

service coturn restart

or

/etc/init.d/coturn restart

You may want to watch the logfile to see if everthing is fine

tail -f /var/log/turn_YYYY-MM-DD.log
0: log file opened: /var/log/turn_2017-08-15.log
0: pid file created: /var/run/turnserver.pid
0: IO method (main listener thread): epoll (with changelist)
0: WARNING: I cannot support STUN CHANGE_REQUEST functionality because only one IP address is provided
0: Wait for relay ports initialization...
0:   relay 185.XX.XXX.XXX initialization...
0:   relay 185.XX.XXX.XXX initialization done
0: Relay ports initialization done
0: IO method (general relay thread): epoll (with changelist)
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=0 created
0: turn server id=2 created
0: IPv4. TLS/SCTP listener opened on : 185.XX.XXX.XXX:80
0: IPv4. TLS/TCP listener opened on : 185.XX.XXX.XXX:80
0: IO method (general relay thread): epoll (with changelist)
0: IPv4. TLS/SCTP listener opened on : 185.XX.XXX.XXX:443
0: IPv4. TLS/TCP listener opened on : 185.XX.XXX.XXX:443
..
.

So now we are ready to test if it is working.
 
 

How to test my TURN Server

Visit this page and see if you can get a proper response from your Coturn server.
The field for “STUN or TURN URI” should look something like this:

turn:xxxxx.netways.de:443?transport=tcp

but you can also use the IP:

turn:185.XX.XXX.XXX:443?transport=tcp

adding the part “?transport=tcp” is important as I was not able to get my TURN server to respond without TCP only.
Next click on “Gather candidates”.
What you would want as a result should look similar to this:

Time Component  Type Foundation Protocol    Address	 Port	         Priority
0.006	1	host	0	 UDP	10.0.10.144	60925	126 | 32512 | 255
0.009	1	host	1	 TCP	10.0.10.144	63376	125 | 32640 | 255
0.010	1	host	1	 TCP	10.0.10.144	9	125 | 32704 | 255
0.015	2	host	0	 UDP	10.0.10.144	47302	126 | 32512 | 254
0.016	2	host	1	 TCP	10.0.10.144	64892	125 | 32640 | 254
0.016	2	host	1	 TCP	10.0.10.144	9	125 | 32704 | 254
0.031	1	srflx	2	 TCP	XXX.XX.XX.XX	3362	 99 | 32607 | 255
0.051	2	srflx	2	 TCP	XXX.XX.XX.XX	3364	 99 | 32607 | 254
0.069	                                                                     Done

If you get a timeout with “Not reachable?” then probably a firewall is blocking the connection. Check again if the ports for the TURN server are open and if you can reach it externally via Telnet or something similar.
 
If everything works as expected you can continue and enter FQDN, port and shared secret in the video calls settings of your Nextcloud:

Also make sure that “TURN server protocols” is set to “TCP only”.
Finally test if video calls work with participants from different networks, through NAT’s and firewalls.
 
Well, that’s at least how I got it working and our NWS Nextcloud customer confirmed that he was able to make video calls without black screens as soon as he added in the TURN server details that I sent him.
Feel free to check out our Software as a Service platform NWS where you can test Nextcloud 30 days for free.

Gabriel Hartmann
Gabriel Hartmann
Systems Engineer

Gabriel hat 2016 als Auszubildender Fachinformatiker für Systemintegrator bei NETWAYS angefangen und 2019 die Ausbildung abgeschlossen. Als Mitglied des Web Services Teams kümmert er sich seither um viele technische Themen, die mit den NETWAYS Web Services und der Weiterentwicklung der Plattform zu tun haben. Aber auch im Support engagiert er sich, um den Kunden von NWS bei Fragen und Problemen zur Seite zu stehen.

Nextcloud with Collabora Online

Nextcloud offers plenty of different useful apps. Many of them work straight away with no further configuration, but some of them require you to complete additional setup steps or even to have extra services running. One of them is Collabora Online. In this post I won’t go into detail about the setup steps and the problems you might experience. Instead I’ll show how well Collabora Online integrates into Nextcloud.
 

 

 
 
 

How to Collaborate

So how do you get started if you have Nextcloud and Collabora up and running? First you need some additional users to share your files with. I would recommend to create some groups if you plan on sharing files with multiple users at once. Then add users to these groups. Create some folders for different purposes and share them with the groups. The folders will appear on the other users accounts as soon as they log in to Nextcloud or reload the page.
So now you’ll be able to collaborate on editing the files located inside the shared folders. You can create new spreadsheet (.ods), text document (.odt) and presentation files (.odp) right from your Nextcloud or you can also upload and edit existing files in all kinds of different office file formats. In the following short video I documented the steps of sharing and collaborative editing.
 


 
Another way of sharing files in groups is to enable the “Group folders” module in the Nextcloud Appstore and then create some folders from the Admin-Panel in the “Group folders” section. It simplifies the process of sharing folders in groups and you can even set quota limits for the shared folders.
 


Group folders

 
Something to note: if your Nextcloud is reachable from multiple domains and you want to use collaborative editing, then you and the person with whom you want to edit a document with should access Nextcloud from the same domain. If you try to use collaborative editing by accessing from different domains or sub-domains, it wont work, you won’t see the changes made by the other person inside the document in real-time.
What if you want to collaborate with a person who has no user account on your Nextcloud? You can share files via link, set optionally an expiration date and a password and then start collaborating with anyone. Just provide them with the shared link (and password if set) and they will be able to use Collabora aswell.
 

CODE and alternatives

Collabora itself is based on LibreOffice and has a lot of features built-in that you may know from other office applications. But there are some limitations in terms of concurrent open documents and simultaneous connections. In the free version CODE (Collabora Online Development Edition) it is limited to 10 documents and 20 connections at once. There is another online office suite that you can use with Nextcloud, it’s called Onlyoffice. For Nextcloud you would set up a Onlyoffice Document Server and then get the Onlyoffice App from the Nextcloud Appstore. In comparison to CODE it requires more hardware resources. At least 1 CPU core (with 2 GHz), 2 GB of RAM and 40 GB of disk space. Collabora on the other hand will be fine with 1 CPU Core, 512 MB of RAM and 1.5 GB disk space.
 

Try Nextcloud with CODE for free

If you want to try it yourself you can quickly spin up a Nextcloud app using our Netways Web Services and test Nextcloud with Collabora Online for 30 days for free. We now include Collabora preconfigured in all our Nextcloud plans.
 

Gabriel Hartmann
Gabriel Hartmann
Systems Engineer

Gabriel hat 2016 als Auszubildender Fachinformatiker für Systemintegrator bei NETWAYS angefangen und 2019 die Ausbildung abgeschlossen. Als Mitglied des Web Services Teams kümmert er sich seither um viele technische Themen, die mit den NETWAYS Web Services und der Weiterentwicklung der Plattform zu tun haben. Aber auch im Support engagiert er sich, um den Kunden von NWS bei Fragen und Problemen zur Seite zu stehen.

Monthly Snap July < Icinga Director, OSBConf, Braintower, SSL, Apply For, Nextcloud, Web Accelerator, …

July started with lots of heat and Isabel told us how to recognize heat with HW Group STE2.
Florian went on with some simple examples for Flexbox in practice and Dirk told us about automated Monitoring with Puppet and the Icinga 2 Agent.
Christian gave an insight behind the scenes of our webinars and Julia announced the Foreman Birthday party at NETWAYS.
Bernd contuinued with his Blogpost on mistakes and how to deal with while Isabel announced the new Software Update for the Braintower SMS Gateway.
Gabriel went on with how to administrate Nextcloud using CLI and Julia gave 7 reasons to join the Open Source Backup Conference.
Martin K. explained the benefits of Web Accelerator and Georg told us how to simplify SSL. Later in July, Gunnar gave an insight in tracking tasks with Todoist and the Icinga Director News were announced by Thomas G. July ended up with the announcement of 24/7 Braintower Support by Isabel and Tobi’s video on Apply services and Apply For in the Icinga Director.

How To Administrate Nextcloud Using CLI

With Nextcloud you can configure almost everything using the Webinterface.
But you may do updates and configuration also via CLI.
In this How To I’ll go over some common use-cases for the Nextcloud CLI.
 

Update / Upgrade

Let’s start with upgrading to the newest version. Go to the directory where your nextcloud is located – there should be a folder called ‘updater’.

[root@nc-vm ~]# cd /var/www/nextcloud/updater
[root@nc-vm ~]# ls
index.php  updater.phar

Inside the updater folder is a file called updater.phar.
Now execute the following command.

[root@nc-vm ~]# sudo -u www-data php updater.phar
Current version is 11.0.3.
Update to Nextcloud 12.0.0 available. (channel: "stable")
Following file will be downloaded automatically: https://download.nextcloud.com/server/releases/nextcloud-12.0.0.zip
Steps that will be executed:
[ ] Check for expected files
[ ] Check for write permissions
[ ] Enable maintenance mode
[ ] Create backup
[ ] Downloading
[ ] Extracting
[ ] Replace entry points
[ ] Delete old files
[ ] Move new files in place
[ ] Done
Start update? [y/N] y

Confirm with ‘y’ to start the update.

Info: Pressing Ctrl-C will finish the currently running step and then stops the updater.
[✔] Check for expected files
[✔] Check for write permissions
[✔] Enable maintenance mode
[✔] Create backup
[✔] Downloading
[✔] Extracting
[✔] Replace entry points
[✔] Delete old files
[✔] Move new files in place
[✔] Done
Update of code successful.
Should the "occ upgrade" command be executed? [Y/n] Y

After the new files have been moved in place you’ll have to confirm to execute the “occ upgrade” command.

Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Set log level to debug
Updating database schema
Updated database
Updating federatedfilesharing ...
Updated federatedfilesharing to 1.2.0
Updating files_pdfviewer ...
Updated files_pdfviewer to 1.1.1
Updating files_texteditor ...
..
..
Checking for update of app workflowengine in appstore
Checked for update of app "workflowengine" in appstore
Starting code integrity check...
Finished code integrity check
Update successful
Maintenance mode is kept active
Reset log level
Keep maintenance mode active? [y/N] N

And finally you enter ‘N’ to disable the maintenance mode

Maintenance mode is disabled

And that’s it. But note: even if it tells you that a lot of apps are be updated, you may find that not all of your apps have been updated.
 

OCC Command

Next we’ll explore the features of the occ command.

[root@nc-vm ~]# cd /var/www/nextcloud
[root@nc-vm ~]# sudo -u www-data php occ

You will get a long list of the available options and commands.

Nextcloud version 12.0.0
Usage:
  command [options] [arguments]
Options:
  -h, --help            Display this help message
  -q, --quiet           Do not output any message
  -V, --version         Display this application version
      --ansi            Force ANSI output
      --no-ansi         Disable ANSI output
  -n, --no-interaction  Do not ask any interactive question
      --no-warnings     Skip global warnings, show command output only
  -v|vv|vvv, --verbose  Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
  _completion                         BASH completion hook.
  check                               check dependencies of the server environment
  help                                Displays help for a command
  list                                Lists commands
  status                              show some status information
  ..
  ..
versions
  versions:cleanup                    Delete versions
  versions:expire                     Expires the users file versions

I won’t be able to cover all of them in this post. But I’ll go over a view of them in the following.
 

Reset Admin Password

This is pretty useful if you forgot your admin password and you find yourself locked out of your Nextcloud.

[root@nc-vm ~]# sudo -u www-data php /var/www/nextcloud/occ user:resetpassword admin
Enter a new password:
Confirm the new password:
Successfully reset password for admin

 

Change Log Level

Sometimes you to increase the log level to figure out what is wrong. By default the log level is set to ‘warning’ (level 2).
To get more information you’ll have to decrease the number. So 1 is level ‘info’ and 0 is for ‘debug’.
You may also set it to ‘error’ which is level 3 to get less information.

[root@nc-vm ~]# sudo -u www-data php occ log:manage --level 0
Enabled logging backend: file
Log level: Debug (0)
Log timezone: UTC

 

Encryption

For server side encryption it’s necessary to enable the encryption app first.
(In Nextcloud Version 12.0.0 and prior enryption does not work with S3 object store as primary storage.)

[root@nc-vm ~]# sudo -u www-data php occ app:enable encryption
encryption enabled

And then enable encryption

[root@nc-vm ~]# sudo -u www-data php occ encryption:enable
Encryption enabled
Default module: OC_DEFAULT_MODULE

Note that only new uploaded files will be encrypted and not the existing ones.
In order to encrypt all existing files of all users you will have to issue the following command:

[root@nc-vm ~]# sudo -u www-data php occ encryption:encrypt-all
You are about to encrypt all files stored in your Nextcloud installation.
Depending on the number of available files, and their size, this may take quite some time.
Please ensure that no user accesses their files during this time!
Note: The encryption module you use determines which files get encrypted.
Do you really want to continue? (y/n) y

Continue with ‘y’. You may notify the users by mail about their private key passwords.
But this only works if the users have provided their email-addresses.

Encrypt all files with the Default encryption module
====================================================
Create key-pair for every user
------------------------------
This module will encrypt all files in the users files folder initially.
Already existing versions and files in the trash bin will not be encrypted.
 Key-pair created for all users
 [============================]
Start to encrypt users files
----------------------------
 all files encrypted
 [>---------------------------]
Generated encryption key passwords
----------------------------------
+-----------+----------------------+
| Username  | Private key password |
+-----------+----------------------+
| admin     | BqaK1WtI             |
+-----------+----------------------+
A list of all newly created passwords was written to data/oneTimeEncryptionPasswords.csv
Each of these users need to login to the web interface, go to the
personal settings section "basic encryption module" and
update the private key password to match the login password again by
entering the one-time password into the "old log-in password" field
and their current login password
Do you want to send the passwords directly to the users by mail? (y/n) n

 

Configuration

Usually the config file for Nextcloud is located in /var/www/nextcloud/config.
So in order to change the configuration you may edit the file /var/www/nextcloud/config/config.php with a text editor.
But you can also import a custom config file in json format. In this example I imported a config to set Ceph S3 object store as primary storage for Nextcloud:

[root@nc-vm ~]# cat objectstore.json
{"system": {
        "objectstore": {
            "class": "OC\\\\Files\\\\ObjectStore\\\\S3",
            "arguments": {
                    "bucket": "$RGW_BUCKET",
                    "autocreate": true,
                    "key": "$RGW_KEY",
                    "secret": "$RGW_SECRET",
                    "hostname": "$RGW_HOSTNAME",
                    "use_ssl": true,
                    "use_path_style": true
            }
        }
}}
[root@nc-vm ~]# sudo -u www-data php occ config:import objectstore.json
Config successfully imported from: objectstore.json

It’s also possible to view only specific sections of the config:

[root@nc-vm ~]# sudo -u www-data php occ config:system:get objectstore
class: OC\\Files\\ObjectStore\\S3
arguments:
  bucket: $RGW_BUCKET
  autocreate: true
  key: $RGW_KEY
  secret: $RGW_SECRET
  hostname: $RGW_HOSTNAME
  use_ssl: true
  use_path_style: true

 

Apps

To get a list of all installed enabled and disabled apps:

[root@nc-vm ~]# sudo -u www-data php occ app:list
Enabled:
  - activity: 2.5.2
  - bruteforcesettings: 1.0.2
  - calendar: 1.5.3
  - comments: 1.2.0
  ..
  ..
  - workflowengine: 1.2.0
Disabled:
  - admin_audit
  - encryption
  - files_external
  - previewgenerator
  - user_external
  - user_ldap

To enable/disable apps:

[root@nc-vm ~]# sudo -u www-data php occ app:enable previewgenerator
previewgenerator enabled
[root@nc-vm ~]# sudo -u www-data php occ app:disable calendar
calendar disabled

 
Like I mentioned before, there are many more commands and the ones I picked are just a view of them.
But I hope they were useful at least for some of you.

Gabriel Hartmann
Gabriel Hartmann
Systems Engineer

Gabriel hat 2016 als Auszubildender Fachinformatiker für Systemintegrator bei NETWAYS angefangen und 2019 die Ausbildung abgeschlossen. Als Mitglied des Web Services Teams kümmert er sich seither um viele technische Themen, die mit den NETWAYS Web Services und der Weiterentwicklung der Plattform zu tun haben. Aber auch im Support engagiert er sich, um den Kunden von NWS bei Fragen und Problemen zur Seite zu stehen.

NETWAYS Web Services: Nextcloud Hosting

NextcloudNextcloud ist die perfekte Lösung zur Speicherung von privaten Daten, Fotos usw. und zum Filesharing in Teams und Unternehmen. Als Fork von ownCloud gestartet, kann sich dieses Open Source Projekt durch eine Vielzahl von Optionen, die bei ownCloud nur in der Enterprise Version enthalten sind, von seinem Ursprung absetzen. Wir nutzen vor allem die S3-Integration, über welche wir den entsprechenden Speicherplatz über unser hochverfügbares Ceph-Storage zur Verfügung stellen. Einen schönen Vergleich zwischen ownCloud und Nextcloud von Gabriel gibt es hier bei uns im Blog.
Über die NETWAYS Web Services können wir Nextcloud Instanzen in verschiedenen Größen für alle Einsatzzwecke zur Verfügung stellen – natürlich voll von uns gemanaged.
Nextcloud kann komplett über das Webinterface bedient werden und es werden Clients für alle wichtigen Betriebssysteme und Apps für iOS und Android zur Verfügung gestellt.

Nextcloud Webinterface

Nextcloud Webinterface


Und das beste – Sie können Nextcloud bei uns 30 Tage kostenfrei testen. Jetzt schnell anmelden!

Martin Krodel
Martin Krodel
Head of Sales

Der studierte Volljurist leitet bei NETWAYS die Sales Abteilung und berät unsere Kunden bei ihren Monitoring- und Hosting-Projekten. Privat reist er gerne durch die Weltgeschichte und widmet sich seinem ständig wachsenden Fuhrpark an Apple Hardware.