Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 78 lines (66 sloc) 1.866 kb
9c600e7 Bring RCNG in from 5.x and adjust config files and scripts accordingly.
Matthew Dillon authored
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 $
696a571 - Remove unused "network" and "network[123]" scripts.
Sascha Wildner authored
5 # $DragonFly: src/etc/rc.d/sshd,v 1.3 2005/11/19 21:47:32 swildner Exp $
9c600e7 Bring RCNG in from 5.x and adjust config files and scripts accordingly.
Matthew Dillon authored
6 #
7
8 # PROVIDE: sshd
9 # REQUIRE: LOGIN
10
11 . /etc/rc.subr
12
13 name="sshd"
14 rcvar=`set_rcvar`
15 keygen_cmd="sshd_keygen"
16 start_precmd="sshd_precmd"
17 pidfile="/var/run/${name}.pid"
18 extra_commands="keygen reload"
19
20 sshd_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
44d294a rc.d/sshd: Create /etc/ssh/ssh_host_ecdsa_key if it doesn't exist.
Peter Avalos authored
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
9c600e7 Bring RCNG in from 5.x and adjust config files and scripts accordingly.
Matthew Dillon authored
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
66 sshd_precmd()
67 {
68 if [ ! -f /etc/ssh/ssh_host_key -o \
69 ! -f /etc/ssh/ssh_host_dsa_key -o \
44d294a rc.d/sshd: Create /etc/ssh/ssh_host_ecdsa_key if it doesn't exist.
Peter Avalos authored
70 ! -f /etc/ssh/ssh_host_ecdsa_key -o \
9c600e7 Bring RCNG in from 5.x and adjust config files and scripts accordingly.
Matthew Dillon authored
71 ! -f /etc/ssh/ssh_host_rsa_key ]; then
72 run_rc_command keygen
73 fi
74 }
75
76 load_rc_config $name
77 run_rc_command "$1"
Something went wrong with that request. Please try again.