Skip to content

Airbitz Server Configuration

Eric Voskuil edited this page Jul 11, 2015 · 1 revision

Airbitz runs a number of libbitcoin-server instances, and these are the instructions we use internally when setting up our boxes. We are maintaining them here on the libbitcoin-server wiki so others can take advantage of them.

These instructions assume an Ubuntu 14.04 server OS.

Prepare the machine

Create a user

useradd -m -g users -G sudo -s /bin/bash bitcoin
passwd bitcoin
# Type a password...

Set up ssh access

su bitcoin
mkdir ~/.ssh
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
# Paste public keys into ~/.ssh/authorized_keys, one on each line...
exit
exit
ssh bitcoin@<server>

Set up software

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install tmux
tmux

Tighten up SSH

# Set PasswordAuthentication no:
sudo sed -i -e 's/.*PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
# Set PermitRootLogin no:
sudo sed -i -e 's/.*PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config
sudo restart ssh

On your personal computer, put lines like the following into ~/.ssh/config:

Host <convenient name>
HostName <ip address>
User bitcoin

Now you can log into the server using ssh <convenient name>, and SSH will use the right port, IP address, and user.

Set up libbitcoin-server

Download

# Link taken from https://github.com/libbitcoin/libbitcoin-server/wiki/Download-BS
wget https://github.com/libbitcoin/libbitcoin-server/releases/download/v2.1.0/bs-linux-x64-mainnet
chmod +x bs-linux-x64-mainnet
sudo install -D bs-linux-x64-mainnet /usr/local/bin/bs

First boot

There are several config files listed below which need to be set up on the box for fully automatic unattended operation.

  • /home/bitcoin/bs.cfg
  • /etc/init/bs.conf
  • /etc/logrotate.d/bs

Optional for encryption, can be done on PC and results copied:

bx cert-new server.private

Next initialize the blockchain:

bs --initchain

The server can then be started for the first time with:

sudo start bs

Useful tidbits

To prevent incoming connections, do:

sudo iptables -A INPUT -p tcp -i eth0 --dport 9091 -j REJECT

Config files

/home/bitcon/bs.cfg

[node]
blockchain_path = blockchain
history_height = 0
hosts_file = hosts
listen_port = 8333
outbound_connections = 8
tx_pool_capacity = 2000

[server]
query_endpoint = tcp://*:9091
heartbeat_endpoint = tcp://*:9092
block_publish_endpoint = tcp://*:9093
tx_publish_endpoint = tcp://*:9094
publisher_enabled = false

[logging]
debug_file = debug.log
error_file = error.log
log_requests = false

[identity]
# Optional for encryption:
cert_file = server.private
# Our Satoshi node:
peer = bitcoin-sol.airbitz.co:8334

/etc/init/bs.conf

#!upstart
description "libbitcoin-server"

start on (local-filesystems and net-device-up and runlevel [2345])
stop on runlevel [016]

chdir /home/bitcoin
respawn

script
    su bitcoin -c "bs bs.cfg > console.log"
end script

pre-stop script
    killall -SIGINT bs
end script

/etc/logrotate.d/bs

/home/bitcoin/debug.log /home/bitcoin/error.log {
    rotate 7
    daily
    sharedscripts
    postrotate
        restart bs
    endscript
}