Skip to content

joaoslva/magic-switch

Repository files navigation

Magic Switch

A Flutter app to control my home server cimbalino.net from my phone. It connects to the server through a Raspberry Pi acting as a gateway, using SSH key-based authentication.

What it does

The app gives a simple visual interface with three nodes — Phone, Raspberry Pi, and Server — connected by animated lines that reflect live connection state. From there you can:

  • Connect to the Pi over SSH to check reachability and server status in one step
  • Wake the server by triggering a script on the Pi
  • Shut the server down with a confirmation step
  • Disconnect from the Pi and reset all state

How it works

Phone  ──SSH──►  Raspberry Pi  ──LAN──►  Home Server

The app SSHes into the Pi using a stored private key. Once connected, it runs two scripts that must exist on the Pi:

  • ~/wake.sh — wakes the server (e.g. via wake-on-LAN)
  • ~/shutdown.sh — shuts the server down

Stack

  • Flutter (Material 3, light theme)
  • dartssh2 — SSH client
  • flutter_secure_storage — encrypted credential storage (Android Keystore)
  • local_auth — biometric / PIN gate on every launch
  • file_picker — SSH private key import

Current state

The app is yet to be tested end-to-end — the implementation is ongoing and nothing has been run against real hardware. What's in place:

  • Biometric/PIN authentication on launch
  • Encrypted storage for the Pi config (IPv6, port, username) and SSH private key
  • Interactive three-node home screen with animated dashed connection lines
  • Contextual subtitles and toast messages that guide the user at every step
  • Settings screen with input validation, key format checking, and existing-key status indicator
  • Help screen explaining the full flow
  • Custom app icon
  • Color palette: #dad7cd / #a3b18a / #588157 / #344e41 (forest greens) + #c44536 (destructive red)

What's not there yet:

  • No persistent SSH connection — each action opens and closes its own session
  • No push notifications or background polling for server state
  • No Android widget or quick-tile shortcut
  • iOS not tested

Setup

  1. Make sure ~/wake.sh and ~/shutdown.sh exist and are executable on your Pi
  2. Ensure your Pi has a static global IPv6 address reachable from mobile data
  3. Add your phone's SSH public key to ~/.ssh/authorized_keys on the Pi
  4. Open the app, authenticate, tap ⚙, fill in the Pi's IPv6 address, port, username, and select your private key file

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors