-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathgen-ssh-config.sh
executable file
·52 lines (40 loc) · 1.06 KB
/
gen-ssh-config.sh
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
#!/usr/bin/env bash
user=$1
if [ -z "$user" ] ; then
echo "Missing username"
echo "Usage: $(basename $0) username"
exit 1
fi
# Setup cleanup
tempfile=/tmp/tum.html
trap "rm -f $tempfile" EXIT
# Print the common part of the configuration
cat >&1 <<EOF
# File generated automatically by $(basename $0)
####################################################
#### TUM servers
####################################################
Host tunnel
HostName login.dos.cit.tum.de
User tunnel
# default rule
Host *.dos.cit.tum.de
HostName %h
User $user
ForwardAgent yes
ProxyJump tunnel
EOF
# Download list of machines
curl -s https://github.com/TUM-DSE/doctor-cluster-config/tree/master/docs/hosts > "$tempfile"
machines=$(egrep '^.+<spa.+\.md' "$tempfile" | cut -d'>' -f3 | cut -d'<' -f1 | cut -d'.' -f1)
# Generate entry for each machine
while read m; do
if [ "$m" == "README" ] ; then continue; fi
cat >&1<<EOF
Host $m
HostName $m.dos.cit.tum.de
User $user
ForwardAgent yes
ProxyJump tunnel
EOF
done <<<"$machines"