N. P. O'Donnell, 2021
Update / Install:
# As root
apt update
apt install -y git
Set up non-root user:
useradd user
sudo usermod -a -G sudo user
sudo -u user mkdir /home/user/.ssh
sudo -u user chmod 700 /home/user/.ssh
cp /root/.ssh/authorized_keys /home/user/.ssh/authorized_keys
chown -R user /home/user/.ssh
chgrp -R user /home/user/.ssh
Disable password for sudo:
sudo visudo
and make the following change:
# Allow members of group sudo to execute any command
-%sudo ALL=(ALL:ALL): ALL
+%sudo ALL=(ALL:ALL) NOPASSWD: ALL
Setup tmux:
su user
echo '[[ ! -z $TMUX ]] || tmux attach || tmux' >> ~/.bash_profile
su - user
Build and install bitcoin core:
sudo chmod 777 /mnt/volume_lon1_01
mkdir /mnt/volume_lon1_01/bitcoin
sudo apt install -y build-essential autoconf libtool pkg-config libboost1.71*
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
./autogen.sh
./configure --without-bdb
make
sudo make install
Save this config file to /etc/bitcoin/bitcoin.conf
:
rpcallowip=0.0.0.0/0
rpcbind=0.0.0.0
rpcuser=user
rpcpassword=hodl2themoon
txindex=1
Remember to choose a good password
Save this unit-file to /etc/systemd/system/bitcoind.service
:
[Unit]
Description=Bitcoin daemon
Documentation=https://github.com/bitcoin/bitcoin/blob/master/doc/init.md
After=network-online.target
Wants=network-online.target
[Service]
ExecStart=/usr/local/bin/bitcoind -daemon \
-pid=/run/bitcoind/bitcoind.pid \
-conf=/etc/bitcoin/bitcoin.conf \
-datadir=/mnt/volume_lon1_01/bitcoin
PermissionsStartOnly=true
ExecStartPre=/bin/chgrp user /etc/bitcoin
Type=forking
PIDFile=/run/bitcoind/bitcoind.pid
Restart=on-failure
TimeoutStopSec=600
User=user
Group=user
RuntimeDirectory=bitcoind
RuntimeDirectoryMode=0710
ConfigurationDirectory=bitcoin
ConfigurationDirectoryMode=0710
MemoryDenyWriteExecute=true
PrivateDevices=true
NoNewPrivileges=true
ProtectHome=true
ProtectSystem=full
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable bitcoind
sudo systemctl start bitcoind
Check if the blockchain is syncing:
tail -f /mnt/volume_lon1_01/bitcoin/debug.log
Set up RPC client(s):
vi ~/.bitcoin/bitcoin.conf
Client config file:
rpcconnect=X.X.X.X # omit this line if local.
rpcport=8332
rpcuser=user
rpcpassword=hodl2themoon
Finally, test connection:
bitcoin-cli help