]> git.pld-linux.org Git - packages/openssh.git/blame - opensshd.init
- rel 0.2
[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.
cbd44157 22if is_no "${NETWORKING}"; then
9ceb608e 23 msg_network_down OpenSSH
cbd44157 24 exit 1
cf3b46d6 25fi
cbd44157 26
cf3b46d6
AF
27
28# See how we were called.
29case "$1" in
30 start)
3c573fc0 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
01d1f289 45 if [ ! -f /etc/ssh/ssh_host_key ]; then
9ceb608e 46 msg_not_running OpenSSH
01d1f289 47 nls "No SSH host key found! You must run \"$0 init\" first."
48 exit 1
49 fi
3c573fc0 50
51 # Check if the service is already running?
cf3b46d6 52 if [ ! -f /var/lock/subsys/sshd ]; then
cbd44157 53 msg_starting OpenSSH
0b7ed40c 54 ULIMIT_C="-S -c 0"
2a63b97e 55 daemon /usr/sbin/sshd
cbd44157 56 RETVAL=$?
57 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sshd
cf3b46d6 58 else
9ceb608e 59 msg_already_running OpenSSH
cf3b46d6 60 fi
cf3b46d6
AF
61 ;;
62 stop)
cbd44157 63 if [ -f /var/lock/subsys/sshd ]; then
64 msg_stopping OpenSSH
65 killproc sshd
66 rm -f /var/run/sshd.pid /var/lock/subsys/sshd >/dev/null 2>&1
67 else
9ceb608e 68 msg_not_running OpenSSH
cbd44157 69 exit 1
70 fi
cf3b46d6 71 ;;
cbd44157 72 restart)
cf3b46d6
AF
73 $0 stop
74 $0 start
75 ;;
76 status)
77 status sshd
cbd44157 78 exit $?
cf3b46d6 79 ;;
01d1f289 80 init)
81 echo "Now the SSH host key will be generated. Please note, that if you"
82 echo "will use password for the key, you will need to type it on each"
83 echo "reboot."
ff7a4dcc 84 /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key
cf14c2df 85 chmod 600 /etc/ssh/ssh_host_key
ff7a4dcc
AM
86 /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
87 chmod 600 /etc/ssh/ssh_host_rsa_key
88 /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
cf14c2df 89 chmod 600 /etc/ssh/ssh_host_dsa_key
01d1f289 90 exit $?
36f63877 91 ;;
92 reload)
93 msg_reloading OpenSSH
94 killproc sshd -HUP
95 ;;
cf3b46d6 96 *)
9ceb608e 97 msg_usage "$0 {start|stop|init|status|restart|reload}"
cf3b46d6
AF
98 exit 1
99esac
100
cbd44157 101exit $RETVAL
This page took 0.057782 seconds and 4 git commands to generate.