summaryrefslogtreecommitdiffstats
path: root/scripts/ssh_guest.sh
diff options
context:
space:
mode:
authorArthur Hanson Rasmusson <arthur@vgpu.io>2026-10-11 20:42:45 -0400
committerArthur Hanson Rasmusson <arthur@vgpu.io>2026-10-11 20:42:45 -0400
commit66d7e5f93ed0f3139ba4a6635bf355a4c0052a04 (patch)
tree7f1b13189d8ed41ecc7e1eb0d415ceb8fcb389fd /scripts/ssh_guest.sh
parentc973ec566abc6d71c58b591ca45237f2725092ef (diff)
downloadopen-iov-66d7e5f93ed0f3139ba4a6635bf355a4c0052a04.tar.gz
open-iov-66d7e5f93ed0f3139ba4a6635bf355a4c0052a04.zip
scripts: add ssh_guest.sh - reliable SSH into the running vGPU guest
Password auth with key auth disabled outright: the host's id_rsa is passphrase-protected and a stale copy of its public key in the guest's authorized_keys made plain ssh hang on the passphrase prompt (the reported 'sshpass hangs'). Wrapper defaults to 127.0.0.1:2222 ubuntu/ubuntu, overridable via VGPU_GUEST_*.
Diffstat (limited to 'scripts/ssh_guest.sh')
-rwxr-xr-xscripts/ssh_guest.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/scripts/ssh_guest.sh b/scripts/ssh_guest.sh
new file mode 100755
index 0000000..b49a992
--- /dev/null
+++ b/scripts/ssh_guest.sh
@@ -0,0 +1,34 @@
+#!/bin/bash
+# ssh_guest.sh - SSH into the running vGPU guest.
+#
+# Usage:
+# scripts/ssh_guest.sh # interactive shell
+# scripts/ssh_guest.sh "nvidia-smi -L" # run one command
+#
+# Why the explicit options: the host's ~/.ssh/id_rsa is passphrase-protected
+# and the guest image once carried its public key in authorized_keys; ssh
+# offered the key, the guest accepted it and the session hung on the
+# passphrase prompt (sshpass only answers password prompts). The stale key
+# was removed from the guest; this wrapper also disables key auth outright so
+# the session can never hang that way again. Password auth is used.
+#
+# Overridable: VGPU_GUEST_HOST, VGPU_GUEST_PORT, VGPU_GUEST_USER,
+# VGPU_GUEST_PASS (defaults 127.0.0.1:2222 ubuntu/ubuntu).
+set -u
+HOST="${VGPU_GUEST_HOST:-127.0.0.1}"
+PORT="${VGPU_GUEST_PORT:-2222}"
+USER="${VGPU_GUEST_USER:-ubuntu}"
+PASS="${VGPU_GUEST_PASS:-ubuntu}"
+
+command -v sshpass >/dev/null || { echo "sshpass not installed" >&2; exit 1; }
+
+exec sshpass -p "$PASS" ssh \
+ -p "$PORT" \
+ -o StrictHostKeyChecking=no \
+ -o UserKnownHostsFile=/dev/null \
+ -o PubkeyAuthentication=no \
+ -o PreferredAuthentications=password \
+ -o ConnectTimeout=15 \
+ -o ServerAliveInterval=15 \
+ -o ServerAliveCountMax=4 \
+ "$USER@$HOST" "$@"