blob: b49a992c625ee2a167cb6a421015e7ef2feebec3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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" "$@"
|