#!/bin/sh
CONFDIR="/etc/ssh"
CONFIG="${CONFDIR}/sshd_config"
sshd_keygen()
{
echo "Starting SSH ..."
(
umask 022
if [ -f ${CONFDIR}/ssh_host_key ]; then
echo "You already have an RSA host key in ${CONFDIR}/ssh_host_key"
echo "Skipping protocol version 1 RSA Key Generation"
else
echo "Generating SSH version 1 RSA host key..."
/usr/bin/ssh-keygen -t rsa1 -f ${CONFDIR}/ssh_host_key -N '' 1>/dev/null 2>&1
fi
if [ -f ${CONFDIR}/ssh_host_dsa_key ]; then
echo "You already have a DSA host key in ${CONFDIR}/ssh_host_dsa_key"
echo "Skipping protocol version 2 DSA Key Generation"
else
echo "Generating SSH DSA host key..."
/usr/bin/ssh-keygen -t dsa -f ${CONFDIR}/ssh_host_dsa_key -N '' 1>/dev/null 2>&1
fi
if [ -f ${CONFDIR}/ssh_host_rsa_key ]; then
echo "You already have a RSA host key in ${CONFDIR}/ssh_host_rsa_key"
echo "Skipping protocol version 2 RSA Key Generation"
else
echo "Generating SSH version 2 RSA key ..."
/usr/bin/ssh-keygen -t rsa -f ${CONFDIR}/ssh_host_rsa_key -N '' 1>/dev/null 2>&1
fi
if [ -f ${CONFDIR}/ssh_host_ecdsa_key ]; then
echo "You already have an ECDSA host key in ${CONFDIR}/ssh_host_ecdsa_key"
echo "Skipping protocol version 2 ECDSA Key Generation"
else
/usr/bin/ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
fi
)
}
[ ! -x /usr/sbin/sshd ] && exit
if [ ! -f /etc/ssh/ssh_host_key -o \
! -f /etc/ssh/ssh_host_dsa_key -o \
! -f /etc/ssh/ssh_host_rsa_key ]; then
echo "Creating SSH Keys ..."
sshd_keygen
fi
/usr/sbin/sshd -f $CONFIG
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>