Permalink: https://naked.bike/45
- Select
Ubuntu Server 16.04 LTS 64-bit
- Recommend
General Purpose
-t2.small
instance type. (1 CPU core, 2GB RAM) - Select a subnet.
us-east-1x
,us-east-2x
,us-west-2x
are $0.023/hr fort2.small
- Select 8GB GP2 SSD ($0.80/month)
- Tags are optional
- Create a new security group and call it
crypto-bot
. For now, leave port22
open toAnywhere
- Review and Launch
- Select
Create a new key pair
, name itcryptobot
and download the private key file. (cryptobot.pem
)
At this point, view your new VPS in EC2 Instances and give it a unique name. Find the public domain for your instance and save it for later, we'll need it to establish an SSH connection.
looks like ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com
Copy private key file to ~/.ssh
mv ~/Downloads/cryptobot.pem ~/.ssh/
Set permissions on private key file to owner can read and write
chmod 600 ~/.ssh/cryptobot.pem
Secure private key file with a password
ssh-keygen -p -f ~/.ssh/cryptobot.pem
Add alias to ssh config
nano ~/.ssh/config
Add the following entry at the end of the file.
Host cryptobot
IdentityFile ~/.ssh/cryptobot.pem
HostName ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com
User ubuntu
Save and exit.
Connect to server
ssh cryptobot
Type in your password and you will be logged into your remote instance. The first time you log in it will ask you to verify the ECDSA key fingerprint, type yes
to bypass this prompt in the future.
First, let's bring the entire server up to date and reboot.
sudo apt-get update && sudo apt-get dist-upgrade -y && sudo shutdown now -r
Upon completion you will be disconnected from the server as it reboots. Wait 2 minutes and reconnect with ssh cryptobot
Install Profit Trailer Dependencies
Add apt repository for certbot, which will be used later.
sudo add-apt-repository ppa:certbot/certbot
These commands install Node.js, npm, essential build tools, Java Development Kit, nginx, and certbot for nginx. Should run with no prompts.
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs build-essential openjdk-8-jre nginx python-certbot-nginx unzip
sudo npm i -g pm2
Now, set pm2 to launch at startup with systemd.
pm2 startup
Copy and paste the command, which should look something like this:
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu
And create a pm2 config file.
pm2 save
Download latest release https://github.com/taniman/profit-trailer/releases
wget https://github.com/taniman/profit-trailer/releases/download/X.X.X/ProfitTrailer-X.X.X.zip
unzip ProfitTrailer-X.X.X.zip
mv ProfitTrailer-X.X.X ProfitTrailer
Edit application properties and set to test mode
cd ProfitTrailer/
nano application.properties
Fill in your license key, api token, exchange info, exchange API keys, time zone, and any other settings you want to change here. Make sure server.test_mode
is set to true
. Profit Trailer will intialize your settings and then you can tweak them through the interface later before taking it out of testing mode.
Your application.properties file should look like this:
license = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
server.port = 8081
server.api_token =
server.sitename = My BTC Bot
trading.exchange = BINANCE
trading.log_history = 8
server.timezone_offset = -04:00
server.language = enus
server.skin = dark
server.currency = USD
server.disable_password = false
server.disable_config = false
server.disable_online_config = false
server.enable_shutdown = true
server.disable_notification = false
server.disable_browser = false
telegram.bot_token_1 =
telegram.chat_1 =
telegram.disable_notification = true
discord.bot_token_1 =
discord.chat_1 =
default_api_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
default_api_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
trading_api_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
trading_api_secret = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
telegram.startup_notification = false
discord.startup_notification = false
telegram.shutdown_notification = false
discord.shutdown_notification = false
server.start_trading_delay = 0
#testmode does paper trading so you will see buy and sell activity.
server.test_mode = true
#timeout in seconds
connection.timeout = 30
#enabling debug modes when support asks you
#logging.level.nl.komtek = DEBUG
#logging.level.nl.komtek.pt.services = TRACE
Save the configuration and start the bot
pm2 start pm2-ProfitTrailer.json
pm2 save
View the logs to ensure a successful start
pm2 logs profit-trailer
The output should like this:
0|profit-t | 2018-05-19 03:13 +00:00:
0|profit-t | 2018-05-19 03:13 +00:00: . ____ _ __ _ _2018-05-19 03:13 +00:00:
0|profit-t | 2018-05-19 03:13 +00:00: /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \2018-05-19 03:13 +00:00:
0|profit-t | 2018-05-19 03:13 +00:00: ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \2018-05-19 03:13 +00:00:
0|profit-t | \\/ ___)| |_)| | | | | || (_| | ) ) ) )
0|profit-t | ' |____| .__|_| |_|_| |_\__, | / / / /
0|profit-t | =========|_|==============|___/=/_/_/_/
0|profit-t | 2018-05-19 03:13 +00:00: :: Spring Boot :: (v1.5.9.RELEASE)2018-05-19 03:13 +00:00:
0|profit-t | 2018-05-19 03:13 +00:00:
0|profit-t | 2018-05-19 03:13 +00:00: 2018-05-19 03:13:22 INFO Application - PT Version: 2.0.3
0|profit-t | 2018-05-19 03:13 +00:00: 2018-05-19 03:13:22 INFO Application - Java Version: 1.8.0_171
0|profit-t | 2018-05-19 03:13 +00:00: 2018-05-19 03:13:24 INFO ConfigApi - Please finish the setup process in your browser
PressCTRL+C
to quit. If you have any trouble getting Profit Trailer to start, consult the wiki or the #Support channel on Discord.
For this step I recommend using a subdomain of a domain you already own. Create a CNAME record in your DNS settings for the subdomain (ie. cryptobot.yourdomain.com
) and point it to the address we used to connect to SSH earlier. (ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com
) Don't move on to NGINX setup until you've selected a domain and setup your DNS. We will need this domain later to encrypt the connection to the browser dashboard.
Open HTTP/HTTPS ports
In the EC2 Dashboard on AWS, select Security Groups in the list and select the Security Group you specified when you created the instance. Give it a unique name if it doesn't already have one. Edit the inbound rules and add HTTP
and HTTPS
(Ports 80 and 443) to the list, and make them accessible Anywhere.
Setup NGINX
sudo nano /etc/nginx/sites-available/cryptobot
Add the following settings to this file. Replace cryptobot.yourdomain.com
with your chosen and configured domain name.
server {
server_name cryptobot.yourdomain.com;
location / {
proxy_pass http://localhost:8081;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Save and exit. Now create a symlink to enable it.
cd /etc/nginx/sites-enabled/
sudo ln -s ../sites-available/cryptobot
Check to make sure the settings are OK before enabling them.
sudo nginx -t
If your configuration is suitable, you will see the following output:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Restart NGINX
sudo systemctl restart nginx
SETUP SSL with Certbot
sudo certbot --nginx -d cryptobot.yourdomain.com
The first time you use Certbot it will ask for an email address, and it will ask you to agree to the terms of service. You must agree to the terms to use this feature. It will also ask you if you're willing to share your email address, and that is optional.
Each time you setup an HTTPS instance with certbot, it will ask if you want to automatically redirect unsecure traffic to your secure HTTPS server. I recommend enabling the redirect, just in case you forget to use https. (Option 2)
Finish Profit Trailer Setup
Visit your profit trailer site in a web browser using the secure HTTPS link. (ie. https://cryptobot.yourdomain.com)
The first thing you will be instructed to do is create a password. Make sure it's strong and stored in a safe, encrypted place. Personally, I use LastPass to generate random, secure passwords and to save them. In order to create a password you will need to verify the API key that is linked to your account.
After creating a password, you will be asked to select a name for your cryptobot settings profile. Name it whatever you want.
Once you have created your settings profile, you will see your dashboard, with your current balances, and it should say Test Mode
in the top right corner.
This is a technical guide on how to setup a secure VPS for use with Profit Trailer. I offer no advice on which trading settings to use. Please, for your sake, do your research and test your settings before taking your bot out of test mode. It's very easy to lose money with the wrong settings. Consider yourself warned, and enjoy.
Install dependencies
sudo apt-get install -y lubuntu-core tightvncserver
Initialize VNC Server
vncserver
On the first run, Tight VNC will ask you to create a password that is used to connect to the server. You can also create a view-only password, but it is optional, and usually not necessary.
Stop the server
vncserver -kill :1
Edit your xstartup
file and replace the last line
nano ~/.vnc/xstartup
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
/usr/bin/startlxde
Automatically start Tight VNC with systemd
Create systemd bash script:
sudo nano /etc/systemd/system/[email protected]
[Unit]
Description=Start TightVNC server at startup
After=syslog.target network.target
[Service]
Type=forking
User=ubuntu
PAMName=login
PIDFile=/home/ubuntu/.vnc/%H:%i.pid
ExecStartPre=-/usr/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/usr/bin/vncserver -depth 24 -geometry 1280x800 :%i
ExecStop=/usr/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
Enable and start new service
sudo systemctl daemon-reload
sudo systemctl enable [email protected]
sudo systemctl start [email protected]
Install Chromium Browser
sudo apt-get install -y chromium-browser
Create a persistent SOCKS connection
ssh -L 1202:127.0.0.1:5901 -N -f -l ubuntu ec2-XXX-XXX-XXX-XXX.compute-1.amazonaws.com -i ~/.ssh/cryptobot.pem
Now, open Screen Sharing, which can be found via Spotlight search. Connect to 127.0.0.1:1202 and type in the password you created earlier. You should be able to open Chromium Browser now and the rest is up to you.
Installing node.js via package manager
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
How To Set Up a Node.js Application for Production on Ubuntu 16.04
How To Secure Nginx with Let's Encrypt on Ubuntu 16.04
Profit Trailer Wiki
https://wiki.profittrailer.com/doku.php
How to Install and Configure VNC on Ubuntu 16.04
Note that I opted to use lubuntu instead of xfce. This is because lubuntu does a better job of emulating the graphical user interface when there is no OpenGL compliant GPU installed in the system.
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-vnc-on-ubuntu-16-04