Archive for May, 2013

Encrypted filesystem on

Posted in Uncategorized on May 18, 2013 by voline

In this article, I will describe a method for creating and sharing on different systems an encrypted directory in a account (henceforth “mega”).


You might be asking why one would want to store encrypted files on a system that provides for end-to-end encryption and stores the file data internally encrypted.  The problem boils down to trust.  I’m not ready to trust mega, despite that they might be trust worthy.  Their encryption design is relatively new and this is a reason to be wary, as it hasn’t been time tested.  I’d prefer to use solutions that have been around a while and used by many.


The idea behind the implementation is to use a FUSE filesystem to access mega and then layer an encrypted filesystem on top of that.  This is basically the technique I use for encrypting files I store on dropbox (see here and here).  There is a key difference in how I currently use dropbox, which gives me 2GB, and how I plan to use mega, 50GB.  I’d like to backup large amounts of data to mega encrypted and be able to access that from potentially any computer around the world.  However, I don’t want to delete the originals and to keep them unencrypted on the local disk where the currently reside.  Since I don’t want to keep two copies of the data locally (an encrypted version and the originals), I want a solution that takes the existing unencrypted directory of originals and gives me an easy way to map that into the cipher text of the encrypted filesystem.

In linux there are two major layerable encryption filesystems: ecryptfs and encfs.  I currently use ecryptfs with dropbox and it seems like the more mature and efficient solution.  However, it does not provide the reverse (plain text -> cipher text) functionality mentioned in the paragraph above.  This was requested as a feature in 2009, but the author expresses little interest in the feature and has since closed as “WON’T FIX”, despite offering to help motivated volunteer.  So that discounts ecryptfs.  Luckily encfs does have reversible functionality with the –reverse option.

The other loose end here is a fuse filesystem for mega.  For this, I will be using the megatools (ppa) utilities.

Putting it all together

Here’s a step-by-step procedure.  I assume an mega account is already setup.

Create the reverse mapping on the computer with the originals

mkdir /tmp/MegaDir.enc
encfs --reverse /path/to/data/to/backup /tmp/MegaDir.enc

Sync the encrypted files to mega

megasync -u  <username> -p <password> \
         --local /tmp/MegaDir.enc --remote /Root/<some subdir>
  • You can sync only a subset of fs tree rooted at /tmp/MegaDir.enc and may sync to any directory under the mega /Root directory

Retrieving unencrypted files

Now you want to view these files unencrypted on some other computer.  First install the megatools programs.  Then you may use the megafs program to mount the mega account to the local filesystem and then layer the encfs filesystem over the encrypted diretory to decrypt the files. You will also need the encfs configuration file that was automatically generated above.

scp :/path/to/data/to/backup/.encfs6.xml \
mkdir /media/megafs /media/megafs.encfs
megafs -u  <username> -p <password> \
       --reload /media/megafs
export ENCFS6_CONFIG=$HOME/megafs-encfs6.xml
encfs /media/megafs/path/to/encrypted/directory \
  • Currently megafs does not support read/write on files.  So you can only get a directory listing.  Not so useful.  However there is an ubuntu ppa with packages patched to allow read support for megafs (source).

And presto!  You’ve got decrypted access to your data.  Make sure you store your password in a safe place and backed up!

NOTE: The process is very similar for ecryptfs.


Running Rebtel One-Click application in wine

Posted in Uncategorized on May 11, 2013 by voline

This was tested on wine 1.5.29 with the Oct 12, 2012 snapshot of winetricks.  Download the Rebtel PC application installer at:

  1. WINEARCH=win32 WINEPREFIX=$HOME/.wine-rebtel winetricks dotnet40
    • The wine install instructions say to install .NET Framework 4.0 in a clean wine prefix using winetricks and must be 32-bit (thus the use of WINEARCH).
  2. WINEARCH=win32 WINEPREFIX=$HOME/.wine-rebtel wine <path to setup installer>/Rebtel-PC-setup.exe

Next comes the problem of starting the application again.  The downloaded exe file is stored in some horrendous path, which probably changed each time an updated exe is downloaded.  If you can find the exe, you can give that to wine and it will run the application.  Not so nice though.

There are reports that using wine to run “rundll32.exe dfshim.dll,ShOpenVerbShortcut C:/users/crass/Start Menu/Programs/Rebtel/Rebtel.appref-ms" should open the application.  However this always gives an error about the url being invalid.  Likewise, if I do “rundll32.exe dfshim.dll,ShOpenVerbApplication <application url found in appref-ms file>", I get another error about the config being different than the installed config (which probably has something to do with the params in the appref-ms file that I’m not using).

Then I figured out I could first run “explorer” and then double click on the desktop icon created. Still this was more steps than I felt necessary. So I tried passing the appref-ms shortcut file on the desktop to explorer and voila!  Here’s the exact command which can be put into a wrapper script to easily run from the command line (changes needed for your specific installation of course).

WINARCH=win32 WINEPREFIX=$HOME/.wine-rebtel wine explorer '%USERPROFILE%\Start Menu\Programs\Rebtel\Rebtel.appref-ms'

Now the problem I’m having is that the rebtel app consistently crashes non-deterministically.  It seems to be related to the use of the gui. But I’ve successfully made an uninterrupted call for a couple minutes without the app crashing.

Another unresolved issue is that the program will not close.  Clicking the close button and selecting the close menu item for the window properties causes the window to disappear and reappear.  I think its trying to minimize to the tray, but I can’t get it to show up there in Unity.