Skip to content

Instantly share code, notes, and snippets.

@rupertlssmith
Last active July 7, 2025 20:14
Show Gist options
  • Save rupertlssmith/442c9c062536a9ec4b126a0e743cdcb4 to your computer and use it in GitHub Desktop.
Save rupertlssmith/442c9c062536a9ec4b126a0e743cdcb4 to your computer and use it in GitHub Desktop.
How to install bitcoin knots on Debian

🧩 Bitcoin Knots Installation Guide (Debian)

1. Install Required Dependencies

sudo apt update
sudo apt install build-essential libtool autotools-dev automake pkg-config bsdmainutils curl git
sudo apt install libssl-dev libevent-dev libboost-system-dev libboost-filesystem-dev libboost-test-dev libboost-thread-dev
sudo apt install libminiupnpc-dev libzmq3-dev libsqlite3-dev

2. Clone the Bitcoin Knots Repository

git clone https://github.com/bitcoinknots/bitcoin.git
cd bitcoin

3. Checkout the Latest Stable Release

git checkout $(git tag | grep 'v[0-9]' | sort -V | tail -n1)

4. Build Bitcoin Knots

./autogen.sh
./configure
make -j$(nproc)

5. Install the Binaries

sudo make install

6. Run Bitcoin Knots

bitcoind -daemon

To check the status:

bitcoin-cli getblockchaininfo

📁 Optional: Create bitcoin.conf

File location: ~/.bitcoin/bitcoin.conf

Example contents:

server=1
daemon=1
txindex=1
rpcuser=yourusername
rpcpassword=yoursecurepassword

Let me know if you want instructions for GUI (bitcoin-qt), pruning, or testnet configurations.

⚙️ Set Up Bitcoin Knots as a systemd Service

1. Create a dedicated user (optional but recommended)

sudo adduser --disabled-password --gecos "" bitcoin

Give the bitcoin user ownership of your .bitcoin directory:

sudo mkdir -p /home/bitcoin/.bitcoin
sudo chown -R bitcoin:bitcoin /home/bitcoin/.bitcoin

Move your bitcoin.conf file there if needed.


2. Create a systemd service unit

Create the service file:

sudo nano /etc/systemd/system/bitcoind.service

Paste the following contents:

[Unit]
Description=Bitcoin Knots daemon
Documentation=https://github.com/bitcoinknots/bitcoin/blob/master/doc/init.md

After=network-online.target
Wants=network-online.target

[Service]
ExecStart=/opt/bitcoinknots/bin/bitcoind -daemon \
            -pid=/run/bitcoind/bitcoind.pid \
            -conf=/etc/bitcoin/bitcoin.conf \
            -datadir=/var/lib/bitcoind

PermissionsStartOnly=true
ExecStartPre=/bin/chgrp btc /etc/bitcoin

User=btc
Group=btc

Type=forking
PIDFile=/run/bitcoind/bitcoind.pid
Restart=on-failure
TimeoutStopSec=600

# Secure sandboxing options
RuntimeDirectory=bitcoind
RuntimeDirectoryMode=0710
ConfigurationDirectory=bitcoin
ConfigurationDirectoryMode=0710
StateDirectory=bitcoind
StateDirectoryMode=0710

PrivateTmp=true
ProtectSystem=full
ProtectHome=true
NoNewPrivileges=true
PrivateDevices=true
MemoryDenyWriteExecute=true

[Install]
WantedBy=multi-user.target

3. Reload systemd and enable the service

sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable bitcoind
sudo systemctl start bitcoind

4. Check service status

systemctl status bitcoind

You should see something like:

Active: active (running)

✅ Notes

  • If you compiled bitcoind into a non-standard path, adjust ExecStart accordingly.
  • Make sure bitcoin.conf has proper permissions (chmod 600) and is owned by the bitcoin user.
  • Logs are available via journalctl:
journalctl -u bitcoind -f
@Henelik
Copy link

Henelik commented Jul 7, 2025

Awesome info, thanks for sharing!

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