sshd (157655) | sshd (161530) |
---|---|
1#!/bin/sh 2# 3# $NetBSD: sshd,v 1.18 2002/04/29 08:23:34 lukem Exp $ | 1#!/bin/sh 2# 3# $NetBSD: sshd,v 1.18 2002/04/29 08:23:34 lukem Exp $ |
4# $FreeBSD: head/etc/rc.d/sshd 157655 2006-04-11 09:08:15Z flz $ | 4# $FreeBSD: head/etc/rc.d/sshd 161530 2006-08-22 11:17:29Z flz $ |
5# 6 7# PROVIDE: sshd 8# REQUIRE: LOGIN cleanvar 9 10. /etc/rc.subr 11 12name="sshd" 13rcvar=`set_rcvar` 14command="/usr/sbin/${name}" 15keygen_cmd="sshd_keygen" 16start_precmd="sshd_precmd" 17pidfile="/var/run/${name}.pid" 18extra_commands="keygen reload" 19 20timeout=300 21 | 5# 6 7# PROVIDE: sshd 8# REQUIRE: LOGIN cleanvar 9 10. /etc/rc.subr 11 12name="sshd" 13rcvar=`set_rcvar` 14command="/usr/sbin/${name}" 15keygen_cmd="sshd_keygen" 16start_precmd="sshd_precmd" 17pidfile="/var/run/${name}.pid" 18extra_commands="keygen reload" 19 20timeout=300 21 |
22load_rc_config $name 23 | |
24user_reseed() 25{ 26 ( 27 seeded=`sysctl -n kern.random.sys.seeded 2>/dev/null` 28 if [ "x${seeded}" != "x" ] && [ ${seeded} -eq 0 ] ; then 29 warn "Setting entropy source to blocking mode." 30 echo "====================================================" 31 echo "Type a full screenful of random junk to unblock" --- 12 unchanged lines hidden (view full) --- 44} 45 46sshd_keygen() 47{ 48 ( 49 umask 022 50 51 # Can't do anything if ssh is not installed | 22user_reseed() 23{ 24 ( 25 seeded=`sysctl -n kern.random.sys.seeded 2>/dev/null` 26 if [ "x${seeded}" != "x" ] && [ ${seeded} -eq 0 ] ; then 27 warn "Setting entropy source to blocking mode." 28 echo "====================================================" 29 echo "Type a full screenful of random junk to unblock" --- 12 unchanged lines hidden (view full) --- 42} 43 44sshd_keygen() 45{ 46 ( 47 umask 022 48 49 # Can't do anything if ssh is not installed |
52 [ -x ${prefix}/bin/ssh-keygen ] || { 53 warn "${prefix}/bin/ssh-keygen does not exist." | 50 [ -x /usr/bin/ssh-keygen ] || { 51 warn "/usr/bin/ssh-keygen does not exist." |
54 return 1 55 } 56 | 52 return 1 53 } 54 |
57 if [ -f ${etcdir}/ssh/ssh_host_key ]; then | 55 if [ -f /etc/ssh/ssh_host_key ]; then |
58 echo "You already have an RSA host key" \ | 56 echo "You already have an RSA host key" \ |
59 "in ${etcdir}/ssh/ssh_host_key" | 57 "in /etc/ssh/ssh_host_key" |
60 echo "Skipping protocol version 1 RSA Key Generation" 61 else | 58 echo "Skipping protocol version 1 RSA Key Generation" 59 else |
62 ${prefix}/bin/ssh-keygen -t rsa1 -b 1024 \ 63 -f ${etcdir}/ssh/ssh_host_key -N '' | 60 /usr/bin/ssh-keygen -t rsa1 -b 1024 \ 61 -f /etc/ssh/ssh_host_key -N '' |
64 fi 65 | 62 fi 63 |
66 if [ -f ${etcdir}/ssh/ssh_host_dsa_key ]; then | 64 if [ -f /etc/ssh/ssh_host_dsa_key ]; then |
67 echo "You already have a DSA host key" \ | 65 echo "You already have a DSA host key" \ |
68 "in ${etcdir}/ssh/ssh_host_dsa_key" | 66 "in /etc/ssh/ssh_host_dsa_key" |
69 echo "Skipping protocol version 2 DSA Key Generation" 70 else | 67 echo "Skipping protocol version 2 DSA Key Generation" 68 else |
71 ${prefix}/bin/ssh-keygen -t dsa -f ${etcdir}/ssh/ssh_host_dsa_key -N '' | 69 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' |
72 fi 73 | 70 fi 71 |
74 if [ -f ${etcdir}/ssh/ssh_host_rsa_key ]; then | 72 if [ -f /etc/ssh/ssh_host_rsa_key ]; then |
75 echo "You already have a RSA host key" \ | 73 echo "You already have a RSA host key" \ |
76 "in ${etcdir}/ssh/ssh_host_rsa_key" | 74 "in /etc/ssh/ssh_host_rsa_key" |
77 echo "Skipping protocol version 2 RSA Key Generation" 78 else | 75 echo "Skipping protocol version 2 RSA Key Generation" 76 else |
79 ${prefix}/bin/ssh-keygen -t rsa -f ${etcdir}/ssh/ssh_host_rsa_key -N '' | 77 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' |
80 fi 81 ) 82} 83 84sshd_precmd() 85{ | 78 fi 79 ) 80} 81 82sshd_precmd() 83{ |
86 if [ ! -f ${etcdir}/ssh/ssh_host_key -o \ 87 ! -f ${etcdir}/ssh/ssh_host_dsa_key -o \ 88 ! -f ${etcdir}/ssh/ssh_host_rsa_key ]; then | 84 if [ ! -f /etc/ssh/ssh_host_key -o \ 85 ! -f /etc/ssh/ssh_host_dsa_key -o \ 86 ! -f /etc/ssh/ssh_host_rsa_key ]; then |
89 user_reseed 90 run_rc_command keygen 91 fi 92} 93 | 87 user_reseed 88 run_rc_command keygen 89 fi 90} 91 |
92load_rc_config $name |
|
94run_rc_command "$1" | 93run_rc_command "$1" |