Thursday, May 10, 2018

Haas Trade Server Ubuntu 18.04 installation comics (Hetzner edition)

Haasbot Ubuntu installation

Updated (21) 2018 - added VisualBasic for email bot

Foreword:

Do not be frightened by the installation. The process is pretty straightforward, easy, and requires NO programming knowledge. Your sole requirement is to pay attention to details and do not hurry.
This document is made for guys who are not very technically savvy. If you are a power user\sysadmin feel free to skim through and perform modifications of your choice.

Introduction.

OS in this tutorial is Ubuntu 18.04 "Minimal" (however almost all of the steps will work on Ubuntu 16.04.4, 17.10 and also should work for other Debian-based Linux distribution).
I will be using free, easy to use software only.
  • I have chosen Ubuntu because it's pretty user-friendly, wide-spread and stable for any task HaasTradeServer may throw. 
  • Version 18 was picked because it is latest LongTermSupport distribution (meaning "reliable" and "no hassle").
  • "Minimal" config with no GUI is chosen to make server less complicated and more robust and secure in future use.
  • Hetzner hosting is used because of the cheap AND fast servers it provides at "Server Auction" Hetzner Servers

For connecting to the remote server we will be using SSH with terminal (console) connection. SSH stands for "secure shell" and it is a cryptographic (ha! Crypto here, too) protocol that is virtually impossible to hack. So your communication with the remote server is secure.
Every time I refer to SSH I will be meaning "this window from Matrix with a lot of letters" - a "terminal console" that will allow you to connect to remote server using SSH protocol.
Your typical Termius SSH console
Using Termius - http://termius.com - for SSH is easier than usual terminal or Putty; but of course, it is up for you to decide which program to utilize.

Terminology

Some terms, such as "login", "password" and "account" are quite confusing, because you can have a lot of them. So I will be calling them, respectively:
  • Hostinglogin (the one you use on Hetzner\VULTR\Linode\Contabo\DigitalOcean\Strato website)
  • SSHlogin (the one you will be using to connect using SSH to the remote server)
  • SSHpassword
  • Haaslogin (the one you will be using to login to http://haasonline.com site)
  • HTSlogin (the one you will be using to enter your HTS application)
  • Exchangelogin - the one you will be using to log in to your exchange.
  • HTSserver - is a computer where HTS is to be installed. Most often it is the IP address of the computer.
  • Laptop - just to make it easier I will refer to your daily computer as a "laptop". It might be desktop or nettop of course.
  • Linux and Ubuntu. While every Ubuntu is a Linux - not every Linux is Ubuntu. To keep confusion to minimum in this document we can use words as a synonims. So, only here and today only Ubuntu=Linux

WARNING Linux commands WARNING

It is VERY important to enter Linux commands as they are provided in this document.
Do NOT cut them in half, do NOT press enter after part of the command.
WARNING - it is UTTERLY important to copy-paste ENTIRE command, in a SINGLE line, as it is in this document. To help you with that I will post only one command at once. A typical command looks like this:
sudo ufw limit ssh
And will be colored here like a Matrix text for ease of use. Again, even if command is so long that it spans several lines - it still MUST be entered in a single continuous line. 

Laptop requirements

Your computer must have some initial set up for the best experience. The following applications are required:
  • HaasTradeServer - you should have already bought the license and downloaded the file from the profile page
  • Web browser - any will do. You might want to use FireFox or Chrome for the best experience.
  • Remote login program - to connect to remote Linux machine you will need a special application. For the sake of simplicity, I recommend downloading and using free, cross-platform (works on any OS) program Termius
  • File uploader\downloader - to get some files to or from your HTSserver you need a special program. For sake of simplicity, I recommend using cross-platform free program CyberDuck

Pre-install phase - A.K.A. "Ordering and Preparing"

Estimated time ~15 minutes (plus extra for KYC process at hosting of your choice)

These are the steps to make you ready (obviously, you should have downloaded and installed Termius, Cyberduck and HaasTradeServer by now)

  1. If you haven't downloaded HTS yet go to https://www.haasonline.com/account/downloads/ using your Haaslogin and download the "Haas Trade Server" package. Also, save License key somewhere convenient. Open the archive and copy the "linux32.tar.gz" file to easily accessible location.
  2. Register your hosting account, and pick any 4+ CPU cores server. Basically, any hosting provider will do.
  3. If you want fast, reliable and cheap hosting I suggest picking Hetzner. Register your Hosting account and choose any server from the "server auction" https://www.hetzner.com/sb keeping in mind the following:
    • CPU-B rating should be of 7000+
    • Price: should be no more than 33 EUR per month (tax included) and NO setup fee
    • DC: must NOT start with "HEL". This means "Helsinki" location, it is not a good option currently for any of the Asian exchanges (Binance, OKEX and others)
    • A nice additional feature might be iNIC card; it is the iNtel 82574 powerful network adapter. But it is NOT necessary.
    • This - is just perfect
    • IMPORTANT: do NOT look for any "cloud", "SX", "EX", "PX" and other servers. Get one from the "Auction" list.

  4. You must complete some kind of KYC to approve your account. Then wait for the server order to be completed. Note your HTSserver IPv4 address. You will need it.
  5. When you get an email that your server is delivered - use your Hostinglogin, get into hosting ROBOT account (it will be automatically created for you at Hetzner),
    select your server and go to "Linux" tab, select "Ubuntu 18.04 LTS minimal",
    set checkbox "I am aware that blah-blah" and click "Activate installation"
  6. Please note that YOU MUST after that click "Reset" tab, select "Execute an automatic hardware reset" and click "Send" to reboot the server in to initiate OS install.
  7. In a several MINUTES installation will be finished and you will receive an email with the details and information of successful Linux installation.
    Copy and save from there the following fields: IPv4 Address - this is your Server's IP address; Username - this is (most probably "root") your SSHlogin, and Password - this is your SSHpassword.
    If this step is taking more than 10 minutes please make sure you have successfully completed previous "Activate" and "Reboot" steps.
  8. Open Termius (should be already installed from the Termius site) and click "New Host" button.
    Enter your Server IPv4 Address into "Address" field,
    your SSHlogin into "Username" field,
    and SSHPassword into "Password" field. Click save, done!
  9. Open Cyberduck (of course it should already be installed from the Cyberduck site). Open "Bookmarks" in the top menu, pick "New Bookmark",
    select "SFTP", make up some cool Nickname,
    enter your server IPv4 as "address",
    your SSHlogin as "Username"
    and /opt as the path
    Now we are ready for some serious business!
    Make sure everything is in place (SSHpassword will be added later) and proceed (just close this window for MacOS).
  10. Now double-click on your newly created bookmark. At first, you will get a message about server "fingerprint". Don't worry, a new server will always do that. (You should be worried if the same message pops out later, though! You server most probably has been re-set or hacked)
    After that message another one will pop up, asking for the SSHpassword. Enter it here and don't forget to click "save" (or "add to keychain") checkmark to let system remember the password
  11. Copying file: Now you just need to drag-n-drop the HaasTradeServer file (namely the "linux32.tar.gz") to the Cyberduck window. This might take MINUTES. After you confirmed upload completed successfully (no "error" or "canceled" or any other messages) it is safe to exit Cybeduck and proceed to the next step
  12. Now run Termius and double-click on Host we have added previously. You might see another message about "Server Fingerprint", (similar to the one you've seen with CyberDuck already),

    and after accepting those - we are in!

Linux phase - AKA "The Dreadful Mono"

Estimated time ~30 minutes

  1. Updating packages.
    First things first, to keep the Ubuntu happy and fresh we should check for updates. Run the following command:
    sudo apt update
    Enter CASE-SENSITIVE letter Y to any questions.

    If you use up-to-date Ubuntu distributive chances are nothing will be updated.
  2. Installing Mono key
    Now we MUST first switch to Mono repository to get the latest version (it should be 5.xx.xx). Otherwise version 4.6.2 will be installed, which I had some problems with.
    Adding the repository key (it is a SINGLE LINE, do copy the command ENTIRELY):
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF The output from the command MUST be error-free.
  3. HTTPS-transport
    To aid with HTTS connectivity it is wise to install apt-https-transport package. Let's do that:
    sudo apt install apt-transport-https This should give no troubles and installs in seconds.
  4. Adding Mono Repository - UBUNTU 18 ONLY
    Now, this is a bit tricky one. You MUST know your Ubuntu version because commands are different. This is a manual for Ubuntu 18. For any other version please consult this page.
    echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.listAlso please mind this is a SINGLE LINE, ONE COMMAND.

    There should be no output for that command.
  5. Pre-Mono steps
    To ensure latest Mono is installed these additional steps must be performed.
    sudo apt update
    After that message indicating "packages might be upgraded" most probably will be show, so we do just that:
    sudo apt upgradeThen some packages will be upgraded; on any question just answer Y
  6. Now the actual MONO installation
    This step will take ~15-30 minutes, depending on your server configuration.
    sudo apt install mono-complete
    As this step is taking a lot of disk space and time you will be asked for confirmation. Just press capital Y to proceed.

    After pretty long time and a lot of text, everything is set
  7. Now we need to install Visual Basic for Mono so newest addition to the family - the Email Bot would work succesfully.
    sudo apt install mono-vbnc
    Of course system will ask you once again if you are completely sure, press Y

    Should take no more than several seconds
  8. Testing Mono installation.
    To do so we must run the command
    mono -VThe result should be basically any version higher than 5.12

    And now to check if we have necessary part of Mono installed, too - the mono-service - run mono-service
    The result must be like "You must specify at least the assembly name" but in general anything other than "No command found" error.

    If you have an older version of Mono or no Service reported this means you have missed some of the steps. Most probably steps to add "Mono key" or "Mono repository".
    It is crucial to go back and re-do those.

Linux final phase - AKA "The HaasTradeServer part"

Estimated time ~7 minutes
  1. Archive checkup.
    Let's go to the /opt folder now
    cd /opt
    And check if our Haas archived file is there
    ls
    We should see the linux32.tar.gz lying there silently

    If the file is not there please go back to "Cyberduck" steps in the beginning and re-do it again.
  2. Folder creation and unpacking.
    Now we need to make the folder for Haas server application.
    mkdir haas
    is a pretty simple command, so we accompany it with unpacking
    tar -C haas -xvf linux32.tar.gz

    Unpacker will show us a list of files it processed - no error should be given!
  3. Pre-configuration run.
    Now we must run Haas once to generate config files. This is easy, change folder
    cd haas
    And run initial
    sudo ./Haasbot.sh

    It would generate a lot of noise for sure, just ignore it for now.
  4. Configuring HaasTradeServer
    Now it's time to perform Haas configuration. Open config in in-built editor
    nano /root/HTS/Settings/MainSettings.XMLThis is how initial config look:

    Now imagine you are using Word (or a Notepad) and change TWO settings. Change ONLY the values. Do NOT delete\remove parameter names (words inside brackets).
    In parameter <OpenInterfaceOnStartup>true</OpenInterfaceOnStartup> change "true" to "false". Resulting line should read: <OpenInterfaceOnStartup>false</OpenInterfaceOnStartup> In parameter <HostingAdres>127.0.0.1</HostingAdres> change the address from 127.0.0.1 to your htsserver IPv4 address. File should be looking a bit like this (of course IP address must be of your server):

    After these two modifications were made, exit editor, saving changes: press CTRL+X, press Y and then press Enter
  5. Finally - the bot launch.
    Now make sure you are in the correct folder (just in case) by running
    cd /opt/haas
    And then, finally, the almighty
    sudo ./Haasbot.sh

    This might look like a lot of errors, but in fact it means literally nothing. We will proceed and check if everything is OK in the next step.
  6. Checking for the bot.Let's see if everything is good. HTS takes a minute to start, so first of all - take small pause (literally minute will be enough). Then run the following
    netstat -tulpn
    You should see your htsserver IP followed by :8090 and another line with :8092

    This indicates successful run.

9 comments:

  1. Nice tutorial,thanks.i will change for linux server
    is there a way to transfert all my saved bots from windows vps to the linux one ?

    ReplyDelete
    Replies
    1. Hey there! There is indeed, will make next writeup about that!
      In short - you need to transfer folder HTS from Windows "Documents\HTS" to Linux "/root/HTS"

      Delete
    2. Thank you a lot ! :D

      Delete
  2. Used this guide to setup and saved a lot of money over Vultr. I had to disable IVP6 to get the license to register in HTS. I moved a copy of HTS folder from vultr to the new Hetzner Ubuntu 18.04 server and updated the IP also turned off open browser as is covered in this guide. Thanks for the hard work. New server is running great so far -- trades a fly'n

    ReplyDelete
    Replies
    1. Great to hear that! More info is coming - on security and small tuning, too (like fixing missing coin icons, doing backup and autostarting HTS)

      Delete
  3. Thanks a heap for this, worked like a charm. Takes a minute or so to load the login screen but I chase this down in due course (maybe this is normal).

    ReplyDelete
    Replies
    1. It is really good to hear the feedback, thanks! Done some important improvements already to the text :) Next stop - adding more security, migrating from other install, upgrading and adding GUI access to the server!
      Stay tuned!

      Delete
  4. Thank you very much Russel, helpfull guide !

    ReplyDelete
    Replies
    1. Thank you, more to come! Just finished simple security one.

      Delete