There might be a few reasons that you’d want to setup a bitcoin or altcoin wallet. I set one up recently for a client and found there wasn’t much info out there about compiling from source. Bitcoin has a PPA which makes it easier, but that doesn’t help us for the altcoins.
The methods below will show you what you need to do to get a wallet up and running from a clean ubuntu install. Oh…and don’t be a cheapy! Try this on a VPS with at least 2GB ram (full disclosure, it’s a DO referral link), or else compiling will probably fail. Also you might run into ram issues while running the daemon if you’re using less. Remember, for bitcoin you’re going to need at least 30GB just to store the blockchain.
I’m sure you know this by now, but I’ll say it none the less…keep your server secure! You wallet contains valuable coins, that if compromised, you can never retrieve. Be careful!
Method 1 PPA (the easy way, works for bitcoin only)
First we update the operating system and install the necessary packages for building our wallet.
sudo apt-get -y update && sudo apt-get -y upgrade sudo apt-get -y install libdb++-dev build-essential libtool autotools-dev autoconf libssl-dev libboost-all-dev python-software-properties curl vim git debconf-utils
Let’s add the Bitcoin PPA and install:
sudo add-apt-repository ppa:bitcoin/bitcoin && sudo apt-get -y update sudo apt-get -y install bitcoind
Now we need to create a bitcoin user. You don’t want to be running the bitcoin daemon as root. Also we’ll change to the bitcoind user.
sudo useradd -d /home/bitcoind -m bitcoind -s /bin/bash sudo su - bitcoind
We make the necessary directories and setup a config file.
mkdir /home/bitcoind/.bitcoin/ touch /home/bitcoind/.bitcoin/bitcoin.conf echo 'rpcuser=litecoinrpc rpcpassword=CHANGE_THIS_TO_SOMETHING_VERY_SECURE server=1' > /home/bitcoind/.bitcoin/bitcoin.conf
If you want to run on testnet add the following to
We’re now ready to fire up bitcoind:
And test it out:
bitcoind getbalance 0.00000000
NOTE: It will take quite a while for the wallet to sync with the network. Your wallet needs to download about 30GB of transactions and process them. While this is going on, your balance might not be correct. To see how far it’s come along run the following command and compare with the current block count:
bitcoind getblockcount 339255
Method 2 (works for all altcoins)
This method will basically allow you to install any altcoin on your server. We’re going to compile from source. In the below method we’re going to setup Litecoin, but it could easily be any other coin. You just need to change the username, git repo url,
sudo useradd -d /home/litecoind -m litecoind -s /bin/bash sudo su - litecoind git clone git://github.com/litecoin-project/litecoin.git cd litecoin/src make -f makefile.unix USE_UPNP= litecoind mv litecoind /usr/bin/litecoind mkdir /home/litecoind/.litecoin/ touch /home/litecoind/.litecoin/litecoin.conf echo 'rpcuser=litecoinrpc rpcpassword=CHANGE_THIS_TO_SOMETHING_VERY_SECURE server=1 testnet=1' > /home/litecoind/.litecoin/litecoin.conf
Fire it up!
Automatically start daemon on startup
If you want the daemon to start automatically do the following as root (or use sudo if you’re user has the ability):
echo 'su bitcoind -c "/usr/bin/bitcoind -daemon"' >> /etc/rc.local
Rinse and repeat for your other altcoins.
Some basic security
I don’t claim to be a Linux server security guru. These are just some best practices to help you not get hacked.
Change SSH port
It can be a good idea to chage the default ssh port. This is a bit inconvenient since you’ll need to specify it each time, but it helps prevent bots trying to brute force port 22.
etc/ssh/sshd_config in your favorite editor and change the following line:
Port 3736 #Change this to some random unused port
Disable password login
IMPORTANT: Make sure you’ve correctly added your public key to your
~/.ssh/authorized_keys file. Test it out before disabling password logins.
etc/ssh/sshd_config and make these changes to disable password logins:
PasswordAuthentication No ChallengeResponseAuthentication no UsePAM no