Fix: Always use explicit SSH key path for all SSH operations
CRITICAL FIX: SSH keys were not being auto-loaded, causing connection failures. Changes: - tools.py: SSH commands now include -i /var/lib/macha/.ssh/id_ed25519 - remote_monitor.py: Use explicit key path instead of sudo ssh - system_discovery.py: Added explicit key path to all SSH calls - system_prompt.txt: Document automatic SSH key loading - DESIGN.md: Clarify CRITICAL requirement for explicit key paths All SSH operations now explicitly specify: -i /var/lib/macha/.ssh/id_ed25519 -o StrictHostKeyChecking=no This ensures Macha can reliably connect to remote hosts without depending on SSH agent or automatic key discovery.
This commit is contained in:
9
tools.py
9
tools.py
@@ -269,17 +269,20 @@ class SysadminTools:
|
||||
}
|
||||
|
||||
# Automatically configure SSH commands to use macha user on remote systems
|
||||
# Transform: ssh hostname cmd -> ssh macha@hostname sudo cmd
|
||||
# Transform: ssh hostname cmd -> ssh -i /var/lib/macha/.ssh/id_ed25519 macha@hostname sudo cmd
|
||||
if command.strip().startswith('ssh ') and '@' not in command.split()[1]:
|
||||
parts = command.split(maxsplit=2)
|
||||
if len(parts) >= 2:
|
||||
hostname = parts[1]
|
||||
remaining = ' '.join(parts[2:]) if len(parts) > 2 else ''
|
||||
# Always use explicit SSH key path
|
||||
ssh_key = "/var/lib/macha/.ssh/id_ed25519"
|
||||
ssh_opts = f"-i {ssh_key} -o StrictHostKeyChecking=no"
|
||||
# If there's a command to run remotely, prefix it with sudo
|
||||
if remaining:
|
||||
command = f"ssh macha@{hostname} sudo {remaining}".strip()
|
||||
command = f"ssh {ssh_opts} macha@{hostname} sudo {remaining}".strip()
|
||||
else:
|
||||
command = f"ssh macha@{hostname}".strip()
|
||||
command = f"ssh {ssh_opts} macha@{hostname}".strip()
|
||||
|
||||
try:
|
||||
result = subprocess.run(
|
||||
|
||||
Reference in New Issue
Block a user