Script to deploy ssh authorized_keys across our network.
authorSomeone <someone@somenet.org>
Thu, 19 Nov 2015 22:18:46 +0000 (23:18 +0100)
committerSomeone <someone@somenet.org>
Thu, 19 Nov 2015 22:18:46 +0000 (23:18 +0100)
ssh_redeploy_authorized_keys.sh [new file with mode: 0755]

diff --git a/ssh_redeploy_authorized_keys.sh b/ssh_redeploy_authorized_keys.sh
new file mode 100755 (executable)
index 0000000..10081ea
--- /dev/null
@@ -0,0 +1,72 @@
+#!/bin/bash
+#
+# Copyright 2015-2016 by Jan Vales <jan@jvales.net> (Someone <someone@somenet.org>)
+# send me your changes. credit author(s). do not publish. share alike.
+# to be done: find a suitable licence text.
+#
+# Script to deploy authorized keys on all out CTF machines.
+#
+
+echo "merge keys"
+cat /root/.ssh/authorized_keys > /root/authorized_keys.adm.tmp
+cat /root/.ssh/authorized_keys > /root/authorized_keys.all.tmp
+
+
+mkdir -p /media/sf_vmshare/_orga/read_only_info
+touch /media/sf_vmshare/_orga/authorized_keys
+cat /media/sf_vmshare/_orga/authorized_keys >> /root/authorized_keys.all.tmp
+
+
+echo "distribute keys to localhost (gw.i)"
+mkdir -p /home/user/.ssh
+chmod 700 /home/user/.ssh
+cat /root/authorized_keys.adm.tmp > /home/user/.ssh/authorized_keys
+chmod 600 /home/user/.ssh/authorized_keys
+
+
+echo "distribute keys to spof (spof.i)"
+# put admkeys on root
+scp /root/authorized_keys.adm.tmp root@spof.i:/root/.ssh/authorized_keys
+ssh root@spof.i "mkdir -p /root/.ssh ; chmod 700 /root/.ssh ; chmod 600 /root/.ssh/authorized_keys"
+
+echo "distribute keys to apof (apof.i)"
+# put admkeys on root
+scp /root/authorized_keys.adm.tmp root@apof.i:/root/.ssh/authorized_keys
+ssh root@apof.i "mkdir -p /root/.ssh ; chmod 700 /root/.ssh ; chmod 600 /root/.ssh/authorized_keys"
+
+
+echo "distribute keys to vmSVC (service.i)"
+# put adminkeys on root
+scp -P22 /root/authorized_keys.adm.tmp root@s.i:/root/.ssh/authorized_keys
+ssh -p22 root@s.i "mkdir -p /root/.ssh ; chmod 700 /root/.ssh ; chmod 600 /root/.ssh/authorized_keys"
+
+# put all keys on user
+#scp -P22 /root/authorized_keys.all.tmp root@s.i:/home/user/.ssh/authorized_keys
+#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"
+
+scp -P22 /root/authorized_keys.all.tmp root@service.i:/home/ctf/.ssh/authorized_keys
+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"
+
+
+echo "distribute keys to vmVULN (v.i)"
+# put allkeys on root
+scp -P22 /root/authorized_keys.all.tmp root@v.i:/root/.ssh/authorized_keys
+ssh -p22 root@v.i "mkdir -p /root/.ssh ; chmod 700 /root/.ssh ; chmod 600 /root/.ssh/authorized_keys"
+
+# put allkeys on user
+scp -P22 /root/authorized_keys.all.tmp root@v.i:/opt/ctf/.ssh/authorized_keys
+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"
+
+echo "distribute keys to vmVULN2 (v2.i)"
+# put allkeys on root
+scp -P22 /root/authorized_keys.all.tmp root@v2.i:/root/.ssh/authorized_keys
+ssh -p22 root@v2.i "mkdir -p /root/.ssh ; chmod 700 /root/.ssh ; chmod 600 /root/.ssh/authorized_keys"
+
+# put allkeys on user
+scp -P22 /root/authorized_keys.all.tmp root@v2.i:/opt/ctf/.ssh/authorized_keys
+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"
+
+echo "cleanup"
+cat /root/authorized_keys.all.tmp > /media/sf_vmshare/_orga/read_only_info/authorized_keys
+rm /root/authorized_keys.adm.tmp /root/authorized_keys.all.tmp
+