From: Frank Brehm Date: Wed, 7 Feb 2024 10:20:29 +0000 (+0100) Subject: Implementing regeneration of RSA host keys X-Git-Tag: 1.8.7^2~2 X-Git-Url: https://git.uhu-banane.de/?a=commitdiff_plain;h=8449a9a2ab93295b0748248d7911d3e2de30fe60;p=pixelpark%2Fcreate-terraform.git Implementing regeneration of RSA host keys --- diff --git a/postinstall-scripts/conf-resolver b/postinstall-scripts/conf-resolver index a2a4c4c..ab5efd0 100755 --- a/postinstall-scripts/conf-resolver +++ b/postinstall-scripts/conf-resolver @@ -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 diff --git a/postinstall-scripts/functions.rc b/postinstall-scripts/functions.rc index a5bd572..24745e1 100644 --- a/postinstall-scripts/functions.rc +++ b/postinstall-scripts/functions.rc @@ -8,7 +8,7 @@ BLUE="" CYAN="" NORMAL="" -VERSION="1.7.2" +VERSION="1.7.3" # shellcheck disable=SC2034 STD_SHORT_OPTIONS="sqdvhV"