Skip to content

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

Check 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!

Copy link

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:

Copy link

johnf commented Aug 30, 2017

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

Copy link

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.

Copy link

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.

Copy link

danielocdh commented 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.

Copy link

jseparovic commented Apr 30, 2018

Electrum offline Ubuntu 18.04

Thanks heaps for this how-to.
Here's an updated version that worked from me at the time of writing this comment.

Online Machine:

Do the following steps on your freshly installed online Ubuntu 18.04 virtual machine (I tested this procedure on a fresh install. If you’ve already installed some of the dependencies on this machine, this procedure probably won’t work, because ubuntu won't download already installed packages, so use a fresh install.)

Grab the dependencies:

# 1) temporarily move existing debs (not required if no *.deb files exist)
mkdir /var/cache/apt/archives/tmp
mv /var/cache/apt/archives/*.deb /var/cache/apt/archives/tmp

# 2) install the dependencies
sudo apt-get install python3-pyqt5 python3-pip qrencode -y

# 3) grab the dependencies
cd /var/cache/apt/archives/
tar cfvz ~/debs.tar.gz *.deb

# 4) restore the pre-existing debs (not required if skipped step 1)
mv /var/cache/apt/archives/tmp/* /var/cache/apt/archives
rm -rf /var/cache/apt/archives/tmp

Grab Electrum and the python libs:

cd ~
mkdir python_libs
cd python_libs
sudo pip3 download
cd ~
tar cfvz ~/python_libs.tar.gz python_libs

Copy to tarballs to USB

cd ~
cp debs.tar.gz python_libs.tar.gz /media/<username>/<usblabel>

On the Ubuntu 18.04 offline machine:

Install the dependencies:

cd ~
mkdir debs
cd debs
cp /media/<username>/<usblabel>/debs.tar.gz .
tar xvfz debs.tar.gz
sudo dpkg -i *.deb

Install Electrum:

cd ~
cp /media/<username>/<usblabel>/python_libs.tar.gz  ~/
tar xfvz python_libs.tar.gz 
cd python_libs
sudo pip3 install --no-index --find-links=. Electrum-3.1.3.tar.gz

Start Electrum


These instructions are also here:

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