Running an Ethereum Node on Digital Ocean

Why Run a Node?

Nodes help the community by storing the blockchain and allowing others to access it.

Setting up Digital Ocean settings

If you wish to sign-up for Digital Ocean using my referral code click here.

First we will go to "Settings" and then click on "Security".

We will then add an SSH key. To do this we will use SSH-keygen.

Running ssh-keygen -t rsa will generate an SSH key for us.

You will be required to create a passphrase (I recommend using a tool like LastPass or 1Pass).

Then run pbcopy < ~/.ssh/id_rsa.pub to put your key into your clipboard.

Copy and paste.

Creating the Droplet.

Select the droplets screen.

It is best to select Ubuntu 16.04 since this is what this guide used.

I then recommend selection the $5/mo droplet size.

You can select any region you wish, I chose Toronto.

Make sure your SSH key is selected if you set that up.

Creating a User

To create a user we run adduser username. We then make this user to the sudo group with usermod -aG sudo username.

We must then allow this user to connect using our public key. On our host machine run pbcopy < ~/.ssh/id_rsa.pub.

Now, back on the server run su - username to login to that user. Now, mkdir ~/.ssh and chmod 700 ~/.ssh to create the .ssh dir and allow writing.

Now copy and paste your public key to ~/.ssh/authorized_keys. Then restrict the permissions with chmod 600 ~/.ssh. We can now login with the new user.

We now disable root by changing PermitRootLogin yes to PermitRootLogin no in /etc/ssh/sshd_config, and then restart the SSH daemon with sudo service sshd restart.

Running Geth

Run the following commands:


      sudo apt-get install software-properties-common
      sudo add-apt-repository -y ppa:ethereum/ethereum
      sudo apt-get update
      sudo apt-get install ethereum
      

Installing Supervisor

Run sudo apt-get install supervisor. To verify it has installed properly run sudo service supervisor restart.

Putting it all Together

We will now create a file for Supervisor to autostart Geth.

Create /etc/supervisor/conf.d/geth.conf using sudo /touch /etc/supervisor/conf.d/geth.conf.

Now, using your favorite text editor open the file and add:


      [program:geth]
      command=/usr/bin/geth --fast
      autostart=true
      autorestart=true
      stderr_logfile=/var/log/supervisor/geth.err.log
      stdout_logfile=/var/log/supervisor/geth.out.log
      

Now restart Supervisor sudo service supervisor restart.

Using this

We can attach to the console at anytime now using sudo geth attach /root/.ethereum/geth.ipc.