This repository provides a Makefile-based automation system for managing remote SSH access using ngrok and sending connection details via WhatsApp through CallMeBot. Additionally, it includes power-saving and cooling control scripts to optimize energy consumption on a Raspberry Pi.
- Remote SSH Access: Uses ngrok to expose port 22 for SSH.
- WhatsApp Notifications: Sends the ngrok connection URL via CallMeBot.
- Power Management: Monitors SSH activity to toggle power-saving modes.
- Cooling Control: Manages fan speed based on CPU temperature.
Ensure the following dependencies are installed:
- Ngrok:
curl -s https://ngrok-agent.s3.amazonaws.com/ngrok.asc | sudo tee /etc/apt/trusted.gpg.d/ngrok.asc >/dev/null && echo "deb https://ngrok-agent.s3.amazonaws.com buster main" | sudo tee /etc/apt/sources.list.d/ngrok.list && sudo apt update && sudo apt install ngrok
jqpsutil(Python package)
git clone https://github.com/Erde321/startupraspCreate an ngrok https://dashboard.ngrok.com/get-started/your-authtoken and enter your Token:
ngrok authtoken <your-ngrok-token>Follow the setup instructions from the CallMeBot repository to configure message sending. The file 'callmebot.py' from CallMeBot-Whatsapp-Signal needs to be in the directory 'callmebot'!
make startThis will:
- Stop any existing ngrok process
- Start the fan control script
- Launch ngrok and extract the public SSH address
- Send the SSH address to a predefined WhatsApp number
make stopThis will terminate any running ngrok process.
To start the script at boot, add the following cron job:
crontab -eAdd this line:
@reboot cd /path/to/repository && make start &The monitor_ssh.py script continuously checks for active SSH/VNC sessions:
- If a session is detected, normal power mode is enabled.
- If no session is active, the Raspberry Pi enters power-saving mode.
To start the monitoring script manually:
python powercontrol/monitor_ssh.pyTo manually switch power modes, run:
sudo ./powercontrol/pi_power_mode.sh powersave
sudo ./powercontrol/pi_power_mode.sh normalThe fancontrol.sh script adjusts fan speed based on CPU temperature.
- 55°C → Low speed (33%)
- 60°C → Medium speed (66%)
- 65°C → High speed (100%)
Run the fan control script manually:
sudo ./fancontrol/fancontrol.shThe sendtext.py script sends WhatsApp messages via CallMeBot.
Before using the script, update sendtext.py with your phone number and API token:
python sendtext.py 'Your Message Here'Ensure you have configured your CallMeBot credentials correctly.
This project is open-source. Feel free to modify and improve!