]> git.pld-linux.org Git - packages/openssh.git/blob - opensshd.init
- removed man section from .so redirections
[packages/openssh.git] / opensshd.init
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.
22 if is_no "${NETWORKING}"; then
23         msg_network_down OpenSSH
24         exit 1
25 fi
26                         
27
28 # See how we were called.
29 case "$1" in
30   start)
31         # generate new keys with empty passwords if they do not exist
32         if [ ! -f /etc/ssh/ssh_host_key -o ! -s /etc/ssh/ssh_host_key ]; then
33             /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N '' 1>&2
34             chmod 600 /etc/ssh/ssh_host_key
35         fi
36         if [ ! -f /etc/ssh/ssh_host_rsa_key -o ! -s /etc/ssh/ssh_host_rsa_key ]; then
37             /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' 1>&2
38             chmod 600 /etc/ssh/ssh_host_rsa_key
39         fi
40         if [ ! -f /etc/ssh/ssh_host_dsa_key -o ! -s /etc/ssh/ssh_host_dsa_key ]; then
41             /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' 1>&2
42             chmod 600 /etc/ssh/ssh_host_dsa_key
43         fi
44
45         if [ ! -f /etc/ssh/ssh_host_key ]; then
46                 msg_not_running OpenSSH
47                 nls "No SSH host key found! You must run \"$0 init\" first."
48                 exit 1
49         fi
50
51         # Check if the service is already running?
52         if [ ! -f /var/lock/subsys/sshd ]; then
53                 msg_starting OpenSSH
54                 daemon /usr/sbin/sshd 
55                 RETVAL=$?
56                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sshd                
57         else
58                 msg_already_running OpenSSH
59         fi
60         ;;
61   stop)
62         if [ -f /var/lock/subsys/sshd ]; then
63                 msg_stopping OpenSSH
64                 killproc sshd
65                 rm -f /var/run/sshd.pid /var/lock/subsys/sshd >/dev/null 2>&1
66         else
67                 msg_not_running OpenSSH
68                 exit 1
69         fi      
70         ;;
71   restart)
72         $0 stop
73         $0 start
74         ;;
75   status)
76         status sshd
77         exit $?
78         ;;
79   init)
80         echo "Now the SSH host key will be generated. Please note, that if you"
81         echo "will use password for the key, you will need to type it on each"
82         echo "reboot."
83         /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key
84         chmod 600 /etc/ssh/ssh_host_key
85         /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
86         chmod 600 /etc/ssh/ssh_host_rsa_key
87         /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
88         chmod 600 /etc/ssh/ssh_host_dsa_key
89         exit $?
90         ;;
91   reload)
92         msg_reloading OpenSSH
93         killproc sshd -HUP
94         ;;
95   *)
96         msg_usage "$0 {start|stop|init|status|restart|reload}"
97         exit 1
98 esac
99
100 exit $RETVAL
This page took 0.108599 seconds and 3 git commands to generate.