From ecbdc8b62e3662bc956748e279b98801ec77ade9 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 27 Mar 2018 16:39:22 +0200 Subject: [PATCH] Extending bin/postinst --- bin/postinst | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/bin/postinst b/bin/postinst index 4556497..9da6316 100644 --- a/bin/postinst +++ b/bin/postinst @@ -1,7 +1,60 @@ #!/bin/bash +HASH_LINE="###############################" + echo "Das ist das Post-Install-Script '$0'." +echo + +echo "Creating /root/.ssh ..." +mkdir /root/.ssh +chmod 0700 /root/.ssh + + +echo +echo "Some information:" +echo " \$hostname: $hostname" +echo " \$ip_address_ether0: $ip_address_ether0" +echo " \$system_name: $system_name" + +#----------------------------------------------------------- +echo +echo "Creating /root/.ssh/authorized_keys ..." >/dev/console + +echo "${HASH_LINE}" >> /root/.ssh/authorized_keys +echo "ssh-dss AAAAB3NzaC1kc3MAAACBAKDLJjA6G2vfqM55xaDspJetd/IUqWWExh3wyrroHY1+wUCF39Qj3kibUP5IfynjPWjVwrxB5JDEPnGdr1kiMO9mfXMiOVZMRcB26RLXfWjpuoXSR+aUKtzEiJv9s+0R3A4Xxj9Vzn5xcGVqU/X9o25Wjltvgp2QgR8OOPjj0PLfAAAAFQDtdQMaYrc70T6Tl+E9d2pAXjJfcwAAAIBVPIqPUg6jTRU6XJgudNtWlmWOD/GdU1nlaHsTm3rKDzQY9hAx+JMKg9ihimGCGdHxXNYQwEk8UnHe04GuKwEw7Lz3+w8x/o0VUBRAkjPAYt34nIO2r2RXEH8NZUBOHPjMng5aygavLlXYovtvlcA4TZsW0T5eqf/5zS3iWhwilAAAAIBrbamvXpY/cbsVDbkw6JmqFoVeOR0jro4a3+/+fDssUygSw+9fSSRAmoXxF1eXTtq28Wx5I5jBSEVYfwSh++3YT+y9cFsnClJ3OwA9JxIWy8JhmXbNdktn8msrIusjUbGjWhIIw7DLm1LMxLcWByR7f97z1MVdetAsGQB9sfxZzQ== softdist" >> /root/.ssh/authorized_keys +echo "${HASH_LINE}" >> /root/.ssh/authorized_keys +echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDZ3QNzqiDE6jUzmXnOzIM93mZBPZtSDbCgYQd8xwOz9ZROxqLcckr8qIvyLFDv/fedwQlLDTg90LGX/zHHAB0T+0DB2dMFOWeSloIMMp+0WwG9i6H0ty6NUVSktvG6h4jbgkhMhHGUEHhxgR2LgxTjq8fpcMOLJ4HLLGW9W3BQOVtoi8hiffKm5DB9Au0HgNvXP/UrCQkBtFzMyhRb7D7aFyDyU/7SuM6m17DIYNx1cg79AH3mjRTQXaOVBrOBJ4uaqy6srbGzWs5FSIMMbgOrcmZRw5GilrG5dBbT/OQSN+sHlECx216pyLrbSWcwG1Fo11iI53pnColRUljMIPJ+XRffxT2yINEfyvfr0GGMKi4c5fcDumgYwT2+foefy72sBhNwKhzjuGySPgRU/1PH8oIcu4TJWyW1xi0AfVZnJhjU5RKeWQ9VMhh1nDntpRdD5z+0FrAL+9AINW4Bjboc6OisikIABBeoT9mbYNNGdHA7rpdJwURycJDpJDhyr0voNnmQ15JF6KZebM0+OW9apTxdotKPKYJ8pFBRGXrTENSVvFNIBbYD55IJ2MlOD2eX6XX2/tnHMdZHCE9Gi22Y8p1oiahLtCU3Th8WwazQlh4H9xAJzK0jp7MOpI3Y553i8zBU47VpO5juELH2bCNwChpdbZbY0i6MxQF61d2iJw== create-vmware-tpl@pixelpark.com" >> /root/.ssh/authorized_keys + +TMP_FILE=$( mktemp ) +wget -O "${TMP_FILE}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "http://192.168.88.8/custom/create-vmware-tpl/keys/auth_keys_pp_betrieb" || true +if [[ -s "${TMP_FILE}" ]] ; then + cat "${TMP_FILE}" >> /root/.ssh/authorized_keys +fi +rm "${TMP_FILE}" + + +#----------------------------------------------------------- +echo +echo "Importing SSH host keys ..." >/dev/console + +mkdir -pv /etc/ssh + +for stem in ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key ; do + for fullname in "${stem}" "${stem}.pub" ; do + TMP_FILE=$( mktemp ) + URL="http://192.168.88.8/custom/create-vmware-tpl/keys/${fullname}" + wget -O "${TMP_FILE}" --dns-timeout=2 --connect-timeout=3 --read-timeout=3 "${URL}" + if [[ -s "${TMP_FILE}" ]] ; then + mv -v "${TMP_FILE}" "/etc/ssh/${fullname}" + if [[ "${stem}" == "${fullname}" ]] ; then + chown -v root:ssh_keys "/etc/ssh/${fullname}" + chmod -v 0750 "/etc/ssh/${fullname}" + fi + fi + rm -f "${TMP_FILE}" + done +done # vim: ts=4 et -- 2.39.5