|
123456789101112131415161718192021222324252627282930313233343536 |
- #!/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
|