How To Run a Bitcoin Full Node over Tor on an Ubuntu (Linux) Virtual Machine (updated 2021)

A step-by-step guide to getting a Bitcoin Full Node running on your computer — no previous experience required!

Full Nodes are Bitcoin’s nervous system!

This article updated in February 2021 with latest info and corrections, including VirtualBox 6.1.18, Ubuntu Server 20.04.2LTS, and Bitcoin Core 0.21.0

Part Zero — Overview

Part One — Prerequisites

Part Two— Setting up the VirtualBox platform

Part Three — Configuring our Ubuntu Linux server virtual machine

Part Four — Installing Ubuntu Linux on our new virtual machine disk

sudo apt update && sudo apt upgrade

Part Five — Installing the Bitcoin Core server (bitcoind)

sudo add-apt-repository universe
sudo apt install build-essential autoconf libtool pkg-config libboost-all-dev libssl-dev libevent-dev doxygen libzmq3-dev libdb++-dev libsqlite3-dev
cd ~
git clone https://github.com/bitcoin/bitcoin.git 
cd bitcoin./contrib/install_db4.sh `pwd`
git checkout v0.21.0git status
./autogen.sh
export BDB_PREFIX="$HOME/bitcoin/db4"./configure BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" --with-gui=no --with-miniupnpc=no
makemake checksudo make install

Part Six — Configuring Bitcoin to use Tor

cd ~mkdir .bitcointouch .bitcoin/bitcoin.confecho "txindex=1" >> .bitcoin/bitcoin.confecho "onlynet=onion" >> .bitcoin/bitcoin.conf
echo "maxconnections=20" >> .bitcoin/bitcoin.conf
sudo apt install tor
less /usr/share/tor/tor-service-defaults-torrc
sudo sh -c "echo 'ControlPort 9051' >> /etc/tor/torrc"
sudo systemctl restart tor
journalctl -f | grep tor -i
sudo usermod -a -G debian-tor username

Part Seven— Bitcoin Lives!!!

bitcoind -daemon -debug=tor
tail -f ~/.bitcoin/debug.log
bitcoin-cli getnetworkinfo
"networks": [
{
"name": "ipv4",
"limited": true,
"reachable": false,
... (and the same for the ipv6 entry) ... "name": "onion",
"limited": false;
"reachable": true,
...
bitcoin-cli getpeerinfo | grep true
bitcoin-cli getpeerinfo | grep addr

Part Eight—The End

References