]> git.somenet.org - ctf/pub/network.git/blob - ssh_redeploy_authorized_keys.sh
GITOLITE.txt
[ctf/pub/network.git] / ssh_redeploy_authorized_keys.sh
1 #!/bin/bash
2 #
3 # Copyright 2015-2016 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
4 # send me your changes. credit author(s). do not publish. share alike.
5 # to be done: find a suitable licence text.
6 #
7 # Script to deploy authorized keys on all out CTF machines.
8 #
9
10 echo "merge keys"
11 cat /root/.ssh/authorized_keys > /root/authorized_keys.adm.tmp
12 cat /root/.ssh/authorized_keys > /root/authorized_keys.all.tmp
13
14
15 mkdir -p /media/sf_vmshare/_orga/read_only_info
16 touch /media/sf_vmshare/_orga/authorized_keys
17 cat /media/sf_vmshare/_orga/authorized_keys >> /root/authorized_keys.all.tmp
18
19
20 echo "distribute keys to localhost (gw.i)"
21 mkdir -p /home/user/.ssh
22 chmod 700 /home/user/.ssh
23 cat /root/authorized_keys.adm.tmp > /home/user/.ssh/authorized_keys
24 chmod 600 /home/user/.ssh/authorized_keys
25
26
27 echo "distribute keys to spof (spof.i)"
28 # put admkeys on root
29 scp /root/authorized_keys.adm.tmp root@spof.i:/root/.ssh/authorized_keys
30 ssh root@spof.i "mkdir -p /root/.ssh ; chmod 700 /root/.ssh ; chmod 600 /root/.ssh/authorized_keys"
31
32 echo "distribute keys to apof (apof.i)"
33 # put admkeys on root
34 scp /root/authorized_keys.adm.tmp root@apof.i:/root/.ssh/authorized_keys
35 ssh root@apof.i "mkdir -p /root/.ssh ; chmod 700 /root/.ssh ; chmod 600 /root/.ssh/authorized_keys"
36
37
38 echo "distribute keys to vmSVC (service.i)"
39 # put adminkeys on root
40 scp -P22 /root/authorized_keys.adm.tmp root@s.i:/root/.ssh/authorized_keys
41 ssh -p22 root@s.i "mkdir -p /root/.ssh ; chmod 700 /root/.ssh ; chmod 600 /root/.ssh/authorized_keys"
42
43 # put all keys on user
44 #scp -P22 /root/authorized_keys.all.tmp root@s.i:/home/user/.ssh/authorized_keys
45 #ssh -p22 root@s.i "mkdir -p /home/user/.ssh ; chmod 700 /home/user/.ssh ; chmod 600 /home/user/.ssh/authorized_keys ; chown -R user:user /home/user/.ssh"
46
47 scp -P22 /root/authorized_keys.all.tmp root@service.i:/home/ctf/.ssh/authorized_keys
48 ssh -p22 root@s.i "mkdir -p /home/ctf/.ssh ; chmod 700 /home/ctf/.ssh ; chmod 600 /home/ctf/.ssh/authorized_keys ; chown -R ctf:ctf /home/ctf/.ssh"
49
50
51 echo "distribute keys to vmVULN (v.i)"
52 # put allkeys on root
53 scp -P22 /root/authorized_keys.all.tmp root@v.i:/root/.ssh/authorized_keys
54 ssh -p22 root@v.i "mkdir -p /root/.ssh ; chmod 700 /root/.ssh ; chmod 600 /root/.ssh/authorized_keys"
55
56 # put allkeys on user
57 scp -P22 /root/authorized_keys.all.tmp root@v.i:/opt/ctf/.ssh/authorized_keys
58 ssh -p22 root@v.i "mkdir -p /opt/ctf/.ssh ; chmod 700 /opt/ctf/.ssh ; chmod 600 /opt/ctf/.ssh/authorized_keys ; chown -R ctf:ctf /opt/ctf/.ssh"
59
60 echo "distribute keys to vmVULN2 (v2.i)"
61 # put allkeys on root
62 scp -P22 /root/authorized_keys.all.tmp root@v2.i:/root/.ssh/authorized_keys
63 ssh -p22 root@v2.i "mkdir -p /root/.ssh ; chmod 700 /root/.ssh ; chmod 600 /root/.ssh/authorized_keys"
64
65 # put allkeys on user
66 scp -P22 /root/authorized_keys.all.tmp root@v2.i:/opt/ctf/.ssh/authorized_keys
67 ssh -p22 root@v2.i "mkdir -p /opt/ctf/.ssh ; chmod 700 /opt/ctf/.ssh ; chmod 600 /opt/ctf/.ssh/authorized_keys ; chown -R ctf:ctf /opt/ctf/.ssh"
68
69 echo "cleanup"
70 cat /root/authorized_keys.all.tmp > /media/sf_vmshare/_orga/read_only_info/authorized_keys
71 rm /root/authorized_keys.adm.tmp /root/authorized_keys.all.tmp
72