Support alternate config dir for sshd conf file and keys (defaults to "/etc").
Based on [misc/12473] from Jim Bernard.
This commit is contained in:
parent
73cdf7f537
commit
7d6824228d
@ -1,4 +1,4 @@
|
||||
# $NetBSD: rc.conf,v 1.29 2002/02/21 19:59:09 garbled Exp $
|
||||
# $NetBSD: rc.conf,v 1.30 2002/02/24 12:50:08 lukem Exp $
|
||||
#
|
||||
# /etc/defaults/rc.conf --
|
||||
# default configuration of /etc/rc.conf
|
||||
@ -148,6 +148,7 @@ sendmail=NO sendmail_flags="-bd -q30m"
|
||||
postfix=NO
|
||||
lpd=NO lpd_flags="-s" # -s "secure" unix domain only
|
||||
sshd=NO sshd_flags=""
|
||||
sshd_conf_dir="/etc" # directory for sshd conf files
|
||||
|
||||
# To run the named(8) DNS server as an unprivileged user under a
|
||||
# chroot(2) cage, uncomment the following after migrating the contents
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# $NetBSD: sshd,v 1.12 2001/04/25 23:27:37 lukem Exp $
|
||||
# $NetBSD: sshd,v 1.13 2002/02/24 12:50:09 lukem Exp $
|
||||
#
|
||||
|
||||
# PROVIDE: sshd
|
||||
@ -12,41 +12,42 @@ name="sshd"
|
||||
rcvar=$name
|
||||
command="/usr/sbin/${name}"
|
||||
pidfile="/var/run/${name}.pid"
|
||||
required_files="/etc/${name}.conf"
|
||||
load_rc_config $name
|
||||
required_files="${sshd_conf_dir}/${name}.conf"
|
||||
extra_commands="keygen reload"
|
||||
|
||||
sshd_keygen()
|
||||
{
|
||||
(
|
||||
umask 022
|
||||
if [ -f /etc/ssh_host_key ]; then
|
||||
echo "You already have an RSA host key in /etc/ssh_host_key"
|
||||
if [ -f ${sshd_conf_dir}/ssh_host_key ]; then
|
||||
echo "You already have an RSA host key in ${sshd_conf_dir}/ssh_host_key"
|
||||
echo "Skipping protocol version 1 RSA Key Generation"
|
||||
else
|
||||
/usr/bin/ssh-keygen -t rsa1 -b 1024 -f /etc/ssh_host_key -N ''
|
||||
/usr/bin/ssh-keygen -t rsa1 -b 1024 -f ${sshd_conf_dir}/ssh_host_key -N ''
|
||||
fi
|
||||
|
||||
if [ -f /etc/ssh_host_dsa_key ]; then
|
||||
echo "You already have a DSA host key in /etc/ssh_host_dsa_key"
|
||||
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"
|
||||
echo "Skipping protocol version 2 DSA Key Generation"
|
||||
else
|
||||
/usr/bin/ssh-keygen -t dsa -f /etc/ssh_host_dsa_key -N ''
|
||||
/usr/bin/ssh-keygen -t dsa -f ${sshd_conf_dir}/ssh_host_dsa_key -N ''
|
||||
fi
|
||||
|
||||
if [ -f /etc/ssh_host_rsa_key ]; then
|
||||
echo "You already have a RSA host key in /etc/ssh_host_rsa_key"
|
||||
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"
|
||||
echo "Skipping protocol version 2 RSA Key Generation"
|
||||
else
|
||||
/usr/bin/ssh-keygen -t rsa -f /etc/ssh_host_rsa_key -N ''
|
||||
/usr/bin/ssh-keygen -t rsa -f ${sshd_conf_dir}/ssh_host_rsa_key -N ''
|
||||
fi
|
||||
)
|
||||
}
|
||||
|
||||
sshd_precmd()
|
||||
{
|
||||
if [ ! -f /etc/ssh_host_key -o ! -f /etc/ssh_host_dsa_key -o \
|
||||
! -f /etc/ssh_host_rsa_key ]; then
|
||||
/etc/rc.d/sshd keygen
|
||||
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
|
||||
fi
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user