BLOG Private Cloud, Made Simple: NextCloud + Raspberry Pi Setup
David Schmid
  • Author: David Schmid
  • Date: 24.11.2024 Last Update: 24.11.2024, 15:03
  • Categories: DIY Projects

Picture this: A cloud service that gives you full control over your data - free of charge, free from big tech's reach and just as convenient. Sounds ideal, doesn't it?

This is where NextCloud, hosted on a Raspberry Pi, steps in.

With a little tinkering, you can transform a Raspberry Pi into your private cloud server, offering everything from file storage to collaboration tools - all while keeping control of your data.

Image NextCloudPi

Table of Contents

(1) Introduction

(1-1) Why NextCloud?

We’re all familiar with services like Dropbox, Google Drive, and iCloud Drive. They’re convenient, sure, but come with a tradeoff: your data is stored on someone else’s servers. If you value privacy or want to avoid recurring subscription fees, NextCloud is the perfect alternative.

NextCloud is a free, open-source platform that can do much more than just store files. It offers features like calendars, collaborative document editing, and even communication tools. Plus, with a plugin system, its capabilities are nearly endless. Best of all, when hosted on your own Raspberry Pi, your data stays in your hands.

Image: Nextcloud Document Colaboration

(1-2) Why Raspberry Pi?

You might think setting up a private cloud requires expensive servers or hosting plans, but the Raspberry Pi makes it both affordable and accessible. For just a fraction of the cost of traditional web hosting, you can use a Pi to power your NextCloud instance. With a bit of preparation and the help of NextCloudPi - a preconfigured image designed to simplify the process - you’ll be up and running in no time.

(1-3) About This Guide

In this guide, we’ll focus on using NextCloudPi, a pre-built image with everything you need to set up NextCloud. While it’s possible to manually install NextCloud on an existing Raspberry Pi OS, this method is more complex, requiring extensive configuration of web servers, databases and more. NextCloudPi saves you the headache and gets you started faster.

(1-4) Important Considerations

Your setup choices also depend on how you plan to use your NextCloud instance:

  • Local Network Only: For a private home cloud, minimal configuration is needed and you can rely on your router for basic security.

  • Accessible from the Internet: If you want to access your cloud remotely, be prepared to configure additional security measures, such as:

    • Port forwarding rules.
    • SSL certificates (e.g., Let’s Encrypt).
    • Firewall configurations.

Note: Exposing your NextCloud instance to the internet requires careful security planning. This guide focuses on a basic home network setup but includes tips for extending functionality safely.

Now, let’s get started!

(2) Preparation Checklist: What You Need to Set Up NextCloudPi on a Raspberry Pi

Before diving into the setup, let’s make sure you have everything you need for a smooth experience.

(2-1) Hardware

  • Raspberry Pi (minimum recommended: Pi 4): A Raspberry Pi 4 or higher is recommended for better performance thanks to its faster CPU and more RAM.

  • microSD Card (8 GB minimum): This is where the OS will be installed. While larger capacities are fine, 8–16 GB is more than sufficient for the operating system itself.

  • microSD Card Adapter: You’ll need this to connect the microSD card to your computer to flash the image.

  • External Storage (Highly Recommended): Store your cloud data on external storage to keep the Pi’s resources free. Options include an external SSD / HDD with a recommended space of 120 GB or more.

  • Ethernet Cable: For a stable and fast connection, plug your Raspberry Pi directly into your router instead of relying on Wi-Fi.

  • Power Supply for Raspberry Pi: Use an official or high-quality power supply that provides sufficient wattage to avoid stability issues.

  • Backup Solution: Protect your data! Whether it’s a NAS, an external drive, or another Raspberry Pi set up for backups, it’s important to have redundancy in case of failure.

Optional: If you prefer not to use SSH or a web interface during setup, you can use a monitor (with a micro-HDMI cable) and a keyboard. However, this guide assumes you’ll set up everything remotely after booting the Raspberry Pi.

My Setup Example: I personally use a db-tronic Raspberry Pi 5 Starter Kit (8 GB RAM), which includes a fan-cooled case, a reliable power supply and a pre-configured microSD card. For storage, I’ve paired it with a SanDisk Extreme Portable SSD (2 TB) for data and integrated backups with a Western Digital NAS for added safety.

Image: My NextCloudPi Setup

(2-2) Software

  • Client Computer: This is your main device for flashing the image, connecting via SSH, and managing the web interface.

  • Image Writing Tool: Use tools like Balena Etcher for a user-friendly interface or dd (on Linux) for a command-line option to flash the NextCloudPi image to your microSD card.

  • NextCloudPi Image: Download the pre-configured image from the NextCloudPi GitHub repository. It’s based on Raspberry Pi OS Lite and includes everything you need to get started.

  • SSH Client: Essential for connecting to the Raspberry Pi remotely. Use ssh via terminal (Linux/Mac) or tools like PuTTY (Windows).

  • Optional Networking Tools: Tools like nmap can be helpful for locating your Raspberry Pi’s IP address on the network after setup.

  • Password Management Tool (Optional): A tool like Bitwarden or KeePass is invaluable for managming the long, complex passwords generated during the initial setup. Having a reliable way to store them will save you frustration.

(3) Flashing NextCloudPi onto Your Raspberry Pi

(3-1) Format Your microSD Card

  1. Format the microSD card: Make sure, the microSD card is clean and ready for flashing. If necessary, use a tool like GParted or one of your operating system's disk utility to format the microSD card. Recommended filesystem: exFAT for compatibility.

  2. Optional: Format External Storage: If you're connecting external storage (SSD/HDD) for your cloud data, you should format it with a Linux-compatible filesystem such as ext4 or BTRFS. However, this can also be done later in the NextCloudPi setup wizard.

(3-2) Download the NextCloudPi Image

  1. Go to the NextCloudPi GitHub Releases Page. Image: Nextcloud Download
  2. Look for the latest release for Raspberry Pi. For example, select:
    NextCloudPi_RaspberryPi4_vx.xx.x.zip
  3. Verify the Download:

    • Use an MD5 checksum tool (e.g., md5sum in Linux) to calculate the checksum of the downloaded file:
      md5sum NextCloudPi_RaspberryPi4_vx.xx.x.zip
      
    • Compare the result with the checksum provided on the GitHub page to ensure the download is intact.
    • Important: The checksum has to be calculated over the zip file using md5.
  4. Unzip the downloaded file:

    unzip NextCloudPi_RaspberryPi4_vx.xx.x.zip
    					

    This will extract the .img file needed for the next step.

(3-3) Prepare the microSD Card

  • Insert the microSD card into your local computer (e.g., using a USB adapter).

  • Identify the microSD card device:

    • Run the lsblk command to list all storage devices:
      lsblk
      				
    • Look for the device representing your SD card (e.g., /dev/sdX or /dev/mmcblk0).
      Important: Double-check you’ve selected the correct device to avoid overwriting critical data!

(3-4) Write the Image to the microSD Card

You have two main options for writing the image:

Option 1: Using dd (Command Line)

  • Write the image to the SD card:

    sudo dd \
    if=/path/to/NextCloudPi_RaspberryPi4_xx_xx_xx.img of=/dev/sdX \
    bs=4M status=progress
                  
    • Replace /path/to/NextCloudPi_RaspberryPi4_xx_xx_xx.img with the path to your unzipped .img file.
    • Replace /dev/sdX with the device name of your SD card (e.g., /dev/sdb).
  • Wait until the process is complete. The status=progress option will show progress during the operation.

Option 2: Using Balena Etcher (or similar GUI Tools)

  • Download and install Balena Etcher or a similar GUI tool.
  • Open Balena Etcher (run with elevated privileges if needed).
  • Select the unzipped .img file.
  • Choose your SD card as the target device.
  • Click Flash and let the process complete.

(3-5) Boot Up the Raspberry Pi

  • Remove the microSD card from your computer and insert it into the Raspberry Pi.
  • Connect the Raspberry Pi:
    • Ethernet cable: Connect the Pi directly to your router for a stable connection.
    • External drive: Plug in the external HDD/SSD. For USB 3.0, use the blue USB ports for maximum speed.
    • Power supply: Plug in the power adapter to turn on the Raspberry Pi.
  • Let the Raspberry Pi boot. This may take a few minutes as it initializes the system and services.

Once the Pi has booted up, you’re ready to connect to it and begin configuring your NextCloud instance.

(4) Accessing and Configuring NextCloudPi

Once your Raspberry Pi has booted with the NextCloudPi image, it’s time to configure and access the system. NextCloudPi offers two main web interfaces:

  1. NextCloudPi Panel (Port 4443): For OS-level configurations and managing NextCloudPi-specific settings.
  2. NextCloud Panel (Port 443): For accessing and using your NextCloud instance.

Both are accessible via the Pi’s IP address or hostname in your browser.

(4-1) Determine Your Network Range

Home routers typically assign IP addresses in private ranges, such as 192.168.0.0/24, 192.168.1.0/24 o r 10.0.0.0/24

To identify your home network range:

  • Run the following command on your local computer:
    ip route | grep default 
    			  
    Example output:
    default via 192.168.1.1 dev wlan0 Here, 192.168.1.1 is your router's IP address, confirming the network range 192.168.1.0/24.

(4-2) Find Your Raspberry Pi’s IP Address

There are multiple ways to find the Raspberry Pi’s IP address:

  1. Using nmap (Recommended for Linux):
    Scan the network range identified earlier:

    nmap -sn 192.168.1.0/24 
    			  
    Example output:
    Nmap scan report for nextcloudpi.local (192.168.1.15)
    			  

    Note the IP address (e.g., 192.168.1.15) or hostname (e.g., nextcloudpi.local).
  2. Default Hostnames:
    If your network supports local hostname resolution, try accessing:
    http://nextcloudpi.local Some routers or network configurations may not support this. If it doesn't wor, use one of the other methods.

  3. Check Your Router:
    Log in to your router’s admin interface and look for connected devices. The Raspberry Pi should appear with its hostname (e.g., nextcloudpi) and assigned IP address.

(4-3) Access the NextCloudPi Panel

Open your browser and enter the Raspberry Pi’s IP address or hostname, followed by port 4443:

https://<RASPBERRY_IP>:4443

Example:
https://192.168.1.15:4443

You’ll likely see an HTTPS certificate error because NextCloudPi doesn’t ship with a trusted TLS certificate by default. It’s safe to ignore this for now. You can add a Let’s Encrypt certificate later.

(4-4) Initial Activation

  1. After logging in, you’ll see two passwords displayed:

    • NextCloudPi Panel Password: For configuring system settings.
    • NextCloud Admin Password: For accessing the NextCloud web interface.
  2. You have to store these passwords securely in a key management tool or print these passwords so you will have to use them later to change these passords if wished...

  3. Click Activate to finalize the initial setup.
  4. When you log in for the first time, you may see a setup wizard. Follow the steps or skip it for now.
Image: Nextcloud Activation

(4-5) USB Drive Configuration

If you're using an external USB drive for file storage:

  1. Plug the drive into your Raspberry Pi.

  2. During the setup wizard, you will see the option "Do you want to save NextCloud data in a USB drive?". Select Continue to configure the USB drive.

  3. If the drive is not formatted, choose Format USB to prepare it. This will erase all existing data on the drive and format it.

(4-6) Hostnames and Trusted Domains

When accessing your NextCloudPi instance, you might notice that your router assigns it a different hostname than the default nextcloudpi.local. For instance, some routers, particularly those provided by ISPs, may append a custom domain to device hostnames, such as nextcloudpi.provider.ip.

If the router doesn’t support .local hostnames or prefers its own scheme, it may override the default nextcloudpi.local hostname.

NextCloud requires that all hostnames or IPs used to access its interface are listed as trusted domains. If you access your NextCloud instance using a hostname like nextcloudpi.provider.ip without adding it to the trusted domains list, you’ll encounter a security warning.

Here’s how to fix it:

  1. Log in to the NextCloudPi Panel via:
    https://<RASPBERRY_IP>:4443

  2. Navigate to:
    CONFIG -> nc-trusted-domains

  3. In the Trusted Domains section, add your custom hostname:
    nextcloudpi.provider.ip

  4. Click Apply to save the changes.

Image: Nextcloud Trusted Domains Config

(5) Enable SSH and Set a Static IP

Setting up SSH access and a static IP for your Raspberry Pi ensures seamless and consistent connectivity, making management and advanced configurations more straightforward.

(5-1) Enable SSH Access on the NextCloudPi Panel

SSH (Secure Shell) provides remote command-line access to your Raspberry Pi, allowing you to configure it from another device.

  1. Open the NextCloudPi Panel:
    Visit the following in your web browser:
    https://<RASPBERRY_IP>:4443 Replace <RASPBERRY_IP> with your Pi’s IP address or nextcloudpi.local if your network supports hostname resolution.

  2. Enable SSH:

    • Navigate to NETWORKING > SSH in the menu.
    • Activate the SSH setting to enable it.
  3. Set a Separate SSH Login:

    • You’ll need to create a password for the default ncpadmin if it’s still set to 1234.
    • Important: The username ncpadmin is only shadowed and you have to type it in.
    Image: Nextcloud SSH Config
  4. Test SSH Access:

    • Open a terminal on your client computer.
    • Use the following command to connect to the Pi:
      ssh ncpadmin@<RASPBERRY_IP>
    • Replace <RASPBERRY_IP> with the Pi’s IP address. Enter the new password when prompted.

(5-2) Update NextCloudPi

Keeping your system up to date is crucial for security and stability. After connecting via SSH, run the following command:


sudo ncp-update 
		

This ensures that you’re running the latest version of NextCloudPi with all security patches applied.

(5-3) Set a Static IP Address

A static IP prevents your Raspberry Pi’s address from changing, ensuring reliable access.

  1. In the NextCloudPi Panel:

    • Go to NETWORKING > nc-static-IP.
  2. Enter the Required Details:

    • IP Address: Choose one within your network range (e.g., 192.168.1.100). Ensure it doesn’t conflict with other devices.
  3. Save and Reboot:

    • Reboot the Raspberry Pi directly from the panel (top-right menu) or via SSH:
      sudo reboot
  4. Verify the Static IP:

    • Reconnect via SSH to confirm the IP address hasn’t changed:
      ssh ncpadmin@<STATIC_IP>

(5-4) Use SSH Keys for Authentication

To simplify and secure SSH access, configure key-based authentication.

  1. Generate an SSH Key Pair on Your Client Computer:

    ssh-keygen -t rsa -b 4096 
    
    Save the key pair in the default location (~/.ssh/id_rsa).
  2. Copy the Public Key to the Raspberry Pi:
    ssh-copy-id ncpadmin@<PI_IP> 
    			
    Again, replace <PI_IP> with your Raspberry Pi’s IP address.
  3. (Optional) Disable Password Authentication:

    • Edit the SSH configuration file on the Raspberry Pi:
      sudo vim /etc/ssh/sshd_config
    • Set the following:
      PasswordAuthentication no
  4. Restart the SSH service:
    sudo systemctl restart ssh

(5-5) Set an Alias for Bash Access

To make SSH access even easier, you can define a Bash alias on your client computer:

  1. Open your .bashrc file:
    vim ~/.bashrc

  2. Add the alias:
    alias ssh-nc="ssh ncpadmin@<STATIC_IP>"

  3. Save and apply the changes:
    source ~/.bashrc

  4. Use the alias to connect:
    ssh-nc

☕ Let's Have a Coffee Break

You've just made it through some of the most technical parts of this guide - flashing images, configuring IPs, and diving into trusted domains. That’s no small feat! Let’s pause for a moment, grab a coffee (or tea), and celebrate the progress you've made so far in setting up your own private cloud.

If you're finding this guide helpful and it's making your Raspberry Pi adventure smoother, consider supporting my work. A cup of coffee fuels the late nights I spend testing, troubleshooting, and sharing these DIY projects with the world.

☕ Buy Me a Coffee

Writing these guides is a labor of love based on my personal experiences and experiments. Your support not only helps me stay caffeinated but also allows me to keep exploring, documenting, and sharing innovative tech solutions.

I also specialize in creating tailored tech solutions to bring your ideas to life. Whether it's enhancing your cloud setup, automating tasks, or optimizing workflows, I’d love to help you with your next project.

🔍 Discover My Services

Now that we're recharged, let's get back to the topic...

(6) Creating Users in NextCloud

One of NextCloud’s powerful features is its ability to support multiple users, making it ideal for families, teams, or organizations. As the admin, you can create and manage users with specific permissions and storage quotas.

(6-1) Log In as Admin and Navigate to User Management

  1. Open your NextCloud web interface:
    http://<RASPBERRY_IP>

  2. Log in using your admin credentials (default username: ncp, unless changed during setup).

  3. In the top-right corner, click your profile picture or initials.

  4. Select Users from the dropdown menu.
Image: Nextcloud Account Setup

(6-2) Add a New User

  1. On the Users page, click the "+ New User" button.
  2. Enter the following details:

    • Username: The unique identifier for the user (e.g., john_doe).
    • Password: Create a secure password or leave it blank to generate a random one (which you can share with the user).
  3. Assign the user to a group (optional):

    • Default group is “Everyone.” You can create custom groups (e.g., “Family” or “Team”) for easier management.
  4. Set a Storage Quota (optional):

    • You can limit the user’s storage space by selecting a predefined quota (e.g., 1 GB, 10 GB) or leaving it as unlimited.
  5. Click Create to finalize the user.

(6-3) Customize User Permissions

Once the user is created, you can adjust their permissions and roles:

  1. Groups:

    • Assign the user to additional groups for role-based permissions or file-sharing purposes.
  2. Admin Access:

    • Grant admin privileges by selecting the Admin checkbox next to their name.
  3. Additional Apps:

    • Enable or restrict access to specific NextCloud apps (e.g., Calendar, Contacts, OnlyOffice).

(7) Start Using NextCloud

With NextCloud successfully set up on your Raspberry Pi and external storage configured, it’s time to dive into using your private cloud. This section provides an overview of how to access and start utilizing NextCloud for file storage, sharing, and more.

(7-1) Navigate the Dashboard

  1. Log in with your NextCloud credentials on your web browser with the IP address or hostname and use your users username and password.

  2. Navigate the NextCloud Dashboard: After logging in, you’ll see the NextCloud Dashboard, which provides:

  • File Manager: The main area for managing and organizing your files.
  • Activity Feed: Tracks recent actions, such as uploads, downloads, and shares.
  • Quick Links: Access frequently used features like Calendar, Photos, or Tasks.

(7-2) Upload Your Files

  1. Go to the Files section in the NextCloud interface.
  2. Click the "+" button or drag and drop files from your computer directly into the browser.
  3. Organize files into folders as needed.

(7-3) Explore NextCloud Features

NextCloud is much more than a file storage platform. Some features to explore:

  1. Calendar and Contacts

    • Sync your calendar and contacts across devices.
    • Enable these apps via Apps > Enable Calendar or Contacts.
  2. Collaboration Tools

    • Use OnlyOffice or Collabora Online to edit documents directly in your browser.
    • Collaborate in real-time with shared documents.
  3. Tasks and Notes

    • Organize tasks and to-dos with the Tasks app.
    • Use Notes for quick memos and ideas, synced across devices.
  4. Plugins and Extensions

    • Install additional apps like a music player, RSS reader, or password manager to extend functionality.

(7-4) Secure Your NextCloud

For better privacy and security:

  1. Enable Two-Factor Authentication (2FA):

    • Go to Settings > Security and enable 2FA with an authenticator app.
  2. Install SSL Certificates:

    • Use Let’s Encrypt via the NextCloudPi Panel to secure your instance with HTTPS.
  3. Regular Backups:

    • Use the NextCloudPi Panel to configure automatic backups to an external drive or cloud service.

(7-5) Monitor Usage and Performance

  1. Check your storage usage under Settings > Personal > Storage Usage.
  2. Monitor server performance using system tools or the NextCloudPi Panel.

(8) Install NextCloud Clients

NextCloud provides desktop and mobile clients for seamless syncing and access:

(8-1) Desktop Clients

  1. Download the NextCloud client for your operating system:
    NextCloud Desktop Client
  2. Install and log in with your NextCloud credentials.
  3. Choose folders on your computer to sync with NextCloud automatically.

(8-2) Mobile Apps

  1. Install the NextCloud app on your smartphone or tablet:
  2. Log in and configure auto-upload for photos and videos to keep them backed up.
Image: Nextcloud Android

(9) Conclusion

Setting up NextCloud on a Raspberry Pi is a rewarding project that puts you in full control of your data. With just a bit of preparation and guidance, you've transformed a compact, affordable device into a powerful private cloud server.

Now it's your turn! Expore its features and make it your own! With the freedom and flexibility it offers, the possiblilities are endless.

Got questions or ideas? Share them in the comments below! I'd love to hear about your setup and experiences!

Comments

No comment on this post yet... Initiate the dialogue - be the first to illuminate this page with your thoughts!

Leave a Comment

Please preserve the rules of respect and avoid any shadow that might fall upon the realm. Keep your discourse pure and use simple characters. Your scroll shall contain no more than a thousand characters.

Only the worthy may share their wisdom beneath the sacred tree of insight. To prove yourself a true hero and not a shadowy automation, solve this puzzle:

captcha