-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvm-ssh
More file actions
executable file
·51 lines (40 loc) · 1.05 KB
/
Copy pathvm-ssh
File metadata and controls
executable file
·51 lines (40 loc) · 1.05 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# vm-ssh - Quick virtctl SSH wrapper
#
# Opens an SSH session to a KubeVirt VM via virtctl.
#
# Usage: vm-ssh <vm-name> <namespace> [user]
# user defaults to 'root' if not specified
set -eu
fatal() {
echo "Error: $*" >&2
exit 1
}
usage() {
cat <<EOF
Usage: $(basename "$0") <vm-name> <namespace> [user]
Open an SSH session to a KubeVirt VM via virtctl.
Arguments:
vm-name Name of the virtual machine
namespace Kubernetes namespace
user SSH user (default: root)
EOF
exit "${1:-0}"
}
if [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]]; then
usage 0
fi
if [[ -z "${1:-}" ]] || [[ -z "${2:-}" ]]; then
usage 1
fi
VM=$1
NS=$2
USER=${3:-root}
if [[ -z "$(type -t virtctl)" ]]; then
fatal "virtctl command is not installed (see helpers/install-virtctl)"
fi
# Avoid "Too many authentication failures": skip pubkey so we don't exhaust server MaxAuthTries
exec virtctl ssh \
--local-ssh-opts="-o PasswordAuthentication=yes" \
--local-ssh-opts="-o PubkeyAuthentication=no" \
-n "$NS" "$USER@vmi/$VM"