-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart_ssh_control.sh
More file actions
executable file
·52 lines (49 loc) · 1.57 KB
/
Copy pathstart_ssh_control.sh
File metadata and controls
executable file
·52 lines (49 loc) · 1.57 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
#!/bin/bash
current_path="$(dirname "$0")"
source $current_path/read_user_password.sh
CLUSTER_DEFAULT=bluehive3
CLUSTER=$CLUSTER_DEFAULT # Set the default value here; supported values are bluehive3, bluehive, or bhward
while [[ $# -gt 0 ]]; do
case "$1" in
-a|--cluster)
if [[ -z "$2" || "$2" == -* ]]; then
echo "Error: $1 requires a cluster name" >&2
exit 1
fi
CLUSTER="$2"
shift 2
;;
--)
shift
break
;;
-*)
echo "Error: Unknown option '$1'" >&2
exit 1
;;
*)
echo "Error: Unexpected argument '$1'" >&2
exit 1
;;
esac
done
echo "Starting SSH session to $CLUSTER."
# Set HOSTNAME based on CLUSTER
if [ "$CLUSTER" = "bluehive3" ]; then
HOSTNAME="bluehive3.circ.rochester.edu"
elif [ "$CLUSTER" = "bluehive" ]; then
HOSTNAME="bluehive.circ.rochester.edu"
elif [ "$CLUSTER" = "bhward" ]; then
HOSTNAME="bhward.circ.rochester.edu"
else
echo "Error: Unknown cluster '$CLUSTER'. Supported clusters: bluehive3, bluehive, bhward"
exit 1
fi
# Detect OS and use appropriate sshpass binary
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS - Use SSH control master configuration
$current_path/sshpass_mac_arm64 -p "$PASSWORD" ssh -o ControlMaster=auto -o StrictHostKeyChecking=no -fN $USER@$HOSTNAME
else
# Linux
$current_path/sshpass_linux_amd64 -p "$PASSWORD" ssh -o ControlMaster=auto -o StrictHostKeyChecking=no -fN $USER@$HOSTNAME
fi