]> Frank Brehm's Git Trees - pixelpark/create-terraform.git/commitdiff
Implementing regeneration of RSA host keys
authorFrank Brehm <frank.brehm@pixelpark.com>
Wed, 7 Feb 2024 10:20:29 +0000 (11:20 +0100)
committerFrank Brehm <frank.brehm@pixelpark.com>
Wed, 7 Feb 2024 10:20:29 +0000 (11:20 +0100)
postinstall-scripts/conf-resolver
postinstall-scripts/functions.rc

index a2a4c4c97c20ed78442c84ad1c2409e3fc1d37c7..ab5efd052cc8e0a38df9b1ed059ed20d31fdfd64 100755 (executable)
@@ -27,8 +27,8 @@ declare -a SEARCH_DOMAINS=()
 
 declare -a DEFAULT_NAME_SERVERS=(
     '217.66.52.10'
-    '93.188.109.13'
-    '212.91.225.75'
+    '93.188.109.12'
+    '93.188.104.82'
 )
 declare -a NAME_SERVERS=()
 
@@ -190,6 +190,32 @@ get_options() {
 
 }
 
+#------------------------------------------------------------------------------
+regenerate_rha_hostkey() {
+
+    local ssh_dir=/etc/ssh
+
+    empty_line
+    if [[ ! -d "${ssh_dir}" ]] ; then
+        error "Directory '${RED}${ssh_dir}${NORMAL}' not found!"
+        return
+    fi
+
+    info "Removing old SSH RSA host key ..."
+    rm -vf "${ssh_dir}/ssh_host_rsa_key"*
+
+    info "Generate new SSH RSA host keys with ${CYAN}4096${NORMAL} bits ..."
+    ssh-keygen -q -N "" -t rsa -b 4096 -f "${ssh_dir}/ssh_host_rsa_key"
+    if [[ -f "${ssh_dir}/ssh_host_rsa_key" ]] ; then
+        chgrp --verbose ssh_keys "${ssh_dir}/ssh_host_rsa_key"
+    else
+        error "The SSH RSA host key ${RED}${ssh_dir}/ssh_host_rsa_key was not generated${NORMAL}."
+    fi
+
+    ls -l "${ssh_dir}/ssh_host_"*
+
+}
+
 #------------------------------------------------------------------------------
 do_backup() {
 
@@ -380,8 +406,7 @@ main() {
 
     check_for_root
 
-    empty_line
-    empty_line
+    regenerate_rha_hostkey
 
     do_backup
     generate
index a5bd57286d40dd0449bf9bdc76ca819bbbf49a6c..24745e1e9d61cfcc29ff5813633b4056588dc519 100644 (file)
@@ -8,7 +8,7 @@ BLUE=""
 CYAN=""
 NORMAL=""
 
-VERSION="1.7.2"
+VERSION="1.7.3"
 
 # shellcheck disable=SC2034
 STD_SHORT_OPTIONS="sqdvhV"