]> git.proxmox.com Git - dab.git/blob - scripts/ssh_gen_host_keys
ed32fe7b48f771177f501c1bf323f23a0bdc5549
[dab.git] / scripts / ssh_gen_host_keys
1 #!/bin/sh
2 ### BEGIN INIT INFO
3 # Provides: ssh_gen_host_keys
4 # Required-Start: $local_fs
5 # Required-Stop:
6 # X-Start-Before: sshd
7 # Default-Start: 2
8 # Default-Stop:
9 # Short-Description: Regenerate SSH keys
10 # Description: Regenerate container SSH keys for uniqueness.
11 ### END INIT INFO
12
13 set -e
14
15 HNAME=`head -n 1 /etc/hostname|awk '{ print $1; }'`
16
17 if [ "X${HNAME}" = "Xlocalhost" ] ; then
18 exit 0;
19 fi
20
21 echo "generating ssh host keys"
22
23 rm -f /etc/ssh/ssh_host_rsa_key
24 ssh-keygen -q -f /etc/ssh/ssh_host_rsa_key -t rsa -N ''
25
26 rm -f /etc/ssh/ssh_host_dsa_key
27 ssh-keygen -q -f /etc/ssh/ssh_host_dsa_key -t dsa -N ''
28
29 if [ -x /sbin/insserv ] ; then
30 /sbin/insserv -r ssh_gen_host_keys
31 rm -f /etc/init.d/ssh_gen_host_keys
32 else
33 rm -f /etc/init.d/ssh_gen_host_keys
34 update-rc.d -f ssh_gen_host_keys remove
35 fi