Files
linux-scripts/debian/debian-regenerate-ssh-keys-machine-id.sh
2023-08-26 16:14:53 -05:00

33 lines
1.1 KiB
Bash

#!/bin/bash
# ask to regenerate machine-id
if [[ ! -f /etc/machine-id-regenerated ]]
then
read -r -p "Regenerate machine-id? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]
then
rm -f /etc/machine-id /var/lib/dbus/machine-id
dbus-uuidgen --ensure=/etc/machine-id
dbus-uuidgen --ensure
touch /etc/machine-id-regenerated
fi
fi
# ask to regenerate ssh host keys
if [[ ! -d /etc/cloud ]]
then
if [[ ! -f /home/akanealw/.ssh/ssh_keys_regenerated ]]
then
read -r -p "Regenerate SSH Keys? <y/N> " prompt
if [[ "${prompt,,}" =~ ^(y|yes)$ ]]
then
rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
mkdir /home/akanealw/.ssh
touch /home/akanealw/.ssh/ssh_keys_regenerated
chmod 700 /home/akanealw/.ssh
chown -R akanealw:akanealw /home/akanealw/.ssh
fi
fi
fi