rc.d: rename vfs_accounting to vfs_quota
[dragonfly.git] / etc / rc.d / sshd
CommitLineData
9c600e7d
MD
1#!/bin/sh
2#
3# $NetBSD: sshd,v 1.18 2002/04/29 08:23:34 lukem Exp $
4# $FreeBSD: src/etc/rc.d/sshd,v 1.3 2003/07/13 01:49:07 mtm Exp $
696a5717 5# $DragonFly: src/etc/rc.d/sshd,v 1.3 2005/11/19 21:47:32 swildner Exp $
9c600e7d
MD
6#
7
8# PROVIDE: sshd
9# REQUIRE: LOGIN
9c600e7d
MD
10
11. /etc/rc.subr
12
13name="sshd"
14rcvar=`set_rcvar`
15keygen_cmd="sshd_keygen"
16start_precmd="sshd_precmd"
17pidfile="/var/run/${name}.pid"
18extra_commands="keygen reload"
9c600e7d
MD
19
20sshd_keygen()
21{
22 (
23 umask 022
24
25 # Can't do anything if ssh is not installed
26 [ -x /usr/bin/ssh-keygen ] || {
27 warn "/usr/bin/ssh-keygen does not exist."
28 return 1
29 }
30
31 if [ -f /etc/ssh/ssh_host_key ]; then
32 echo "You already have an RSA host key" \
33 "in /etc/ssh/ssh_host_key"
34 echo "Skipping protocol version 1 RSA Key Generation"
35 else
36 /usr/bin/ssh-keygen -t rsa1 -b 1024 \
37 -f /etc/ssh/ssh_host_key -N ''
38 fi
39
40 if [ -f /etc/ssh/ssh_host_dsa_key ]; then
41 echo "You already have a DSA host key" \
42 "in /etc/ssh/ssh_host_dsa_key"
43 echo "Skipping protocol version 2 DSA Key Generation"
44 else
45 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N ''
46 fi
47
44d294a0
PA
48 if [ -f /etc/ssh/ssh_host_ecdsa_key ]; then
49 echo "You already have a ECDSA host key" \
50 "in /etc/ssh/ssh_host_ecdsa_key"
51 echo "Skipping protocol version 2 ECDSA Key Generation"
52 else
53 /usr/bin/ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''
54 fi
55
9c600e7d
MD
56 if [ -f /etc/ssh/ssh_host_rsa_key ]; then
57 echo "You already have a RSA host key" \
58 "in /etc/ssh/ssh_host_rsa_key"
59 echo "Skipping protocol version 2 RSA Key Generation"
60 else
61 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N ''
62 fi
63 )
64}
65
66sshd_precmd()
67{
68 if [ ! -f /etc/ssh/ssh_host_key -o \
69 ! -f /etc/ssh/ssh_host_dsa_key -o \
44d294a0 70 ! -f /etc/ssh/ssh_host_ecdsa_key -o \
9c600e7d
MD
71 ! -f /etc/ssh/ssh_host_rsa_key ]; then
72 run_rc_command keygen
73 fi
74}
75
76load_rc_config $name
77run_rc_command "$1"