diff --git a/debian/settings/reset-sshd-keys.sh b/debian/settings/reset-sshd-keys.sh new file mode 100644 index 0000000..b1f14a7 --- /dev/null +++ b/debian/settings/reset-sshd-keys.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +#### Functions +check_root() { + if [ "$EUID" -ne 0 ]; then + echo "Must be root to run $0" + exit + fi +} + +choice() { + echo -ne "[y/n]" + while true + do + read -rN1 input + case $input in + [yY][eE][sS]|[yY]) + return 0 + + break + ;; + [nN][oO]|[nN]) + return 1 + ;; + esac + done +} + +#### Main + +check_root + +echo -ne "\nReset sshd server key ? " +if choice 2>/dev/null; then + echo -ne "\nDelete key ...\n" + rm /etc/ssh/ssh_host_* + echo -ne "\nGenerate key ...\n" + dpkg-reconfigure openssh-server + systemctl restart sshd + systemctl status sshd +fi +