File: ssh

package info (click to toggle)
strongswan 6.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 61,584 kB
  • sloc: ansic: 405,188; sh: 11,621; makefile: 6,254; sql: 2,885; javascript: 1,948; python: 990; xml: 608; perl: 586; cs: 522; lex: 485; yacc: 443; ruby: 398; ada: 114
file content (37 lines) | stat: -rwxr-xr-x 649 bytes parent folder | download | duplicates (9)
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
#!/bin/bash

DIR=$(dirname `readlink -f $0`)
. $DIR/testing.conf
SSHCONF="-F $DIR/ssh_config"

if [ $# == 0 ]
then
	echo "$0 <host>"
	exit 1
fi

host=$1
echo "$host" | grep -q "^\([0-9]\+\.\|[0-9a-fA-F]\+:\).*"
if [ $? -eq 0 ]
then
	# assume we got an ip address
	ip=$host
else
	pos='$1'
	echo "$host" | grep -q ".*1$"
	if [ $? -eq 0 ]
	then
		# {host}1, use second address
		pos='$2'
		host=`echo "$host" | sed -n -e "s/1$//p"`
	fi
	ip="`echo $HOSTNAMEIPV4 | sed -n -e "s/^.*${host},//gp" | awk -F, "{ print ${pos} }" | awk '{ print $1 }'`"
	if [ -z $ip ]
	then
		echo "Host '$host' unknown"
		exit 1
	fi
fi

shift
exec ssh $SSHCONF -q root@$ip $@