[HOWTO] Sync media collection over WiFi using git-annex and sshfs

Use Case

I store my audio collection on my NAS which is actually an archive of all the music albums I bought (and ripped using abcde). On my laptop I keep a big subset of the mp3 for daily listening. I also use my laptop to rip my CDs, correct false id3 tags and add cover.jpg files. On my fp2 I have a smaller subset for listening on the road or at work using Vanilla Music player .

I keep all those files in sync over WiFi using sshfs and git-annex. E.g. if I rip a new CD I can push it to my NAS, fp2 or only one of those two. If I fix id3 tags, I can sync the changes with all three locations.


The media files cannot be modified on the fp2. Only read access is possible.

This how-to won’t go into details but link to other sites for further reading whenever possible. So it’s more a link collection than an actual how-to.

The connection is slow. But within your wifi range you can use your fp2 as usual while files are synced.


At least one PC with sshfs and git annex.

Installation and Configuration

  1. Install SSHelper as explained here. I prefer the direct download link over Google Play Store. Follow the configuration until and including “Making First Contact”.
  2. Create a ssh config file ~/.ssh/config, so you do not have to enter the whole configuration whenever you want to conntect. Here is mine:
    `Host fairphone2

    Replace lars-fairphone by your fp2’s hostname or IP address

    Hostname lars-fairphone
    User any
    Port 2222
    PreferredAuthentications password,publickey

    The line below can be commented in after setting up public key authentication

    #IdentityFile ~/.ssh/id_rsa
    I set up a static lease and hostname in my OpenWRT router. So lars-fairphone resolves to my fairphones local IP. How to do this is also explained on the SSHelper website in section More optimizations.
  3. Start SSHelper on your fp2 and connect to your fp2 using the command ssh fairphone2. Confirm the key fingerprint with y on first connection:
    The authenticity of host '[lars-fairphone]:2222 ([]:2222)' can't be established. ECDSA key fingerprint is SHA256:..... Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '[lars-fairphone]:2222' (ECDSA) to the list of known hosts.
    Enter exit to terminate the ssh session.
  4. Set up Public-key (passwordless) logins as explained in the corresponding section on the SSHelper page. Add the line IdentityFile ~/.ssh/id_rsa to your ~/.ssh/config file. Retry to connect like in step 3. This time it should work using the key.
  5. Enable External Storage Access as explained in SSHelper : External Storage Access. I only tested with “Method 1: Application Data Directory” for Android 6.0 and newer. (Please note, that with Android 5 and below you can create a file in the /sdcard directory tree, but then you can’t change its permissions or its time stamp, which is essential for the usage with git (annex).)
  6. Now you can mount your device with sshfs: Create a mountpoint (for testing):
    mkdir /tmp/fp2
    Mount the device:
    sshfs fairphone2:/ /tmp/fp2
    Try to list its content: ls -al /tmp/fp2
    Unmount it:
    fusermount -u /tmp/fp2
    Remove the mount point:
    rmdir /tmp/fp2.
  7. Make the mount point permanent. E.g. add it to your fstab as explained in the Gentoo Linux Wiki.
    I prefer autofs for automounting, which is also explained in the Gentoo Linux Wiki. Here is my /etc/autofs/auto.fp2:
    *-fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536 :sshfs\#fairphone2\:/storage/B8A8-1008/Android/data/com.arachnoid.sshelper/&
    And this is the corresponding line in /etc/autofs/auto.master:
    /mnt/fp2 /etc/autofs/auto.fp2 uid=1000,gid=1000,--ghost
  8. Use git-annex to add your fp2 as a remote of your local media collection as explained in the git-annex walkthrough


Use the git-annex walkthrough to get familiar with git-annex.


This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.