aboutsummaryrefslogtreecommitdiff
path: root/tools/rumba-access
blob: 02f639e05016de77e21869a44d96253835ca9e2b (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
35
36
37
38
39
40
#!/usr/bin/env bash

FILE=/tmp/rumba/ssh_info

MACHINE_ID=$1
if [ "$MACHINE_ID" == "" ]; then
	echo "usage: $0 NODE_NAME"
	exit 255
fi

USER=$(grep "\<${MACHINE_ID}\>" ${FILE} | awk -F';' '{print $2}')
if [ "$USER" == "" ]; then
	echo "Error: Node ${MACHINE_ID} unknown"
	exit 255
fi

HOST=$(grep "\<${MACHINE_ID}\>" ${FILE} | awk -F';' '{print $3}')
if [ "$HOST" == "" ]; then
	echo "Error: Node ${MACHINE_ID} unknown"
	exit 255
fi

SSH_PORT=$(grep "\<${MACHINE_ID}\>" ${FILE} | awk -F';' '{print $4}')
if [ "$SSH_PORT" == "" ]; then
	echo "Error: Node ${MACHINE_ID} unknown"
	exit 255
fi

PROXY=$(grep "\<${MACHINE_ID}\>" ${FILE} | awk -F';' '{print $5}')
if [ "$PROXY" == "" ]; then
	echo "Error: Node ${MACHINE_ID} unknown"
	exit 255
fi

echo "Accessing Rumba node ${MACHINE_ID}"
if [[ $PROXY = "None" ]]; then
    ssh -A -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p ${SSH_PORT} ${USER}@${HOST}
else
    ssh -A -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -oProxyCommand="ssh ${USER}@$PROXY -W %h:%p" -p ${SSH_PORT} ${USER}@${HOST}
fi