AidanMontareDotNet

You are on the old part of aidanmontare.net, which I am no longer maintaining. Newer versions of some of this content can be found on the active part of my site, which you can reach from my homepage.

Really Quick File Sharing Server

(last updated

I already wrote my guide to making a DAViCal Calendar Server to synchronize calendars across multiple devices. One of my goals was to gradually offload the important files on my phone to backups in other places.

Aside from my calendars and todo lists, the only other important files on my phone were a bunch of text documents in the iPhone’s Note app. Some of them weren’t very interesting, but some were pretty important, and the Notes application is not the most secure place to save files you want to make sure you don’t lose. So I turned to my trusty Raspberry Pi server to whip up a solution to this problem.

Here we will take the Raspberry Pi from my DAViCal server project and add SFTP access. It takes about five minutes and gives you a really simple way to backup files on your mobile devices.

Warning

If there are things you don’t trust on your network, or you want a secure SFTP setup, don’t do this. Longer, more detailed guides will explain how to create a separate user and chroot it so that the devices can only access certain folders on the server. But I didn’t really feel like doing any of that when I set this up. If the server is on a private network and the only devices that you connect to it are your own, then this setup is a quick and dirty way to get the job done.

The Server

Setting up the server is really quick if we aren’t so concerned about restricting access. We will assume you are using the standard pi user here, but I could be any user really.

First we will edit the sshd config, as the ssh daemon is the one that will allow SFTP access.

sudo vim /etc/ssh/sshd_config and uncomment or add the following:

Subsystem sftp /usr/lib/openssh/sftp-server

And then restart SSH (it shouldn’t affect any ongoing connections): sudo service ssh restart

Now any user who can access the server over SSH can also access SFTP over the same port (22).

Next, make a folder in your pi user’s home directory to hold all your synchronized files: mkdir /home/pi/sync

That’s it!

iPhone Client

I use GoodReader on my iPhone to store files. It’s a really nice full-featured file utility (note my phone is old, so these directions were made with version 3, not the current version 4).

To add a server and synchronize some notes, do the following:

  • Get the GoodReader application if you don’t already have it.
  • Add a new folder in GoodReader.
  • Copy the notes from your Notes app on your phone into GoodReader as a bunch of text files. (Annoyingly the copy feature in Notes on the iPhone does not preserve blank lines.)
  • Select the globe icon and then Servers.
  • Add a new server.
  • Set the host name as the IP address within your home network of your Raspberry Pi server.
  • Set the path to the folder you created earlier. (The path by default starts at the user’s home directory, but the slider marked “Path starts at system root” can change that.)
  • Set the username of the user on your server (pi on most Pi’s).
  • Enter the pi user’s password.
  • Set the port (if you moved SSH to something other than 22).
  • Add the server.
  • Go back and select the folder of notes within GoodReader and select Upload from the options.
  • Upload it to the server.
  • Go to the server and select the folder you just uploaded. Select Sync.
  • Go back to the remote server’s home page and hit the sync icon.
  • When you get a warning about conflicts, say they are the same file, since you just uploaded the files from GoodReader.

Now you have a synchronized folder of notes in GoodReader. After you edit something, you can click the globe icon and then the sync icon to store your changes on your server (assuming you are within the same network at the time).

Note that if you want to edit or remove sync settings after they are created, you can find them under the Downloads tab of the globe icon window (I struggled to find this for a bit).

This method gives you a really simple way to have a bunch of text documents you don’t want to lose on your phone, but also backed up to a central server. All without any of your data leaving your home network.

Other Clients

Since your files are now on the Pi server, any device that can connect to this server can get to your notes. So if you started some notes on your phone when you were at a meeting, you can now return home, sync your phone to your server, and work on those notes on a desktop (because you are one of those people who still loves physical keyboards).

On Android and Kindle, the ES File Explorer supports SFTP and is a nice file explorer overall.

On Linux I use Dolphin, KDE’s file manager, which has built-in support for SFTP: just type sftp://IP_ADDRESS into the location bar and it will prompt for a username and password.

On Windows… I avoid Windows as much as possible, so I don’t use anything for SFTP on Windows. There are plenty of solutions out there, though.