]> git.pld-linux.org Git - packages/openssh.git/blame - opensshd.init
- patch5 shouldn't be applied by default
[packages/openssh.git] / opensshd.init
CommitLineData
cf3b46d6
AF
1#!/bin/sh
2#
3# sshd sshd (secure shell daemon)
4#
5# chkconfig: 345 55 45
6#
7# description: sshd (secure shell daemon) is a server part of the ssh suite.
8# Ssh can be used for remote login, remote file copying, TCP port
9# forwarding etc. Ssh offers strong encryption and authentication.
10
11
12# Source function library
13. /etc/rc.d/init.d/functions
14
15# Get network config
16. /etc/sysconfig/network
17
18# Get service config
19[ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd
20
21# Check that networking is up.
7d58fbb0 22if is_yes "${NETWORKING}"; then
23 if [ ! -f /var/lock/subsys/network ]; then
24 msg_network_down OpenSSH
25 exit 1
26 fi
27else
28 exit 0
cf3b46d6 29fi
cbd44157 30
bff0c7f8 31RETVAL=0
cf3b46d6
AF
32# See how we were called.
33case "$1" in
34 start)
3c573fc0 35 # generate new keys with empty passwords if they do not exist
36 if [ ! -f /etc/ssh/ssh_host_key -o ! -s /etc/ssh/ssh_host_key ]; then
7d58fbb0 37 /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N '' 1>&2
38 chmod 600 /etc/ssh/ssh_host_key
3c573fc0 39 fi
40 if [ ! -f /etc/ssh/ssh_host_rsa_key -o ! -s /etc/ssh/ssh_host_rsa_key ]; then
7d58fbb0 41 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' 1>&2
42 chmod 600 /etc/ssh/ssh_host_rsa_key
3c573fc0 43 fi
44 if [ ! -f /etc/ssh/ssh_host_dsa_key -o ! -s /etc/ssh/ssh_host_dsa_key ]; then
7d58fbb0 45 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' 1>&2
46 chmod 600 /etc/ssh/ssh_host_dsa_key
3c573fc0 47 fi
48
01d1f289 49 if [ ! -f /etc/ssh/ssh_host_key ]; then
9ceb608e 50 msg_not_running OpenSSH
7d58fbb0 51 nls "No SSH host key found! You must run \"%s init\" first." "$0"
01d1f289 52 exit 1
53 fi
3c573fc0 54
55 # Check if the service is already running?
cf3b46d6 56 if [ ! -f /var/lock/subsys/sshd ]; then
cbd44157 57 msg_starting OpenSSH
0b7ed40c 58 ULIMIT_C="-S -c 0"
2a63b97e 59 daemon /usr/sbin/sshd
cbd44157 60 RETVAL=$?
61 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sshd
cf3b46d6 62 else
9ceb608e 63 msg_already_running OpenSSH
cf3b46d6 64 fi
cf3b46d6
AF
65 ;;
66 stop)
7d58fbb0 67 if [ -f /var/lock/subsys/sshd ]; then
cbd44157 68 msg_stopping OpenSSH
69 killproc sshd
70 rm -f /var/run/sshd.pid /var/lock/subsys/sshd >/dev/null 2>&1
71 else
9ceb608e 72 msg_not_running OpenSSH
cbd44157 73 fi
cf3b46d6 74 ;;
cbd44157 75 restart)
cf3b46d6
AF
76 $0 stop
77 $0 start
bff0c7f8 78 exit $?
cf3b46d6
AF
79 ;;
80 status)
81 status sshd
cbd44157 82 exit $?
cf3b46d6 83 ;;
01d1f289 84 init)
0d883194 85 nls "Now the SSH host key will be generated. Please note, that if you"
86 nls "will use password for the key, you will need to type it on each"
87 nls "reboot."
ff7a4dcc 88 /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key
cf14c2df 89 chmod 600 /etc/ssh/ssh_host_key
ff7a4dcc
AM
90 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
91 chmod 600 /etc/ssh/ssh_host_rsa_key
7d58fbb0 92 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
cf14c2df 93 chmod 600 /etc/ssh/ssh_host_dsa_key
01d1f289 94 exit $?
36f63877 95 ;;
bff0c7f8 96 reload|force-reload)
0d883194 97 if [ -f /var/lock/subsys/sshd ]; then
98 msg_reloading OpenSSH
0d883194 99 killproc sshd -HUP
100 RETVAL=$?
0d883194 101 else
bff0c7f8 102 msg_not_running OpenSSH >&2
103 exit 7
0d883194 104 fi
36f63877 105 ;;
cf3b46d6 106 *)
bff0c7f8 107 msg_usage "$0 {start|stop|init|restart|reload|force-reload|status}"
108 exit 3
cf3b46d6
AF
109esac
110
cbd44157 111exit $RETVAL
This page took 0.057033 seconds and 4 git commands to generate.