SparkleShare, a self-hosted GDrive, OneDrive, Dropbox alternative

SparkleShare creates special folders on your computer that will be automatically kept in sync with a server and other connected clients. Each time you add, update or delete a file SparkleShare sends the update to the server and all other connected clients. This works very similar to Google Drive, Microsoft OneBox and DropBox, but with SparkleShare you have the freedom you use any server. What's interesting about SparkleShare is that it is using Git as the backend. It is basically a Git client combined with a directory watcher service. Each time you add, change or delete files, SparkleShare automatically commits and pushes the changes to the remote Git repository.

In this tutorial I use the Windows version of SparkleShare and connect it to a self-hosted Gitea Git server on a VPS running with Ubuntu 18.04. This is the server you end up with when you followed my previous tutorials about setting up a VPS and Gitea.

You don't necessarily have to set up your own server, SparkleShare works with any Git service that provides Git over SSH access, like BitBucket and GitHub.

On Windows, you download the .msi file and start it to install SparkleShare. Start SparkleShare and you see a little icon in the task bar.

As mentioned before SparkleShare is using Git as the backend. Because of this, you have to first create a Git repository on the server that you want to sync with. On my self-hosted Gitea server I create a new project and call it test. It is reachable with this URL: ssh://git@git.ralscha.ch:44933/sr/test.git

Next we have to add the public key of SparkleShare to the Git server. Right click on the SparkleShare application icon, then select SparkleShare -> Client ID -> Copy to Clipboard.

In Gitea you open the Your Settings menu and the SSH / GPG Keys tab. Click on the blue Add Key button in the Manage SSH Keys section.

Now paste the SparkleShare key into the Content text field and click the green Add Key button.

Right click on the application icon and select the menu item Add hosted project....

SparkleShare opens the following dialog.

Select On my own server and enter Address and Remote Path. Click Add and SparkleShare tries to clone the repository. If successful, you should find a new directory in your user home directory (C:\Users\<USER>\SparkleShare\test). The last part of the directory (test) corresponds with the name of the Git repository. You can connect more than one Git repository. Each repository gets its own subfolder in the C:\Users\<USER>\SparkleShare\ directory.

While SparkleShare is running it watches for changes in this folder. Add a new file, open the project in Gitea and you should see the new file there.

Because this is a normal Git project, you can add and change files with any other Git client. SparkleShare picks up the change and downloads it to your computer. Local changes will be synchronized immediately to the Git server, but if you change something from another client it takes a few minutes until SparkleShare picks up the change and downloads it to your computer. The reason for this is that by default there is no notification service that notifies SparkleShare of server changes and the client has to fall back to polling. If you experiment with multiple clients wait a few minutes until you see the changes propagated to all clients.

See this page https://github.com/hbons/SparkleShare/wiki/Notification-service if you are interested in using a notification service for immediate client synchronization. The page contains an example of a Git hook that sends a message to a notification service, SparkleShare clients can connect to this service and will be notified immediately when another client pushes changes to the remote repository. In the spirit of self-hosting you can also install the notification service on your own server.

Another interesting feature of SparkleShare is to encrypt files before sending them to the server. To enable this feature all you have to do is creating a Git repository with a name that ends with -crypto. For this example I created a repository with the name secret-crypto.

When you add the project SparkleShare asks for a password. It will use this password for encrypting every file with the AES-256-CBC algorithm that you add to this folder.

SparkleShare omits the -crypto suffix when it creates the folder on your local computer. In this example it creates the folder C:\Users\<USER>\SparkleShare\secret

The files are unencrypted on your local computer but when you open the file on the remote Git repository you see the file with encrypted content.

Note that the file names are not mangled and the file size of an AES encrypted file is very similar to the original file size. An attacker might deduce information just from the name and size of an encrypted file.

SparkleShare creates the folders by default in the users home directory under C:\Users\<USER>\SparkleShare. Although there is no built in function in the GUI to specify another folder, there is a way to do this manually.

In this example I move the test folder from C:\Users\<USER>\SparkleShare\test to e:\shares\test

Stop SparkleShare.

Move the folder test, open the configuration file %APPDATA%\sparkleshare\config.xml in a text editor and add a <path> tag inside <folder>.

You can also rename the folder then you have change the <name> configuration. Save the configuration file and start SparkleShare.

Instead of moving individual project folders to another location, you can move the whole C:\Users\<USER>\SparkleShare directory to another location. For that you add the <folders_path> tag inside <sparkleshare>. Stop SparkleShare, move the folder and start SparkleShare.

SparkleShare provides a script to set up Git very easily on a Linux server. This is useful if you run your own Linux server but are not interested in installing a full-blown Git server with Web interface like I describe in this blog post. This is a more lightweight solution that only requires a SSH server and the Git command line tools.

Login to your Linux server and then issue the following commands as root user: