google.com, pub-7590763259720133, DIRECT, f08c47fec0942fa0
 

Host a Storj Node on a Virtual Private Server (VPS)

Updated: Oct 2, 2021


You will be compensated with rewards for running your own Storj node
Host a Storj Node on a Virtual Private Server (VPS)

Storj is an S3-compatible platform and suite of decentralized applications to store data in a secure and decentralized manner.


Small pieces of encrypted data from Storj DCS will be stored at random on your Node. Once your Node is set up, you need to ensure your Node is online and running properly.


After your Node is set up and verified, you’ll be compensated for the storage and bandwidth you provide for Storj DCS.


In this tutorial, we will set up Storj on an Ubuntu virtual private server (VPS). You will want to acquire a VPS with a large storage capacity.


 

Virtual Private Server Recommendation


A VPS with the following specifications should be sufficient (more disk space is preferred):

Virtual CPUs: 1 Core

Memory Size: 0.5 GB

Disk Space: 550 GB

Bandwidth: 2 TB




Virtual CPUs: 2 Cores

Memory Size: 2 GB

Disk Space: 2 TB

Bandwidth: Unlimited 100mbps

Price: $48USD Annually



Virtual CPUs: 4 Cores

Memory Size: 5 GB

Disk Space: 5 TB

Bandwidth: 25000 GB @ 1000mbps

Price: $32.50USD Monthly


 

Prerequisites


You should complete the following guides in their entirety to secure your server.



 

Updates


Depending on your VPS provider, the server could be ready instantly or take up to 24 hours.

Once the VPS has been created successfully, your provider will send you a confirmation email that contains the server IP address and password.


Establish an SSH connection with your server. Make sure your server is fully updated using the following command:

sudo apt update -y && sudo apt full-upgrade -y && sudo apt autoremove -y && sudo apt clean -y && sudo apt autoclean -y

This command will perform the following:

  • update - updates the list of packages but do not install

  • upgrade - install new versions of packages if new versions are available

  • full-upgrade - performs the function of an upgrade but will remove currently installed packages if this is needed to upgrade the system as a whole (fixing bad dependencies)

  • autoremove, autoclean and clean - clean old packages which are not needed anymore

  • option -y does not request permission on every step

  • && states that it runs the next command if the previous was successfully executed


 

Registration


Head over to https://registration.storj.io/ and Get your auth token by submitting your email address. You will receive your single-use authorization token to your email address.


 


Download the Identity Binary


curl -L https://github.com/storj/storj/releases/latest/download/identity_linux_amd64.zip -o identity_linux_amd64.zip
unzip -o identity_linux_amd64.zip
chmod +x identity
sudo mv identity /usr/local/bin/identity

 


Create an Identity


This can take several hours or days, depending on your machine's processing power and luck.

identity create storagenode

This process will continue until it reaches a difficulty of at least 36. On completion, it will look something like this:

Use the identity create storagenode to begin the setup
Storj Node - Creating an Identity

 

Authorize the Identity


Authorize your Storage Node identity using your single-use authorization token (please, replace the placeholder <email:characterstring> with your actual authorization token):

identity authorize storagenode <email:characterstring>

If authorization is successful, you will see the following message:

Identity successfully authorized using single use authorization token.

 

Confirm the Identity


Run the following commands to confirm you have the required identity files:

grep -c BEGIN ~/.local/share/storj/identity/storagenode/ca.cert
grep -c BEGIN ~/.local/share/storj/identity/storagenode/identity.cert

The first command should return 2, and the second command should return 3:

Confirming your Storj Identity certificates
Storj Node - Confirm the Identity

If your numbers are different, then authorizing the identity was not successful. You may try again.




 

UDP Configuration


If you are running your node on Linux, you might see warnings about the receive buffer size.


UDP transfers on high-bandwidth connections can be limited by the size of the UDP receive buffer. This buffer holds packets that have been received by the kernel but not yet read by the application. Once this buffer fills up, the kernel will drop any new incoming packet.


Storj software attempts to increase the UDP receive buffer size. However, on Linux, an application can only increase the buffer size up to a maximum value set in the kernel, and the default maximum value is too small for high-bandwidth UDP transfers.


We recommend increasing the maximum buffer size by running the following to increase it to ~2.5MB.

sudo sysctl -w net.core.rmem_max=2500000

To make this value persistent across reboots, run the following instead:

sudo /bin/su -c "echo "net.core.rmem_max=2500000" >> /etc/sysctl.conf"

sudo sysctl -w net.core.rmem_max=2500000

 

Install Docker


To set up a Storage Node, you first must have Docker installed. Install Docker by following the appropriate installation guide for your OS.


curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

 

Download the Storage Node Docker Container


Run the following command to download the latest version of Storj Storage Node.

sudo docker pull storjlabs/storagenode:latest

 

Setup static mount via /etc/fstab for Linux


First, run the following command and find the name of the hard drive you wish to use (for example, sda2, or ubuntu--vg-lv--root):

lsblk

Here is my example:

Configure a static mount in Ubuntu for Stroj Node
Storj Node - Linux fstab static mount

Look for a Type "part" that matches the Size of your storage capacity. Once you find it, we will now get the Unique ID (UUID) of the hard drive, minus the <>:

lsblk -d -fs /dev/<sda2>

‌OR

lsblk -d -fs /dev/mapper/<ubuntu--vg-lv--root>

Copy the UUID, as well as the FSTYPE. We’ll need that later. ‌ Next, we will create a new directory in the /mnt folder where you want your Storj files to be stored; you can name this directory whatever you would like, minus the <>.

sudo mkdir /mnt/<directory name>

‌Next, we will add our hard drive to the, etc/fstab file:

sudo nano /etc/fstab

‌Add the following line at the end of the file, replacing the <text> with your copied values:

UUID=<your HD UUID> /mnt/<directory name> <FSTYPE> defaults 0 2

‌To save changes, press Ctrl-X, Y, Enter


Once saved, run the following command:

sudo mount -a

‌That’s it! ‌ If you’d like to confirm, you can rerun this command, and your new mount point will be updated in the mounting column:

lsblk -d -fs /dev/<location (example: sda2)>

You’ve successfully static mounted your hard drive.




 

Setting up the Storage Node


Copy this command into a plain text editor like nano or Wordpad:

sudo docker run --rm -e SETUP="true" \
    --mount type=bind,source="<identity-dir>",destination=/app/identity \
    --mount type=bind,source="<storage-dir>",destination=/app/config \
    --name storagenode storjlabs/storagenode:latest

Replace the <identity-dir> and <storage-dir> with your parameters.


Copy the updated command and run it on your server. Here is an example of what my command looks like:

docker run setup for Storj Node
Storj Node - Setting up the node

 

Running the Storage Node


Copy this command into a plain text editor like nano or Wordpad:


sudo docker run -d --restart unless-stopped --stop-timeout 300 \
    -p 28967:28967/tcp \
    -p 28967:28967/udp \
    -p 127.0.0.1:14002:14002 \
    -e WALLET="0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
    -e EMAIL="[email protected]" \
    -e ADDRESS="domain.ddns.net:28967" \
    -e STORAGE="1.7TB" \
    --mount type=bind,source="<identity-dir>",destination=/app/identity \
    --mount type=bind,source="<storage-dir>",destination=/app/config \
    --name storagenode storjlabs/storagenode:latest

Modify the following:

WALLET - A wallet address to receive STORJ token payouts for running the node. Example: Crypto.com

EMAIL - Email address so that we can notify you when a new version has been released. (recommended)

ADDRESS - External/static IP address of your VPS and port (Default 28967)

STORAGE - How much disk space do you want to allocate to the Storj network. Be sure not to over-allocate space! Allow at least 10% extra for the overhead. If you over-allocate space, you may corrupt your database when the system attempts to store pieces when no more physical space is actually available on your drive. The minimum storage shared requirement is 500 GB, which means you need a disk of at least 550 GB total size to allow for the 10% overhead.


Replace the following:

<identity-dir> - The same identity directory from the Setting up your Storage Node command.

<storage-dir> - The same storage directory from the Setting up your Storage Node command.


Save your edited command somewhere safe as you will need to rerun this every time you manually update your Storj Node.


Copy the updated command and run it on your server. Here is an example of what my command looks like:

Modify your setup command for Stroj Node
Stroj Node - setup command input

Congratulations, you're a Storj Node operator!


You can also check to see if the node was started properly by running the following command in the terminal:

sudo docker ps -a

 

Updating the Storj Node


Ensure your node is updated and compliant.


Automatic Updates (Optional)


You can set up automatic updates for your storagenode Docker container using watchtower. Watchtower will look for new updates to the Docker container on Docker Hub in a random interval between 12 and 72 hours and automatically update your storage node when it sees a new version.


First, please pull the latest watchtower image from docker:

sudo docker pull storjlabs/watchtower

To set up auto-update for storagenode, please run the following command once:

sudo docker run -d --restart=always --name watchtower -v /var/run/docker.sock:/var/run/docker.sock storjlabs/watchtower storagenode watchtower --stop-timeout 300s

If you want to double-check that watchtower is properly running, you can run the following command:

sudo docker ps -a

Manual Updates


Please use manual updates only if the automatic update method was unsuccessful, or is unavailable for your node configuration.


1. Stop the running Storage Node container:

sudo docker stop -t 300 storagenode

2. Remove the existing container:

sudo docker rm storagenode

3. Pull the latest image from docker:

sudo docker pull storjlabs/storagenode:latest

4. Start your storage node again by running the following command you saved from the section: Running the Storage Node, i.e:

sudo docker run -d --restart unless-stopped --stop-timeout 300 \
    -p 28967:28967/tcp \
    -p 28967:28967/udp \
    -p 127.0.0.1:14002:14002 \
    -e WALLET="0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
    -e EMAIL="[email protected]" \
    -e ADDRESS="domain.ddns.net:28967" \
    -e STORAGE="1.7TB" \
    --mount type=bind,source="<identity-dir>",destination=/app/identity \
    --mount type=bind,source="<storage-dir>",destination=/app/config \
    --name storagenode storjlabs/storagenode:latest


 

Storj Web Dashboard (Optional)


If you would like to utilize the built-in graphical web dashboard to view the status of your node, you can continue through this optional portion of the tutorial. The web dashboard looks like the following:

Utilize the built-in graphical web dashboard for Storj Node
Storj Node - Web Dashboard

Since we are running our Storj node on a VPS with an external/static IP, we want to allow web traffic safely. We will accomplish this by installing Caddy:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy-stable.asc
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

Now we will edit the Caddy configuration file:

sudo nano /etc/caddy/Caddyfile

You can leave the port the default 80 or consider switching it to 8080. Remove the # in front of reverse_proxy and change the IP address to 127.0.0.1:14002. It should look similar to this:

# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.

:8080 {
        # Set this path to your site's directory.
        root * /usr/share/caddy

        # Enable the static file server.
        file_server

        # Another common task is to set up a reverse proxy:
        reverse_proxy 127.0.0.1:14002

        # Or serve a PHP site through php-fpm:
        # php_fastcgi localhost:9000
}

# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile

‌To save changes, press Ctrl-X, Y, Enter


Restart Caddy using the following command:

sudo systemctl restart caddy

Browse to HTTP://<your static IP>:8080. You should now see the Storj Web Dashboard!


 

Password protect the Stroj Web Dashboard (Optional)


To secure your Storj Web Dashboard, you may consider adding basic password authentication. This does not provide strong protection, but it's better than leaving your portal open to the public.


First, we need to hash your password because Caddy does not accept plain text passwords. Run the following command, minus the <>:

sudo caddy hash-password

You will be prompted to enter and then confirm your desired password. Make sure you keep this password somewhere secure. The command will output a hash-password. Copy this hash.


Edit the Caddy configuration file:

sudo nano /etc/caddy/Caddyfile

Add the following lines, minus <> and replacing username with any desired login name and replacing password with the hash-password copied from the above command.

basicauth /* {
   <username> <hash-password>
}

The Caddyfile should look similar to this:



# The Caddyfile is an easy way to configure your Caddy web server.
#
# Unless the file starts with a global options block, the first
# uncommented line is always the address of your site.
#
# To use your own domain name (with automatic HTTPS), first make
# sure your domain's A/AAAA DNS records are properly pointed to
# this machine's public IP, then replace ":80" below with your
# domain name.

:8080 {
        basicauth /* {
        username base64_hash_password
}

        # Set this path to your site's directory.
        root * /usr/share/caddy

        # Enable the static file server.
        file_server

        # Another common task is to set up a reverse proxy:
        reverse_proxy 127.0.0.1:14002

        # Or serve a PHP site through php-fpm:
        # php_fastcgi localhost:9000
}
# Refer to the Caddy docs for more information:
# https://caddyserver.com/docs/caddyfile

‌To save changes, press Ctrl-X, Y, Enter


Restart Caddy using the following command:

sudo systemctl restart caddy

When you access HTTP://<your static IP>:8080, you will be prompted to input your username and password.



 

In this tutorial, you have learned how to set up and secure a VPS, install Storj Node Storage, activate and password the Stroj Web Dashboard. Congratulations for making it this far!


Feel free to comment below with any questions or comments.


If you found this article informative, please support my efforts by donating to my Ethereum ENS address: geekbyte.eth


556 views4 comments