recreate ssh host keys
This commit is contained in:
parent
4eac84bf6d
commit
da434cd3d1
|
@ -4,6 +4,44 @@
|
||||||
# recreate ssh host keys
|
# recreate ssh host keys
|
||||||
#
|
#
|
||||||
|
|
||||||
while read line; do
|
sshdconfig="/etc/ssh/sshd_config"
|
||||||
echo $line
|
|
||||||
done < /etc/ssh/sshd_config
|
if [ $(whoami) != "root" ]; then
|
||||||
|
echo "you need to be root"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -r $sshdconfig ]; then
|
||||||
|
while read line; do
|
||||||
|
fletter=${line:0:1}
|
||||||
|
if [ -z $fletter ]; then
|
||||||
|
#empty line. skipping.
|
||||||
|
:
|
||||||
|
elif [ $fletter == "#" ]; then
|
||||||
|
#comment. skipping.
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo $line | grep "HostKey" >> /dev/null
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
file=$(echo $line | awk '{print $2}')
|
||||||
|
if [ $file != "${file/_dsa_/}" ]; then
|
||||||
|
mv $file $file.old
|
||||||
|
mv $file.pub $file.pub.old
|
||||||
|
ssh-keygen -t dsa -f $file
|
||||||
|
elif [ $file != "${file/_ecdsa_/}" ]; then
|
||||||
|
mv $file $file.old
|
||||||
|
mv $file.pub $file.pub.old
|
||||||
|
ssh-keygen -t ecdsa -f $file
|
||||||
|
elif [ $file != "${file/_rsa_/}" ]; then
|
||||||
|
mv $file $file.old
|
||||||
|
mv $file.pub $file.pub.old
|
||||||
|
ssh-keygen -t rsa -f $file
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < $sshdconfig
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "$sshdconfig - file not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in New Issue