From 38bc909c6a061a92ba9b891c7f8f67f1b0755c63 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Thu, 12 Jun 2025 21:25:37 +0200 Subject: [PATCH] Fix SSH user in lab status command --- packages/home-lab-tools.nix | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/home-lab-tools.nix b/packages/home-lab-tools.nix index 96fa98a..41e3a95 100644 --- a/packages/home-lab-tools.nix +++ b/packages/home-lab-tools.nix @@ -128,13 +128,29 @@ writeShellScriptBin "lab" '' warn " congenital-optimist: ⚠ Tailscale inactive" fi + # Check if -v (verbose) flag is passed + local verbose=0 + if [[ "''${1:-}" == "-v" ]]; then + verbose=1 + fi + # Check remote machines for machine in sleeper-service grey-area reverse-proxy; do + local ssh_user="sma" # Using sma as the admin user for remote machines + + # Test SSH connectivity with debug info if in verbose mode + if [[ $verbose -eq 1 ]]; then + log "Testing LAN connection to $machine..." + ${openssh}/bin/ssh -v -o ConnectTimeout=2 -o BatchMode=yes "$ssh_user@$machine" "echo OK" || true + log "Testing Tailscale connection to $machine.tailnet..." + ${openssh}/bin/ssh -v -o ConnectTimeout=2 -o BatchMode=yes "$ssh_user@$machine.tailnet" "echo OK" || true + fi + # Try with normal SSH first (for LAN) - if ${openssh}/bin/ssh -o ConnectTimeout=2 -o BatchMode=yes "sma@$machine" "echo OK" >/dev/null 2>&1; then + if ${openssh}/bin/ssh -o ConnectTimeout=2 -o BatchMode=yes "$ssh_user@$machine" "echo OK" >/dev/null 2>&1; then success " $machine: ✓ Online (LAN)" # Try with Tailscale hostname as fallback - elif ${openssh}/bin/ssh -o ConnectTimeout=2 -o BatchMode=yes "sma@$machine.tailnet" "echo OK" >/dev/null 2>&1; then + elif ${openssh}/bin/ssh -o ConnectTimeout=2 -o BatchMode=yes "$ssh_user@$machine.tailnet" "echo OK" >/dev/null 2>&1; then success " $machine: ✓ Online (Tailscale)" else warn " $machine: ⚠ Unreachable"