Generate ssh host keys

From radmind

(Difference between revisions)
Jump to: navigation, search
(Added more robust version of script.)
Line 1: Line 1:
-
This script will generate ssh host keys if they files are missing or empty.  To use this script, add the following files to a negative transcript:
+
This script will generate ssh host keys if they are missing or empty.  To use this script, add the following files to a negative transcript:
*./private/etc/ssh_host_dsa_key
*./private/etc/ssh_host_dsa_key

Revision as of 08:46, 30 May 2007

This script will generate ssh host keys if they are missing or empty. To use this script, add the following files to a negative transcript:

  • ./private/etc/ssh_host_dsa_key
  • ./private/etc/ssh_host_dsa_key.pub
  • ./private/etc/ssh_host_key
  • ./private/etc/ssh_host_key.pub
  • ./private/etc/ssh_host_rsa_key
  • ./private/etc/ssh_host_rsa_key.pub
#!/bin/sh

SSHKEYGEN=/usr/bin/ssh-keygen

if [ ! -s /etc/ssh_host_key -o ! -s /etc/ssh_host_key.pub ]; then
    if [ -f /etc/ssh_host_key ]; then
	rm /etc/ssh_host_key
    fi
    if [ -f /etc/ssh_host_key.pub ]; then
	rm /etc/ssh_host_key.pub
    fi
    $SSHKEYGEN -q -t rsa1 -f /etc/ssh_host_key -N "" \
        -C "" < /dev/null > /dev/null 2> /dev/null
    echo "Created /etc/ssh_host_key"
fi

if [ ! -s /etc/ssh_host_rsa_key -o ! -s /etc/ssh_host_rsa_key.pub ]; then
    if [ -f /etc/ssh_host_rsa_key ]; then
	rm /etc/ssh_host_rsa_key
    fi
    if [ -f /etc/ssh_host_rsa_key.pub ]; then
	rm /etc/ssh_host_rsa_key.pub
    fi
    $SSHKEYGEN -q -t rsa  -f /etc/ssh_host_rsa_key -N "" \
        -C "" < /dev/null > /dev/null 2> /dev/null
    echo "Created /etc/ssh_host_rsa_key"
fi

if [ ! -s /etc/ssh_host_dsa_key -o ! -s /etc/ssh_host_dsa_key.pub ]; then
    if [ -f /etc/ssh_host_dsa_key ]; then
	rm /etc/ssh_host_dsa_key
    fi
    if [ -f /etc/ssh_host_dsa_key.pub ]; then
	rm /etc/ssh_host_dsa_key.pub
    fi
    $SSHKEYGEN -q -t dsa -f /etc/ssh_host_dsa_key -N "" \
        -C "" < /dev/null > /dev/null 2> /dev/null
    echo "Created /etc/ssh_host_dsa_key"
fi

exit 0
Personal tools