2000-08-01 00:39:41 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2002-03-27 12:15:54 +03:00
|
|
|
# $NetBSD: sshd,v 1.14 2002/03/27 09:15:54 lukem Exp $
|
2000-08-01 18:28:32 +04:00
|
|
|
#
|
2000-08-01 00:39:41 +04:00
|
|
|
|
2000-08-10 05:41:09 +04:00
|
|
|
# PROVIDE: sshd
|
|
|
|
# REQUIRE: LOGIN
|
2000-08-01 00:39:41 +04:00
|
|
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
|
|
|
name="sshd"
|
2000-09-19 17:04:38 +04:00
|
|
|
rcvar=$name
|
2000-08-10 05:41:09 +04:00
|
|
|
command="/usr/sbin/${name}"
|
2002-03-27 12:15:54 +03:00
|
|
|
command_args='-f ${sshd_conf_dir}/${name}.conf'
|
2000-08-11 02:49:43 +04:00
|
|
|
pidfile="/var/run/${name}.pid"
|
2002-02-24 15:50:08 +03:00
|
|
|
load_rc_config $name
|
|
|
|
required_files="${sshd_conf_dir}/${name}.conf"
|
2000-08-11 02:49:43 +04:00
|
|
|
extra_commands="keygen reload"
|
2000-08-01 00:39:41 +04:00
|
|
|
|
2000-08-10 05:41:09 +04:00
|
|
|
sshd_keygen()
|
|
|
|
{
|
2001-04-26 03:27:37 +04:00
|
|
|
(
|
2001-04-26 03:18:50 +04:00
|
|
|
umask 022
|
2002-02-24 15:50:08 +03:00
|
|
|
if [ -f ${sshd_conf_dir}/ssh_host_key ]; then
|
|
|
|
echo "You already have an RSA host key in ${sshd_conf_dir}/ssh_host_key"
|
2001-03-27 02:21:26 +04:00
|
|
|
echo "Skipping protocol version 1 RSA Key Generation"
|
2000-08-01 00:39:41 +04:00
|
|
|
else
|
2002-02-24 15:50:08 +03:00
|
|
|
/usr/bin/ssh-keygen -t rsa1 -b 1024 -f ${sshd_conf_dir}/ssh_host_key -N ''
|
2000-08-01 00:39:41 +04:00
|
|
|
fi
|
|
|
|
|
2002-02-24 15:50:08 +03:00
|
|
|
if [ -f ${sshd_conf_dir}/ssh_host_dsa_key ]; then
|
|
|
|
echo "You already have a DSA host key in ${sshd_conf_dir}/ssh_host_dsa_key"
|
2001-03-27 02:21:26 +04:00
|
|
|
echo "Skipping protocol version 2 DSA Key Generation"
|
2000-08-01 00:39:41 +04:00
|
|
|
else
|
2002-02-24 15:50:08 +03:00
|
|
|
/usr/bin/ssh-keygen -t dsa -f ${sshd_conf_dir}/ssh_host_dsa_key -N ''
|
2001-03-27 02:21:26 +04:00
|
|
|
fi
|
|
|
|
|
2002-02-24 15:50:08 +03:00
|
|
|
if [ -f ${sshd_conf_dir}/ssh_host_rsa_key ]; then
|
|
|
|
echo "You already have a RSA host key in ${sshd_conf_dir}/ssh_host_rsa_key"
|
2001-03-27 02:21:26 +04:00
|
|
|
echo "Skipping protocol version 2 RSA Key Generation"
|
|
|
|
else
|
2002-02-24 15:50:08 +03:00
|
|
|
/usr/bin/ssh-keygen -t rsa -f ${sshd_conf_dir}/ssh_host_rsa_key -N ''
|
2000-08-01 00:39:41 +04:00
|
|
|
fi
|
2001-04-26 03:27:37 +04:00
|
|
|
)
|
2000-08-01 00:39:41 +04:00
|
|
|
}
|
|
|
|
|
2000-08-10 05:41:09 +04:00
|
|
|
sshd_precmd()
|
|
|
|
{
|
2002-02-24 15:50:08 +03:00
|
|
|
if [ ! -f ${sshd_conf_dir}/ssh_host_key -o ! -f ${sshd_conf_dir}/ssh_host_dsa_key -o \
|
|
|
|
! -f ${sshd_conf_dir}/ssh_host_rsa_key ]; then
|
|
|
|
$0 keygen
|
2000-08-01 00:39:41 +04:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
keygen_cmd=sshd_keygen
|
2000-08-01 18:28:32 +04:00
|
|
|
start_precmd=sshd_precmd
|
2000-08-01 00:39:41 +04:00
|
|
|
|
|
|
|
load_rc_config $name
|
|
|
|
run_rc_command "$1"
|