-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcluster_ssh.sh
More file actions
executable file
·60 lines (51 loc) · 1.33 KB
/
Copy pathcluster_ssh.sh
File metadata and controls
executable file
·60 lines (51 loc) · 1.33 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
52
53
54
55
56
57
58
59
60
#!/usr/bin/env bash
set -Eeuo pipefail
script_directory="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_directory}/cluster_helpers.sh"
cluster_name="bluehive3"
print_usage() {
cat <<'EOF'
Usage: cluster_ssh.sh [-a|--cluster CLUSTER] [--] [remote-command [argument ...]]
Open the cluster login node without requiring a ~/.ssh/config entry.
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
-a|--cluster)
[[ -n "${2:-}" && "$2" != -* ]] || {
echo "Error: $1 requires a cluster name" >&2
exit 1
}
cluster_name="$2"
shift 2
;;
--cluster=*)
cluster_name="${1#*=}"
shift
;;
-h|--help)
print_usage
exit 0
;;
--)
shift
break
;;
-*)
echo "Error: Unknown option '$1'" >&2
exit 1
;;
*)
break
;;
esac
done
require_cluster "${cluster_name}" || exit 1
# shellcheck disable=SC1090
source "${script_directory}/start_ssh_control.sh" --cluster "${cluster_name}"
ssh_arguments=(
-F /dev/null
-o "ControlPath=${SSH_CONTROL_PATH}"
)
[[ $# -gt 0 ]] && ssh_arguments+=(-T)
exec /usr/bin/ssh "${ssh_arguments[@]}" "${SSH_LOGIN_TARGET}" "$@"