Automating Remote Python Dashboards with a Bash Script

Running Python dashboards on a remote machine can feel repetitive: log in via SSH, activate a virtual environment, navigate into the right directory, and finally launch your script. Doing that every time by hand is error-prone. I solved this by writing a Bash script that automates the whole process.
Here’s the (sanitized) version:
#!/bin/bash
Example script to start a remote Python dashboard
--- CONFIG ---
REMOTE_USER="username"
REMOTE_HOST="xxx.xxx.xxx.xxx" # obfuscated IP
REMOTE_PASS="********" # obfuscated password
VENV_PATH="~/peakecoin_venv_312/bin/activate"
APP_DIR="~/peakecoin/swapbots/uni_bots"
APP="dashboard.py"
--- EXECUTE ---
sshpass -p "$REMOTE_PASS" ssh -t -o StrictHostKeyChecking=no ${REMOTE_USER}@${REMOTE_HOST}
"bash -c 'source $VENV_PATH && cd $APP_DIR && nohup python3 $APP > dashboard.log 2>&1 &'"
How It Works:
- sshpass: lets the script pass credentials non-interactively
- StrictHostKeyChecking=no: avoids prompts on first connection
- source $VENV_PATH: activates the Python virtual environment
- cd $APP_DIR && python3 $APP: navigates to the right folder and starts the dashboard
- nohup … &: keeps it running even after you disconnect
Security Note:
For safety, you should never hard-code passwords or IP addresses in a production script.
A better approach is to store credentials in environment variables ($DASH_PASS, $DASH_IP, etc)
or use SSH keys instead of passwords. That way, you can share your script publicly while
keeping sensitive information private.
With this in place, starting the dashboard remotely is as simple as:
./start_dashboard.sh
Congratulations @peakecoin! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)
Your next target is to reach 50 posts.
You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word
STOP