Browse Source

Add SSH key authentication for device access via ttyd

Uses ~/.ssh/device_access key to connect to devices through tunnels.
Public key needs to be added to device firmware's authorized_keys.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
root 2 weeks ago
parent
commit
9eccedfbe9
1 changed files with 4 additions and 0 deletions
  1. 4 0
      backend/app/services/tunnel_service.py

+ 4 - 0
backend/app/services/tunnel_service.py

@@ -223,11 +223,15 @@ class TunnelService:
 
         # Spawn ttyd process
         # ttyd connects to device via SSH through the tunnel port
+        # Uses dedicated key for device access
+        import os
+        ssh_key = os.path.expanduser("~/.ssh/device_access")
         cmd = [
             "ttyd",
             "--port", str(ttyd_port),
             "--writable",  # Allow input
             "ssh",
+            "-i", ssh_key,
             "-p", str(device_tunnel_port),
             "-o", "StrictHostKeyChecking=no",
             "-o", "UserKnownHostsFile=/dev/null",