I wanted to create a personal version of DropBox, using my own hosting, in order to get around the privacy concerns of that service. I found this nifty application (despite the awful, awful name) called Sparkleshare which claimed to do exactly that, being a client interface to a git repository.
I wanted to use a git repository on my own hosting – webfaction – but couldn’t find a complete tutorial, so thought I’d reproduce the steps here. Thanks to Neum for getting me most of the way there.
1. Install git on your host
Log into your webfaction control panel, and create a new git application. This is covered exhaustively in the webfaction docs.
2. Create a new git repository
Log into your webfaction account via ssh, and at the terminal move to your git repository directory:
where ‘git’ is replaced by the name you gave your git application in step 1.
Create the repository, substituting your own title for REPONAME, and then allow http push:
git init --bare REPONAME.git
git config http.receivepack true
3. Create a new ssh user
We don’t really want to use our main ssh login here, so for security it would be better to create a new ssh user specific to this application.
Log into your webfaction control panel again, and go to Account->SSH/SFTP Users. Click ‘add new user’ and give your new user a username and password, and shell ‘/bin/bash’. Do not add them to any groups, just click ‘Save’.
By default, this user will have access to all directories on your server – if desired, you could restrict this via use of setfacl.
4. Install Sparkleshare
Install the client software for your platform. The instructions from this point are for Windows, but other Linux/MacOS tutorials are available.
5. Set up RSA keys
Once installed, find the tray icon for Sparkleshare, left click on it, and click on Sparkleshare->Client ID->Copy to clipboard. This will copy the public RSA key generated when the client software was installed to the clipboard.
Connect to your hosting via ssh again, and if one doesn’t already exist, create a new ssh directory in your home directory:
mkdir -p $HOME/.ssh
Open the ‘authorized_keys’ file with a text editor (this will create it if it does not already exist):
nano -w ~/.ssh/authorized_keys
Paste the Sparkleshare RSA key into the file, and make sure it is all on one line – when I copied it, two line returns had to be removed. Exit and save the file.
6. Add repository to Sparkleshare
Click on Sparkleshare in the system tray again, and click ‘Sparkleshare->Add Hosted Project’. Under address put ‘ssh://USERNAME@ACCOUNTNAME.webfactional.com’, where USERNAME is the ssh account username set up in step 3, and ACCOUNTNAME is the unique name given to your hosting (usually the username of the primary login). Under Remote Path put ‘/home/ACCOUNTNAME/webapps/APPLICATIONNAME/repos/REPONAME.git’, where ACCOUNTNAME is as above, APPLICATIONNAME is the name given to your git application in step 1, and REPONAME is the name of your git repository in step 2. Click ‘Add’.
If all works to plan, you now have a new repository which is available at Users\[Windows username]\SparkleShare\, and which will automatically update whenever files are added or updated on any client machine. To set up other clients, repeat steps 4 to 6 on other machines.
If you’re having trouble with public-key access, seperately try following the instructions for setting this up with PuTTY. If this also fails, you may need to contact webfaction support to restart the SSH service on your hosting.