Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?

Installing Electrum on an air-gapped Ubuntu Machine

This guide shows how to install Electrum on an air-gapped machine. You will also need an Ubuntu machine connected to the network in order to complete this guide (it can be a virtual machine).

On the online machine

If you are running Ubuntu 16.04 off of a live USB, there is a bug that affects the package manager. You need to run these two commands at the terminal to fix it:

$ sudo mv /var/cache/app-info/xapian/default /var/cache/app-info/xapian/default_old

$ sudo mv /var/cache/app-info/xapian/default_old /var/cache/app-info/xapian/default

Next update the package manager:

$ sudo apt-add-repository universe

$ sudo apt-get update

Make a temporary directory to download .deb package files

$ mkdir debs

$ cd debs

Generate a list of URIs for the software you would like to install. This generates a text file called “apturls”.

$ sudo apt-get -y install --print-uris python-qt4 python-pip qrencode | cut -d\' -f2 | grep http:// > apturls

Now download the software packages to your hard drive

$ wget -i apturls

The previous step downloaded several .deb files to your hard drive in the “debs” directory. Copy this directory to the software usb drive. Make another temporary directory for the Electrum python sources

$ mkdir ~/python_files

$ cd ~/python_files

Download Electrum’s python dependencies $ sudo pip download https://download.electrum.org/2.7.6/Electrum-2.7.6.tar.gz

Check https://electrum.org/#download to see if there is a URL available for a more recent version. The previous step should have downloaded several files into the “python_files” directory. Copy this to your software usb. Your software usb is now ready to be transferred to the air-gapped machine.

On the air-gapped machine

Plug in the usb and navigate to the directory of the "debs" files. Install the packages.

$ sudo dpkg -i *.deb

Now switch to the directory with the python files. Install the python files

$ sudo pip install --no-index --find-links=../python_files ../python_files/Electrum-2.7.5.tar.gz

That's it! You should be able to run Electrum by typing $ electrum at the command line.

I found an alternative way to install the debian packages on the airgapped machine. It doens't seem to work on computers running on a live USB, but it may be more secure (I think apt-get checks package signatures and dpkg doesn't, but I'm still researching this).

Instead of $ sudo dpkg -i *.deb, copy all the .deb files to /var/cache/apt/archive. Then you should be able to sudo apt-get install python-qt4 python-pip. Try it and see what works for you.

Please leave any feedback in a comment!

@johnf

This comment has been minimized.

Show comment Hide comment
@johnf

johnf Jun 12, 2017

If your destination airgap is a different architecture e.g. raspberry pi you'll need to do
pip download --no-binary :all: https://download.electrum.org/2.8.3/Electrum-2.8.3.tar.gz

johnf commented Jun 12, 2017

If your destination airgap is a different architecture e.g. raspberry pi you'll need to do
pip download --no-binary :all: https://download.electrum.org/2.8.3/Electrum-2.8.3.tar.gz

@johnf

This comment has been minimized.

Show comment Hide comment
@johnf

johnf Aug 30, 2017

If you are upgrading an existing machine you need to add --upgrade to the install command

johnf commented Aug 30, 2017

If you are upgrading an existing machine you need to add --upgrade to the install command

@realgs

This comment has been minimized.

Show comment Hide comment
@realgs

realgs Feb 12, 2018

Did you mean to copy all the .deb files into /var/cache/apt/archives (archives instead of archive?). That still throws me with E: unable to locate package python-qt4 and the same for python-pip.

realgs commented Feb 12, 2018

Did you mean to copy all the .deb files into /var/cache/apt/archives (archives instead of archive?). That still throws me with E: unable to locate package python-qt4 and the same for python-pip.

@realgs

This comment has been minimized.

Show comment Hide comment
@realgs

realgs Feb 13, 2018

In case of Electrum 3.0.6 what dependencies would have been changed? It's python3 based and it requires at least its 3.4 version. It also uses pyqt5.
I think this command would change:
$ sudo apt-get -y install --print-uris python-qt4 python-pip qrencode | cut -d\' -f2 | grep http:// > apturls
Could you write me back? Unfortunately I'm not familiar with Linux that much but I'd love to install Electrum totally offline.

realgs commented Feb 13, 2018

In case of Electrum 3.0.6 what dependencies would have been changed? It's python3 based and it requires at least its 3.4 version. It also uses pyqt5.
I think this command would change:
$ sudo apt-get -y install --print-uris python-qt4 python-pip qrencode | cut -d\' -f2 | grep http:// > apturls
Could you write me back? Unfortunately I'm not familiar with Linux that much but I'd love to install Electrum totally offline.

@danielocdh

This comment has been minimized.

Show comment Hide comment
@danielocdh

danielocdh Feb 24, 2018

I wanted to be certain that there was some kind of verification for the .deb files on the air-gapped machine, I couldn't find any. I was able to extract one of the .deb files, modify one of its files, change its internal md5sum and recreate the deb file, then I installed the recreated deb file without any issues or warning, tested with apt apt-get and dpkg.

Also I noticed that while using these commands on an online machine that had Electrum installed I got an empty apturls file (because everything was already installed). So to use this method and not miss any dependencies both your online and air-gapped machine might need to be the same version and also fresh installs.

Because of these 2 findings I think the safest and easiest thing to do is to use verified ubuntu liveCDs (with the same version) for both your online and air-gapped machines. There still would be risks with this method (from the online machine/network) but it would be much less risky than to download .deb packages on an unknowingly compromised ubuntu machine/VM and install them on your air-gapped machine without being able to verify them.

I wanted to be certain that there was some kind of verification for the .deb files on the air-gapped machine, I couldn't find any. I was able to extract one of the .deb files, modify one of its files, change its internal md5sum and recreate the deb file, then I installed the recreated deb file without any issues or warning, tested with apt apt-get and dpkg.

Also I noticed that while using these commands on an online machine that had Electrum installed I got an empty apturls file (because everything was already installed). So to use this method and not miss any dependencies both your online and air-gapped machine might need to be the same version and also fresh installs.

Because of these 2 findings I think the safest and easiest thing to do is to use verified ubuntu liveCDs (with the same version) for both your online and air-gapped machines. There still would be risks with this method (from the online machine/network) but it would be much less risky than to download .deb packages on an unknowingly compromised ubuntu machine/VM and install them on your air-gapped machine without being able to verify them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment