5 min read

Bitcoin Core on Linux X86

Bitcoin Core on Linux X86

Preparation

We have a up & running Linux server. It's important that the user has sudo rights.

ssh user@ipadresse

(Change the ip-address with the ip-address from your server.)

sudo usermod -aG sudo $USER

Now the user has sudo rights.

Paket installation and download folder

Debian based systems

sudo apt install wget tor gnupg 

For Fedora

sudo dnf install wget tor gnupg 

For Arch based systems

sudo pacman -S wget tor gnupg 

Now we create a download directory in our home directory

mkdir Downloads

We change into it

cd Downloads

Download and verification - Bitcoin Core

Bitcoin Core download

We visit the website https://bitcoincore.org/en/download/ and copy the links to the .tgz file, the link to the SHA256SUMS file and the link to the SHA256SUMS.asc file and paste it with the command below in our terminal window.

wget https://bitcoincore.org/bin/bitcoin-core-23.0/bitcoin-23.0-x86_64-linux-gnu.tar.gz
wget https://bitcoincore.org/bin/bitcoin-core-23.0/SHA256SUMS
wget https://bitcoincore.org/bin/bitcoin-core-23.0/SHA256SUMS.asc

Other downloads

Now we visit the github - https://github.com/bitcoin/bitcoin/ - repo from Bitcoin and click on "Go to file".

In the search window we enter rpcauth.py, click on "Raw" and copy the URL and download the python with the following command:

wget https://raw.githubusercontent.com/bitcoin/bitcoin/master/share/rpcauth/rpcauth.py

In the next step we download the systemservice file. In our browser we are going back to the main website und enter in the search field "bitcoind.service". We click on "Raw", copy the URL and download the file.

wget https://raw.githubusercontent.com/bitcoin/bitcoin/master/contrib/init/bitcoind.service

Verify our Bitcoin Core download

With the following command we can verify the checksum from out Bitcoin Core download.

sha256sum --ignore-missing --check SHA256SUMS

If we don't get OK we should immediately delete the download.

Now we import the GPG from one or more Bitcoin Core developers. We can find them here - https://github.com/bitcoin-core/guix.sigs/tree/main/builder-keys. To import the gpg keys we have to download the gpg files.

Here I import only one key

gpg --import fanquake.gpg

With the command below we check the signature

gpg --verify SHA256SUMS.asc

If everyhing is okay we should see "Good signature" from Michael Ford. Don't worry about the others as we don't have imported their keys.

Install Bitcoind

Extract the file

tar xzf bitcoin-23.0-x86_64-linux-gnu.tar.gz

Install Bitcoind

sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-23.0/bin/*

Test start Bitcoind

bitcoind -daemon

We change in our homedirectory in .bitcoin

cd ~/.bitcoin

For the check we take a look into the log file

tail -f debug.log

If everything is okay we go to the next steps.

Create a config for Bitcoind and install the service file

In the .bitcoin directory we create a file called bitcoin.conf

nano bitcoin.conf

In the file we paste

# Options
testnet=0
server=1
daemon=1
txindex=1
#datadir=
# Connection Settings
# Output from rpcauth.py 

rpcport=8332
rpcbind=0.0.0.0
rpcallowip=127.0.0.1
rpcallowip=10.0.0.0/8
rpcallowip=172.0.0.0/8
rpcallowip=192.0.0.0/8
zmqpubrawblock=tcp://0.0.0.0:28332
zmqpubrawtx=tcp://0.0.0.0:28333
zmqpubhashblock=tcp://0.0.0.0:28334
whitelist=127.0.0.1
#addnode=

# Tor Settings
#onlynet=onion
#proxy=127.0.0.1:9050
#listen=1
#bind=127.0.0.1
#addnode=

With STRG + x + y and enter we save the file. We check if the file is okay

ls -la

We should see the config file bitcoin.conf.

Now we create a user for rpc requests.

cd ~/Downloads

We need to make the file rpcauth.py executable

chmod +x rpcauth.py

Create a rpcuser and password

./rpcauth.py username password

We copy the line rpcauth=xxxx

nano ~/.bitcoin/bitcoin.conf

In our config file we paste the output dnder # Output from rpcauth.py.

Save the file with STRG + x + y and enter.

We stop the running bitcoind with

bitcoin-cli stop

Installation systemservice file

We change into our downloads directory.

cd ~/Downloads

Before we can install the service we have to change some parameters.

[Service]
ExecStart=/usr/bin/bitcoind -daemonwait \

Change to

ExecStart=/usr/local/bin/bitcoind -daemon \

Set the correct directory for bitcoind

                            -conf=/etc/bitcoin/bitcoin.conf \
                            -datadir=/var/lib/bitcoind

Change to

                            -conf=/home/yourusername/.bitcoin/bitcoin.conf \
                            -datadir=/home/yourusername/.bitcoin

We set the following line as inactive

ExecStartPre=/bin/chgrp bitcoin /etc/bitcoin

Change to

# ExecStartPre=/bin/chgrp bitcoin /etc/bitcoin

We have to set the correct username

Run as bitcoin:bitcoin

User=bitcoin
Group=bitcoin

Change to

User=yourusername
Group=yourusername

Under Deny access to home we set a # before the line

# Deny access to /home, /root and /run/user
ProtectHome=true

Change to

# Deny access to /home, /root and /run/user
# ProtectHome=true

Done. We save the file with STRG +x +y and enter.

Next we have to copy the file to the systemd directory

sudo cp bitcoind.service /etc/systemd/system

Activate it

sudo systemctl enable bitcoind

Start bitcoind with the servicefile

sudo systemctl start bitcoind

Check if everything runs smooth

tail -f ~/.bitcoin/debug.log

We have now installed a Bitcoin Core BUT it's running via clearnet!

Activate Tor

If you don't have installed tor, below are the steps for the latest Tor package installation.

On Debian / Ubuntu based systems

sudo apt-get update 

To get the information about our running distrubtion

lsb_release -c

or

cat /etc/debian_version

We edit the sources list file and add the tor repos

sudo nano /etc/apt/sources.list.d/tor.list

Copy and paste the text below (Debian and Ubuntu except Focal)

deb     [signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org <DISTRIBUTION> main
deb-src [signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org <DISTRIBUTION> main

Since Ubuntu Focal has dropped 32 bit support we have to add the repos for Ubuntu Focal.

Check the system architecutre

dpkg --print-architecture

Replace ARCHITECTURE with your current architecture.

   deb     [arch=<ARCHITECTURE> signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org focal main
   deb-src [arch=<ARCHITECTURE> signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org focal main

Save with STRG +x +y + enter.

sudo apt-get update

Add the Tor project gpg key

wget -qO- https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --dearmor | tee /usr/share/keyrings/tor-archive-keyring.gpg >/dev/null
sudo apt-get install tor deb.torproject.org-keyring

On Fedora systems

sudo dnf install tor

On Arch based systems

sudo pacman -S tor

We add our user to the group tor

sudo usermod -aG debian-tor $USER

We edit the config file for tor

sudo nano /etc/tor/torrc

At the end of the config file we add

ControlPort 9051
CookieAuthentication 1
CookieAuthFileGroupReadable 1

Save the file with STRG +x +y + enter

Now we have to enable tor in our bitcoin.conf.

nano ~/.bitcoin/bitcoin.conf

To activate tor we delete the # before some lines. After that the config must look like this:

onlynet=onion
proxy=127.0.0.1:9050
listen=1
bind=127.0.0.1

Save the file with STRG +x +y + enter.

Restart Bitcoind

sudo systemctl restart bitcoind

Check the log

tail -f ~/.bitcoin/debug.log 

It may take some time for peers to connect to our node via Tor.

Done!

Bisq

If you are using Bisq you have to set some additional parameters in your bitcoin.conf.

nano ~/.bitcoin/bitcoin.conf

In the file we add

pruned=0
peerbloomfilters=1

Save the file with STRG +x +y + enter and restart the node.

sudo systemctl restart bitcoind

Tipps

Queries

Check how many peers are connected to us

bitcoin-cli getconnectioncount

Check blockchain infos

bitcoin-cli getblockchaininfo

With the parameter help you can get a lot other infos.

bitcoin-cli help
๐Ÿงก
If this article was helpful for you, please consider a donation to the author.