Initial Commit
This commit is contained in:
commit
45f32fa0af
3 changed files with 718 additions and 0 deletions
36
ssh_host_key_gen.sh
Normal file
36
ssh_host_key_gen.sh
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# This script regenerates the SSH host keys on a newly,
|
||||
# template created, VM
|
||||
#
|
||||
# Add the full path of the script in /etc/rc.local, just
|
||||
# above 'exit 0'
|
||||
|
||||
if which systemctl
|
||||
then
|
||||
systemctl stop ssh
|
||||
else
|
||||
service ssh stop
|
||||
fi
|
||||
|
||||
if ls /etc/ssh/ssh_host_* &> /dev/null
|
||||
then
|
||||
rm -f /etc/ssh/ssh_host_*
|
||||
fi
|
||||
|
||||
ls /etc/ssh/ssh_host_* &> /dev/null
|
||||
|
||||
if [ "$?" -ne 0 ]
|
||||
then
|
||||
ssh-keygen -A
|
||||
fi
|
||||
|
||||
if which systemctl
|
||||
then
|
||||
systemctl start ssh
|
||||
else
|
||||
service ssh start
|
||||
fi
|
||||
|
||||
sed -i "/$0/d" /etc/rc.local
|
||||
rm -f $0
|
||||
Loading…
Add table
Add a link
Reference in a new issue