#!/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" "$@"