Generate ssh host keys

From radmind

Revision as of 15:12, 29 May 2007 by Mcneal (Talk | contribs)
Jump to: navigation, search

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:

  • ./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

SSH-KEYGEN=/usr/bin/ssh-keygen

[ ! -s /etc/ssh_host_key ]     && $SSH-KEYGEN -q -t rsa1 \
    -f /etc/ssh_host_key -N "" -C "" < /dev/null > /dev/null 2> /dev/null
[ ! -s /etc/ssh_host_rsa_key ] && $SSH-KEYGEN -q -t rsa  \
    -f /etc/ssh_host_rsa_key -N "" -C "" < /dev/null > /dev/null 2> /dev/null
[ ! -s /etc/ssh_host_dsa_key ] && $SSH-KEYGEN -q -t dsa  \
    -f /etc/ssh_host_dsa_key -N "" -C "" < /dev/null > /dev/null 2> /dev/null

exit 0
Personal tools