Setting Up a Crypto Bot on VPS: systemd, Monitoring, and Security

Setting Up a Crypto Bot on VPS: systemd, Monitoring, and Security Picture this: you launched your bot on a home PC, went on vacation, and two days later it crashed because of a power outage. Losses—up to $1000 per day for an active trader. We configure your VPS so the bot runs 24/7 with **guarant

Blockchain Development Services

Frequently Asked Questions

Latest works

  • image_website-b2b-advance_0.webp
    B2B ADVANCE company website development
    1450
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1308
  • image_websites_belfingroup_462_0.webp
    Website development for BELFINGROUP
    1003
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1269
  • image_logo-advance_0.webp
    B2B Advance company logo design
    719
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    1009

Setting Up a Crypto Bot on VPS: systemd, Monitoring, and Security

Picture this: you launched your bot on a home PC, went on vacation, and two days later it crashed because of a power outage. Losses—up to $1000 per day for an active trader. We configure your VPS so the bot runs 24/7 with guaranteed 99.9% uptime. With over 50 projects under our belt, including HFT with sub-5ms latency, here's a proven recipe we use in every project.

How to Choose a VPS for Your Crypto Bot

For most trading bots, 2 vCPU, 4 GB RAM, and 40 GB SSD are sufficient. For bots with heavy analytics or a local node, go with 4–8 vCPU and 16–32 GB RAM. Comparison of configurations:

Bot Type vCPU RAM Disk Latency to Exchange
Standard (DCA, Grid) 2 4 GB 40 GB SSD < 30 ms
With analytics (ML) 4 16 GB 100 GB SSD < 20 ms
HFT / arbitrage 8 32 GB 200 GB NVMe < 5 ms (same data center)

Geographic location matters: latency to the exchange affects execution speed. Binance has servers in Frankfurt and Tokyo, Bybit in the Netherlands, dYdX on AWS us-east-1. For HFT, place your server in the same data center. For strategies holding positions longer than a minute, it's less critical.

OS: Ubuntu LTS or Debian stable. No GUI—only headless server.

Why systemd Instead of screen or tmux?

screen, tmux, and nohup are for development. For production, use only systemd. It restarts the process on crash, manages logs, and starts on server reboot. Systemd is built into Ubuntu/Debian, requires no extra packages, and gives fine-grained resource control. According to systemd documentation, unit files provide complete process isolation. In practice, systemd restarts your bot 10x faster than manual monitoring, and downtime losses for arbitrage strategies can reach $1000 per day.

Isolation and Dependency Management

# Update system apt update && apt upgrade -y apt install -y python3.11 python3.11-venv python3-pip git # Create unprivileged user useradd -m -s /bin/bash botuser su - botuser # Python virtual environment python3.11 -m venv /home/botuser/bot-env source /home/botuser/bot-env/bin/activate pip install -r requirements.txt # Node.js via nvm (not apt—outdated versions) curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash source ~/.bashrc nvm install 20 nvm use 20 cd /home/botuser/mybot && npm ci --production 

Never run the bot as root. If the bot is compromised, minimal permissions mean minimal damage.

Systemd Service Configuration

# /etc/systemd/system/trading-bot.service [Unit] Description=Trading Bot After=network-online.target Wants=network-online.target [Service] Type=simple User=botuser Group=botuser WorkingDirectory=/home/botuser/mybot # Python ExecStart=/home/botuser/bot-env/bin/python main.py # Node.js alternative: # ExecStart=/home/botuser/.nvm/versions/node/v20.0.0/bin/node index.js Restart=on-failure RestartSec=10s StartLimitIntervalSec=60s StartLimitBurst=3 # Resource limits MemoryMax=2G CPUQuota=150% # Environment variables from file EnvironmentFile=/home/botuser/mybot/.env # Logging StandardOutput=journal StandardError=journal SyslogIdentifier=trading-bot [Install] WantedBy=multi-user.target 

After creating the file, activate the service: systemctl daemon-reload && systemctl enable trading-bot && systemctl start trading-bot. Check status: systemctl status trading-bot. Logs: journalctl -u trading-bot -f --since "1 hour ago".

Restart=on-failure + RestartSec=10s + StartLimitBurst=3 ensures the bot restarts on crash but avoids infinite crash loops.

How to Secure the Server Against Hacks?

# Disable password SSH, use keys only sed -i 's/#PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config systemctl restart ssh # UFW—open only required ports ufw default deny incoming ufw allow ssh ufw allow 443/tcp # if web interface exists ufw enable # Fail2ban against SSH brute force apt install fail2ban -y systemctl enable fail2ban --now 

Exchange API keys: set up an IP whitelist on the exchange—only your VPS IP. Even if the key leaks, it won't work from other IPs.

Environment Variables and Secrets

Never put API keys in code or git. Use a .env file with restricted permissions: chmod 600 and chown botuser:botuser. .gitignore must include .env. Verify that .env hasn't accidentally ended up in git history: git log --all --full-history -- .env.

How to Set Up Monitoring and Alerts?

The bot should report problems by itself. Minimal setup: send notifications via Telegram.

import telebot import functools from aiohttp import web import time bot_notifier = telebot.TeleBot(os.environ['TELEGRAM_BOT_TOKEN']) ADMIN_CHAT_ID = os.environ['TELEGRAM_CHAT_ID'] def notify(message: str, level: str = 'INFO'): prefix = {'INFO': 'INFO', 'WARNING': 'WARNING', 'ERROR': 'ERROR'}.get(level, '') try: bot_notifier.send_message(ADMIN_CHAT_ID, f"{prefix} {message}") except Exception: pass # In exception handler except Exception as e: notify(f"Bot crashed: {type(e).__name__}: {e}", level='ERROR') raise 

External watchdog: UptimeRobot or similar pings an HTTP health endpoint every 5 minutes. Bot returns 200—alive. Otherwise, SMS/email alert. Comparison of monitoring methods:

Method Response Time Cost Bot Dependency
Telegram notifications Up to 1 second Free Yes (built-in)
UptimeRobot 5 minutes Free (50 checks) No
journalctl Manual Free No
Additional monitoring methods Install Node Exporter for CPU/RAM/disk metrics, set up Prometheus + Grafana for visualization. Use Alertmanager for Telegram alerts. This gives a complete picture of server and bot health.

Deployment Script

#!/bin/bash set -e cd /home/botuser/mybot git pull origin main source /home/botuser/bot-env/bin/activate pip install -r requirements.txt --quiet systemctl restart trading-bot sleep 3 systemctl status trading-bot --no-pager 

For more complex projects, use GitHub Actions + SSH deployment triggered automatically on push to main.

What's Included in Turnkey Setup

  • VPS configuration selection based on your strategy (see table above)
  • OS installation and basic software
  • systemd unit creation with resource limits
  • Telegram notifications and health endpoint integration
  • Security setup: SSH keys, UFW, Fail2ban, exchange IP whitelist
  • Test run and auto-restart verification on crash
  • Deployment script for quick updates
  • Operation instructions (access, logs, common commands)

Contact us to evaluate your project and get a commercial offer. Order VPS setup for your crypto bot—our engineers will prepare your server within one day. We guarantee stable 24/7 operation and prompt support.

Our Process

We follow a structured approach to ensure every deployment is reliable:

  1. Data gathering – We discuss your bot's requirements, strategy, and expected load.
  2. Audit/Analysis – We review your bot's dependencies and performance needs.
  3. Design – We propose the optimal VPS configuration and architecture.
  4. Estimation – We provide a detailed timeline and cost estimate based on the analysis.
  5. Development – We set up the server, configure systemd, security, and monitoring.
  6. Testing – We simulate failures to verify auto-restart and alerts.
  7. Launch – We go live and provide you with full documentation.

Timelines

Setup typically takes 1 to 3 days depending on the complexity of your bot and infrastructure requirements. Complex HFT setups with custom monitoring may require additional time.

Common Mistakes to Avoid

  • Running the bot as root—always use a dedicated unprivileged user.
  • Storing API keys in code or committing .env to git.
  • Using screen/tmux for production—systemd is the only robust option.
  • Skipping IP whitelisting on exchange API keys.
  • Forgetting to set resource limits in the systemd unit file.

Our team has firsthand experience with these pitfalls and will ensure your setup avoids them.