Page 1 of 1

DELTE--Basic Node Setup & Management on Linux

Posted: Tue Jan 31, 2023 4:49 pm
by mqpickens
Hardware Requirements
  • 4GB or 8GB Minimum of RAM w\ 32 or 64 bit OS Respectively
  • 10GB + sufficient space for an ever growing blockchain
    • 250GB recommended; 500GB+ to play it safe

Below are the Linux commands for the initial setup of your own microcurrency node. This has been
tested on Debian 11+. Make sure to compile and verify your own binaries. This guide assumes you
already have your trusted binaries prepared and ready to go.


Update/Upgrade
  • sudo apt-get -y update
  • sudo apt-get -y upgrade
Install Packages
  • sudo apt-get -y install wget psmisc
Download, Verify Checksum, and Uncompressed the Binaries for the correct CPU & OS Install Binaries
  • sudo install -m 0755 -o root -g root -t /usr/bin bitcoin-install/bin/*
Prepare Service Configuration
  • cat << EOF | sudo tee /etc/systemd/system/bitcoind.service
    [Unit]
    Description=Bitcoin daemon
    After=network-online.target
    Wants=network-online.target

    [Service]
    ExecStart=/usr/bin/bitcoind -micro -daemonwait -pid=/run/bitcoin/bitcoind.pid -conf=/etc/bitcoin.conf -datadir=/var/lib/bitcoin
    ExecStop=/usr/bin/bitcoin-cli -micro -conf=/etc/bitcoin.conf -datadir=/var/lib/bitcoin stop

    Type=forking
    PIDFile=/run/bitcoin/bitcoind.pid
    Restart=always
    RestartSec=30
    TimeoutStartSec=infinity
    TimeoutStopSec=600

    ### Run as bitcoin:bitcoin ###
    User=bitcoin
    Group=bitcoin

    ### /run/bitcoin ###
    RuntimeDirectory=bitcoin
    RuntimeDirectoryMode=0710

    ### /var/lib/bitcoin ###
    StateDirectory=bitcoin
    StateDirectoryMode=0710

    ### Hardening measures ###
    PrivateTmp=true
    ProtectSystem=full
    ProtectHome=true
    NoNewPrivileges=true
    PrivateDevices=true
    MemoryDenyWriteExecute=true

    [Install]
    WantedBy=multi-user.target
    EOF
  • sudo systemctl daemon-reload # Reload the new service configuration
Create a bitcoin System User
  • sudo useradd --system --shell=/sbin/nologin bitcoin
Wrap the Bitcoin CLI Binary with its Runtime Configuration
  • alias btc="sudo -u bitcoin /usr/bin/bitcoin-cli -micro -datadir=/var/lib/bitcoin -conf=/etc/bitcoin.conf"
  • echo "alias btc=\"sudo -u bitcoin /usr/bin/bitcoin-cli -micro -datadir=/var/lib/bitcoin -conf=/etc/bitcoin.conf\"" | sudo tee -a /etc/bash.bashrc # Reestablish alias @ boot
Generate Bitcoin Configuration File with the Appropriate Permissions
  • cat << EOF | sudo tee /etc/bitcoin.conf
    #server=0 # Accept JSON-RPC commands.
    #rpcuser=satoshi # Username for JSON-RPC connections.
    #rpcpassword=bitcoin # Password for JSON-RPC connections.
    #rpcauth=satoshi:e826...267$R07...070d # Username and hashed password for JSON-RPC connections
    #rest=0 # Accept public REST requests.
    #txindex=0 # Maintain a full transaction index.
    [micro]
    #### Add nodes here via ssh tunneling (e.g. addnode=localhost:19335). ####
    EOF
  • sudo chown root:bitcoin /etc/bitcoin.conf
  • sudo chmod 640 /etc/bitcoin.conf
Configure bitcoind's Log Files; Prevents them from Filling up the Partition
  • cat << EOF | sudo tee /etc/logrotate.d/bitcoin
    /var/lib/bitcoin/micro/debug.log {
    $(printf '\t')create 660 root bitcoin
    $(printf '\t')daily
    $(printf '\t')rotate 14
    $(printf '\t')compress
    $(printf '\t')delaycompress
    $(printf '\t')sharedscripts
    $(printf '\t')postrotate
    $(printf '\t')$(printf '\t')killall -HUP bitcoind
    $(printf '\t')endscript
    }
    EOF
Setup a Symbolic Link to Standardize the Location of bitcoind's Log Files
  • sudo mkdir -p /var/log/bitcoin/micro
  • sudo ln -s /var/lib/bitcoin/micro/debug.log /var/log/bitcoin/micro/debug.log
  • sudo chown root:bitcoin -R /var/log/bitcoin
  • sudo chmod 660 -R /var/log/bitcoin
Enable System Control for bitcoin and Start it Now
  • sudo systemctl enable bitcoind --now
############## System Controls for bitcoind #################
  • sudo systemctl status bitcoind # See system control status for bitcoind
  • sudo systemctl enable bitcoind # Enable @ boot and enable auto-restart
  • sudo systemctl disable bitcoind # Disable @ boot and disable auto-restart
  • sudo systemctl disable bitcoind --now # Disable system control for bitcoin and stop it now
  • sudo systemctl start bitcoind# Start the service
  • sudo systemctl stop bitcoind# Stop the service
  • sudo cat /var/log/bitcoin/micro/debug.log # Read latest debug log file
  • sudo ls -all /var/lib/bitcoin/micro | grep "debug" # View all (archived) debug log files

Static IP and Dynamic DNS

Posted: Wed Feb 01, 2023 5:13 pm
by mqpickens
~~~~~~~~~~~~~~~~~~~~~~~~ Static IP and Dynamic Node ~~~~~~~~~~~~~~~

Network Requirements
  • Static External IP: Negotiate with the ISP for a guaranteed static IP!
    • May need to update to a business account
    • May need to pay a little more each month
    • Configurable Router w\ Decent Firewall:
      • Setup a Static Internal IP just for the node
      • Setup port forwarding (i.e. External-IP:19333 to Internal-IP:19333)
    Step 4: Prevent NetworkManager from randomly disconnect wifi

    DELETE ME

    Posted: Fri Mar 17, 2023 5:59 pm
    by mqpickens
    asdf

    P2P "Connection" Cards (2” x 3.5”)

    Posted: Tue Apr 18, 2023 6:05 pm
    by mqpickens
    Create P2P (2” x 3.5”) "Connection" Cards. Example:
    Bitcoin of Arizona
    AZ Money P2P Node Connection
    Mitch Atkinson & Michael Pickens
    Date: 4/27/2023
    QR Codes:
    Name: BTCofAZ_MPickens_MAtkinson_04272023
    Address: p2p.btcofaz.com:22
    P2P Public Key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILTQSLjgO9MVUBl65ZqX8XoXqrRCnqB8ZoPApOBPv514
    Host Public Key: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJCVpZALmNJ3FTmrzBs3bQ69T/l+VSh3AQAqHiA5bVgG

    Descriptive Name
    Address:port
    P2P Public Key
    cat /root/.ssh/p2pkey.pub
    Server Public Key
    ssh-keyscan -t ed25519 localhost

    Establish P2P SSH Connection

    Posted: Thu May 11, 2023 11:38 pm
    by mqpickens
    sudo apt-get -y install python
    btc disconnectnode "" 0 # Node ID ------- Hey, just a quick note how to boot a connection

    ~~~~~~~~~~~~~~~~~~~~~~ script TEST inputs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    NAME=BTCofAZns_MAtkinson_04272023
    TARGET=localhost
    TARGET_PORT=22
    P2PPUB="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHyvKfiFuFZxVi+tziPV+KflsDEOQmRCBF++MIbcVNf1"
    HOSTPUB="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB2WKnGIRkPsVS7SXJafEa8GEuMSWAS6DKgErDD6d4Ct"


    ~~~~~~~~~~~~~~~~~~~~~~ Start of script - Make Connection ~~~~~~~~~~~~~~~~~~~~~~~~~~
    HOSTPUBSCAN=$(ssh-keyscan -H -t ed25519 -p "$TARGET_PORT" "$TARGET")
    if [[ ! "$HOSTPUBSCAN" == *"$HOSTPUB"* ]]; then
    echo -e "\nCould not connect to ${NAME} or could not validate the given public host key"
    echo "${HOSTPUBSCAN}"
    exit 1
    fi

    echo -e "\nMake the new peer's node ${NAME} known to this node"
    echo "${HOSTPUBSCAN} # ${TARGET}:${TARGET_PORT} ${NAME}" | sudo tee -a /root/.ssh/known_hosts

    echo -e "\nAuthorize the new peer ${NAME} to connect to this node"
    echo "${P2PPUB} # ${TARGET}:${TARGET_PORT} ${NAME}" | sudo tee -a /home/p2p/.ssh/authorized_keys

    echo -e "\nQuery the Kernel for an unused port to use for tunneling"
    LOCAL_PORT=$(python -c 'import socket; s=socket.socket(); s.bind(("", 0)); print(s.getsockname()[1]); s.close()')
    echo "Got one! Will use port ${LOCAL_PORT} for ssh tunneling to connect with ${NAME}"

    echo -e "\nCreate a new environment file (/etc/default/p2pssh@$NAME) for systemctl p2pssh@ tunnel service"
    sudo cat << EOF > /etc/default/p2pssh@$NAME
    #~~~ ${NAME} ~~~#
    TARGET=$TARGET
    TARGET_PORT=$TARGET_PORT
    LOCAL_PORT=$LOCAL_PORT
    EOF

    echo -e "\nEnable this new tunnel between this node and the new peer and start it up immediately"
    sudo systemctl enable p2pssh@${NAME} --now

    echo -e "\nConnect (via the addnode rpc command) the current bitcoind instance to the new tunnel"
    bitcoin-cli -micro -datadir=/var/lib/bitcoin -conf=/etc/bitcoin.conf addnode ${TARGET}:${LOCAL_PORT} "add"

    echo -e "\nAdd the new tunnel connetion to bitcoin.conf; bitcoind will auto-connect each time it restarts"
    echo "# ${NAME}" | sudo tee -a /etc/bitcoin.conf
    echo "addnode=${TARGET}:${LOCAL_PORT}" | sudo tee -a /etc/bitcoin.conf

    echo -e "\nExit successfully"
    exit 0