How to run a full Bitcoin node on a Virtual Private Server.
Running a Bitcoin node gives you a the warm, fuzzy feeling that comes from helping people download the blockchain faster. Same as seeding torrents provides warm fuzzies. You are supporting the overall Bitcoin network, relaying transactions and allowing people close to your server location to download the blockchain faster.
Once your node is running, submit it to https://getaddr.bitnodes.io/
Note- this was written for Ubuntu, but in step 2.1 I explain how to make this install work in any Linux OS.
I try to make this guide as universal as possible, as I’ve run into a few different forks running nodes on different machines.
This is a good way to learn some basic linux because the install is fairly straightforward and I address most of the problems you could encounter.
1. First, check what kind of linux distro you are running. There is no universal way to do this, so
look for a release file like “redhat-release”, ect.
It will return more info about your distro, its just good to know for the rest of the install..
2. Check if you have apt-get installed, this is needed for my install.
If you get a return, then you have it installed go to 3, if not see below.
2.1 If you have Yum, and not apt get, here are 3 ways to install it:
3. Next, this is a script that will save us 10 steps adjusting the firewall, ect.
wget -O btcNode.sh https://raw.github.com/XertroV/BitcoinAutoNode/master/bitcoinAutoNode.sh ; sudo bash btcNode.sh
What this does is:
Firewall rules; allow 22,8333
Sets up autostart (cron)
Adds limit to bitcoin connections in order to help control bandwidth; reduce from 40 in step-8 to limit it further.
Everything will install perfect, however Bitcoind may not be in the package,
Check by typing:
If nothing happens, we need to install bitcoind directly in 3.1. If yes, go to 4.
3.1 Install Bitcoind
sudo aptitude install python-software-properties
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo aptitude update
sudo aptitude install bitcoind
You can start Bitcoind and see if it works,
It will output “Bitcoin server starting”
4. When you start Bitcoind it will start to download the blockchain. This will take weeks! If you are OK with that, then you are done. If not, below I will show how to download the blockchain via torrent.
5 . Next, we need to download the blockchain. Install transmission-daemon, which is a BitTorrent cliet so we can torrent it instead of waiting for it to download.
sudo add-apt-repository ppa:transmissionbt/ppa
sudo apt-get update
sudo apt-get install transmission-cli transmission-common transmission-daemon
More info for other distros: www.webupd8.org/2009/12/setting-up-transmission-remote-gui-in.html
In the terminal, type:
To see if its work. If it is type:
The reason is, we are editing the config file and if transmission-daemon is running, it will overwrite our changes.
6. . Next, we need to edit the the config file of transmission to whitelist and setup 9091. This will allow us to go to www.IPADDRESS:9091 to be able to download a torrent
If running Transmission under your own username, the configuration file will be located at ~/.config/transmission-daemon/settings.json.
Most linux distros have Nano or Vi as text editors. So either type:
Once you are in the file, look for:
rpc-whitelist is a comma-delimited list of IP addresses that allow us to connect to the web interface from home.
Wildcards allowed using ‘*’. Example: “127.0.0.*,192.168.*.*”, Default: “127.0.0.1” )
Add your home IP to the list, the IP you are using to connect over SSH.
Save the file and exit.
(In Vi to save an exit type “Shift-ZZ”)
More info: https://trac.transmissionbt.com/wiki/EditConfigFiles#Options
7. Login to the webui of transmission by going to www.IPADDRESS:9091 and download the bootstrap.dat file here.
It will take anywhere from 30min – a few hours depending on your connection.
It will download into a folder called Downloads in your root directory, or user directory.
8. Once its downloaded, move it into the .bitcoin folder by typing:
mv ~/Downloads/bootstrap.dat ~/.bitcoin
turn on bitcoind by typing
It will output “Bitcoin server starting”
Now, it will start verifying the blocks that are in the bootstrap.dat file. Will take a few hours. You check what its up to by typing:
You will see under “blocks”.
Its finished once the block amount is the same number as the blockheight on blockchain.info
9. This is extra, If you want to be able to see your nodes status from going to the IP, being able to show your friends like this: 220.127.116.11
Download this script
Put it anywhere on your server and change the RPCUSER/PASS, NODEADDR and BITCOINADDR.
Run the script to update every time. You can also use it to create a chron job.
Note: You’ll need to install BitcoinRPC for the script to work.
Go here: https://github.com/jgarzik/python-bitcoinrpc
Follow Jeffs simple instructions. Once BitcoinRPC is installed, run the node script again and it will update!