version 1.1, 2014/01/23 09:34:55
|
version 1.2, 2014/09/15 19:06:52
|
Line 0
|
Line 1
|
|
#!/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 |
|
|
|
if [ -f ${CONFDIR}/ssh_host_ed25519_key ]; then |
|
echo "You already have an ed25519 host key in ${CONFDIR}/ssh_host_ed25519_key" |
|
echo "Skipping protocol version 2 ed25519 Key Generation" |
|
else |
|
/usr/bin/ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_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 |