Here we are going to learn how to set up your own Virtual Private Server (VPS) correctly to run our released crypto trading bots and tools. You will learn how to deploy an instance of Ubuntu, install NodeJS, set up your secure SSH key login and how to manage your trading bots easily with a terminal manager called tmux.
If you have not decided on a VPS provider yet, we recommend you give our comparison article a quick read. In this tutorial, I will be using DigitalOcean - though don't worry, you can apply this tutorial to any cloud server or VPS host.
Setting up your VPS for crypto trading bots
- Create a new Ubuntu server
- Initial login
- Setting up your secure SSH key login
- Installing node.js
- Using Tmux to manage your processes
- Example of launching Pricewatch bot and GasToken Miners
Create a new Ubuntu server
Once you have registered on your VPS provider and set up your account, the first thing we will need to do is create a new Ubuntu server. DigitalOcean refers to them as Droplets, though you may see the term Instances or Virtual Machines being used depending on your chosen host.
Wow! Look at that, DigitalOcean has a one click solution for Ubuntu + NodeJS server. You can definitely use that one, but as I want this tutorial to be accessible to people using other hosts, I am going to click New Droplet.
And then you just need to fill in the details, for our requirements we do not need a powerful server, so I have selected the standard $5/mo plan and chosen Ubuntu 18.04 x64 as my operating system. Then just continue to fill in the details.
You can select your preferred location and choose a custom hostname if you wish, once you are happy click the big green create button.
Once it has been created, you will receive an email with your server's ip address and root password. This is what you will need to SSH into your server and manage it from a terminal. If you have never used a terminal before, I recommend installing Hyper. Also if you are on Windows, then I would recommend using Ubuntu On Windows.
Initial login and server setup
Once you have received your new Ubuntu's server details and opened up a terminal on your own computer, first you will login as Root using your server's public IP address. Here is the command:
ssh [email protected]_server_ip
This will prompt you to enter in the password DigitalOcean has sent you, and will then prompt you to set your own password. Now root is the administrative user in a Linux environment, and therefore it is recommended that you do not use it on a regular basis. So the first thing we are going to do is create a new user.
The above command will create a new user called saturnspaceship, of course, you should replace it with a username you like. It will ask you to fill in some details, starting with an account password. The rest of the information you can skip by pressing ENTER.
The thing is, you don't want to be having to swap accounts everytime you want to install something new on your server. We can avoid this by turning our new user account into what is known as a superuser which is simply a normal account with root privileges. This lets our account run admin commands by putting the word sudo before the command.
usermod -aG sudo saturnspaceship
Great, so now let's check if we can login to our new account. First we need to logout of our root account.
And now we will login back into our Ubuntu server but this time using the new user we just created.
ssh [email protected]_server_ip
Which should prompt you to login with the password you just set! Great, now the last thing I want you to setup is to use an SSH key instead of using password authentication. So before you move onto the next section, remember to logout again because we need to create our SSH key on our own computer.
Setting up your secure SSH key login
Using an SSH key to login to your Ubuntu server is easier and also much more secure than entering your password. The first thing we need to do is create the RSA Key Pair. We do this from our client machine, which will most likely be your computer. Here is the command you need to type:
After entering the command, the output should look as follows:
Generating public/private rsa key pair.
Enter file in which to save the key (/your_home/.ssh/id_rsa):
I recommend saving it in the default .ssh/ subdirectory so just press enter.
You can set a passphrase for it also, but it is not required. The end result should look something like this:
Your identification has been saved in /your_home/.ssh/id_rsa.
Your public key has been saved in /your_home/.ssh/id_rsa.pub.
The key fingerprint is:
You now have a public and private key that you can use to authenticate. Now we just need to place the public key on our Ubuntu server so we can use it to authenticate our login.
The easiest way to do this will be by using a command called ssh-copy-id. So using the user account we created earlier, it would look as follows:
ssh-copy-id [email protected]_server_ip
This will prompt you to enter the user password you created, and if everything was successfully it will tell you that the keys have been added. Now if you try and SSH back into your Ubuntu server:
ssh [email protected]_server_ip
It will log you straight in, without needing to enter your password. Success!
Great things are moving along smoothly! Before we install NodeJS lets make sure that everything is updated as this is a fresh Ubuntu install.
sudo apt-get update
Which will prompt you to enter the password you created for your user account. And then once that command has finished, we need to make the upgrades:
sudo apt-get upgrade
You may be asked about disk space, you can simply answer
Yes to these queries. Next let's install some build essential tools also, as some of our products require them to work correctly.
sudo apt-get install build-essential
And now we are finally ready to install Node.js, which you can do using the following command:
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
This command will first download the correct version of NodeJS we want to use and then it will prompt you again to press enter once the download is finished.
Using Tmux to manage your processes
We now have everything installed on our Ubuntu server that is required for running our crypto trading bots or tools. Now we need to learn how to keep everything running even when we logout by creating a tmux session.
sudo apt-get install tmux
First, we are going to create a new tmux session. This is where you will launch all your crypto trading bots from, because tmux keeps your session live all the time - even if you disconnect or logout. This will also make it easy to log back in and check what is going on. I am going to call my session tradingbots.
tmux new -s tradingbots
You have now opened a new tmux session, but we know we are going to be running more than one trading bot on our VPS server so lets set up our terminal to easily let us monitor everything in one glance. Tmux works completely by using hotkeys, you can find a cheat sheet here. You tell tmux you are going to enter a command by using the prefix Ctrl + b first.
- Split the terminal vertically: Ctrl + b and then press %.
- Then split it horizontally: Ctrl + b and then press ".
- Now move back to your first pane Ctrl + b and then use your arrow keys ← → ↑ ↓ to navigate. Once you are back on the first pane do another horizontal split.
The end result should have your terminal looking as following:
Now the last thing you need to learn about tmux, is how to detach yourself from your session. This will allow you to logout and keep everything running.
- As usual press Ctrl + b and then use the detach hotkey d.
- You should find your terminal has gone back to its original state, you can check your session is still active with the following command
- If you logout now, everything inside your tmux session will keep running smoothly. To retrieve your ongoing tmux session, just use the following command, amending the name to what you set.
tmux a -t tradingbots
Magic! You should find your terminal is back to how it was with the four panes. So now we just need to start running some trading bots.
Launching Pricewatch bot and GasToken Miners
If you have never used Pricewatch bot or GasToken Miner, please start by reading their how to use tutorials which you can find here:
As I am going to focus simply on what you need to do to launch them on your VPS, and not how to setup their configurations.
For Pricewatch bot, you can create your trading strategy
.json files directly on your server by using nano which is a command line text editor. Just type the following command:
And once you are happy with your configuration, use Ctrl + O to save the file. And then Ctrl + X to exit nano.
To make things easier to modify, let's save the private keys of the wallets we will be using to run trading bots and tools on our server as variables. You can do this by using the export command, first open your
And then you can just add as many wallets as you are planning to use, I am going to add 3 wallets. So I would just add 3 export commands:
Then use Ctrl + O to save the file. And then Ctrl + X to exit nano.
You will need to reload .bashrc for the changes to take effect, you can do this with the following command:
And you will need to do this in each pane of your terminal, to check if your variable has been set up you can type:
And your private key should be displayed. Now instead of having to write your pkey all the time, you can use $pricewatch_bot1, $marketmaker_bot1, $gst1_miner, $gst2_miner whenever needed. Note that this will save your private keys in plain text on your VPS server, so make sure these wallets are only used to run your trading bots. Treat them as hot wallets and do not use them to store a large amount of funds. This is, of course optional, you can enter your private key manually if you prefer.
Launching Pricewatch Bot & Market Maker bot
So to launch Pricewatch bot, once we have set up our .JSON file, your command to launch will look something like this:
npx @saturnnetwork/pricewatch-bot -p $pricewatch_bot1 -j '/home/saturnspaceship/saturntrader.json'
If you are having trouble figuring the path for your .JSON file, use the
pwd command to display what directory you are in.
Once that has started, as we learnt earlier, use tmux to move over to another panel on your terminal. So Ctrl + b then use an arrow key to navigate.
In your next panel, you can launch Market Maker bot:
npx @saturnnetwork/market-maker-bot -p $marketmaker_bot1 -j '/home/saturnspaceship/saturnmarketmakerexample.json'
Launching GasToken Miner
Once we are in our third panel, we can start our GST1 miner with the following command:
npx -q gastoken-miner -p $gst1_miner -a 50 -c ETC -t GST1 -b 20
Move over to the next panel and launch your GST2 miner:
npx -q gastoken-miner -p $gst2_miner -a 50 -c ETC -t GST2 -b 20
Let's take a look:
Beautiful! We now have everything running safely on our cloud server. As you can see I also have an instance of Market Maker bot running in the bottom left panel!
Now we can logout and leave everything running, remember what we learnt earlier? Ctrl + b and then the deattach hotkey is d. Next time you ssh back into your server, just retrieve your session with:
tmux a -t tradingbots
Happy cloud trading!
Congratulations! You now know how to set up a Ubuntu server on a VPS, create a new superuser account, setup your SSH key log, install NodeJS and how to use tmux to manage your crypto trading bots and gastoken miners. I think you just leveled up!