How to Host and Share Big Files Online with PicoShare in Linux

Spread the love

Picoshare is a lightweight and highly accessible file sharing web app for Linux. It provides an easy-to-use interface where you can upload and share files from your own server. This article will show you how to install Picoshare and share files online using Docker in Ubuntu Linux.

Content

Why Use Picoshare to Share Files Online

One of the biggest selling points of PicoShare is that it’s effortless to deploy on any Linux-based platform. With the help of Docker, you can share files online with PicoShare without worrying about Linux dependencies and program compatibility.

Another selling point of PicoShare is that it doesn’t manipulate the files you upload to its platform. This makes it useful for sharing pictures and videos, since you can be sure that the server will not re-encode your media as you upload it.

Lastly, PicoShare comes with the ability to duplicate its file storage to external object storage solutions. For instance, you can link your Amazon S3-compatible bucket to your PicoShare server and create a 1:1 backup of your server’s contents. This makes it easy to restore data when migrating from one system to another.

Installing the Prerequisites for PicoShare

Assumption: This tutorial is done on an Ubuntu 24.04 machine with at least 2 GB of RAM and 50 GB of disk space. You will need to have a domain name that you can create “A” records for that domain. Lastly, this article will use DigitalOcean Spaces for its S3-compatible object storage backend.

Note: While the instructions here are for Ubuntu, they should also work for most Linux distributions.

The first step in installing PicoShare is to obtain both Docker and Nginx for your host system (for other Linux distributions, here is how to install Docker on your Linux systems). To start, retrieve the signing key for the Docker project’s repository:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Create a new apt repository file using your favorite text editor:

sudo nano /etc/apt/sources.list.d/docker.list

Paste the following line of code inside your new repository file:

deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu noble stable

Save your repository file, then update both the system’s repository listings and its current packages:

sudo apt update && sudo apt upgrade

Install Docker, Docker Compose, and Nginx using apt in Ubuntu:

sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-buildx-plugin nginx

Creating a Cloud Storage Backup for PicoShare

Go to your S3-compatible cloud storage provider, then create a new storage bucket. In this case, I’m using DigitalOcean Spaces so I will click Create -> Spaces Object Storage on my dashboard screen.

Select a Datacenter location for your S3-compatible storage, then tick the Enable CDN checkbox.

Provide a name for your new Spaces bucket, then click Create a Spaces Bucket to initialize it.

Click the Copy Icon on the Origin Endpoint textbox and paste it on a separate text file.

Scroll through the left sidebar of your DigitalOcean Dashboard, then click the API category.

Click the Spaces Keys tab, then select Generate New Key.

Provide a name for your new key, then click Create Access Key.

Copy both the “Access Key” and “Secret Key” from the page and paste it to your text file.

Installing and Running PicoShare

Create a new folder for PicoShare inside your user’s home directory, then go inside it:

mkdir ~/picoshare && cd ~/picoshare

Use your favorite text editor to create the Compose file for PicoShare:

nano ./docker-compose.yml

Paste the following block of code inside your new .yml file:

version: "3.2"
services:
  picoshare:
    image: mtlynch/picoshare
    environment:
      - PORT=4001
      - PS_SHARED_SECRET=RANDOM PASSWORD HERE
      - LITESTREAM_BUCKET="YOUR BUCKET NAME"
      - LITESTREAM_ENDPOINT="YOUR ORIGIN ENDPOINT HERE"
      - LITESTREAM_ACCESS_KEY_ID="YOUR BUCKET ACCESS ID HERE"
      - LITESTREAM_SECRET_ACCESS_KEY="YOUR BUCKET SECRET HERE"
    ports:
      - 4001:4001
    command: -db /data/store.db
    volumes:
      - ./data:/data

Replace the value of the “PS_SHARED_SECRET” variable with a sufficiently long and random password. This will serve as the password for PicoShare’s web interface.

Note: you can generate your own random password by running: cat /dev/urandom | tr -dc 'A-Za-z0-9' | fold -w 32 | head -n 1 on a separate terminal session.

Change the value of the “LITESTREAM_BUCKET” variable with the name of your Spaces bucket.

Copy the region and domain name portion of your endpoint, then paste it as the value of your “LITESTREAM_ENDPOINT” variable.

Replace the values of both the “LITESTREAM_ACCESS_KEY_ID” and the “LITESTREAM_SECRET_ACCESS_KEY_ID” variables with DigitalOcean Spaces bucket’s Access Key and Secret Key.

Save your docker-compose.yml file, then run the following command to build and run the PicoShare instance:

sudo docker compose up -d

On a side note: you can also use Docker and Docker Compose to quickly host a Minecraft server on your Linux machine.

Securing PicoShare with an SSL Reverse Proxy

At this point, you now have PicoShare running at port 4001 on your local machine. In order to access it securely on the internet, you need to make sure that all connections to it are encrypted via SSL.

Start by creating a new “A” record for your domain name pointing to the IPv4 address of your PicoShare server. In my case, I will create an “A” record with the value “picoshare.”

Install the “core” snap package on your Ubuntu system:

sudo snap install core

Fetch the certbot snap package from the Electronic Frontier Foundation (EFF):

sudo snap install certbot --classic

Create a new Nginx site configuration file using your favorite text editor:

sudo nano /etc/nginx/sites-available/picoshare

Paste the following block of code inside your site config file:

server {
 
        server_name SUBDOMAIN.YOUR-ROOT.DOMAIN;
 
        location / {
                proxy_pass http://127.0.0.1:4001;
                proxy_http_version 1.1;
                proxy_redirect off;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header X-Forwarded-Proto https;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header Host $host;
                client_max_body_size 0m;
        }
}

Save your site configuration file, then create a symbolic link from your “/etc/nginx/sites-available/” directory to your “/etc/nginx/sites-enabled/” folder:

sudo ln -s /etc/nginx/sites-available/picoshare /etc/nginx/sites-enabled/

Double-check your Nginx config file for any errors, then start the Nginx webserver daemon using systemctl:

nginx -t
sudo systemctl enable --now nginx.service

Register your PicoShare server using EFF’s certbot utility:

sudo certbot register --agree-tos -m YOUR-EMAIL@ADDRESS.HERE

Generate a new SSL certificate pointing to your server’s domain name:

sudo certbot --nginx -d SUBDOMAIN.YOUR-ROOT.DOMAIN

Good to know: learn how HTTPS protects your data online by generating your own SSL certificate with OpenSSL.

Testing PicoShare and Uploading Your First File

Open a web browser, then navigate to your subdomain to load the PicoShare landing page.

Click the Log In button on the page’s upper right corner.

Provide the value of the “PS_SHARED_SECRET” on the Passphrase textbox, then click Authenticate to login.

Check whether you can save data on your PicoShare server by clicking the Upload button, then select a sample file through the picker menu.

Copy the first link that the server returns to the user that you want to share your file to.

Enable Temporary Guest Uploads on PicoShare

Aside from user-submitted uploads, you can also create temporary links that allow anonymous users to upload single files on your server. This can be useful if you have someone that needs to share files with you but can’t upload files to a regular cloud service.

Start by clicking the Guest Links category on PicoShare’s homepage.

Click the Create New button just above the empty link overview table.

Provide the basic details for your guest upload link. In my case, I will label it as “MakeTechEasier” and set the expiry to Never with a file size limit of 100MB and an overall limit of 10 uploads.

Click Create to generate the temporary guest link for your PicoShare instance.

Click the Copy Icon on the right-hand side of the guest link, then send the content of your clipboard to the intended recipient.

Deploying and securing PicoShare to share files online using Linux is just the first step in reclaiming your digital privacy online. Learn how you can further protect yourself by hosting your own email aliases server using SimpleLogin.

Image credit: Alejandro Escamilla via Unsplash and PicoShare Github. All alterations and screenshots by Ramces Red.

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Sign up for all newsletters.
By signing up, you agree to our Privacy Policy and European users agree to the data transfer policy. We will not share your data and you can unsubscribe at any time. Subscribe


Ramces Red
Staff Writer

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.

Leave a comment