]>
Commit | Line | Data |
---|---|---|
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 | 22 | if is_no "${NETWORKING}"; then |
23 | msg_Network_Down OpenSSH | |
24 | exit 1 | |
cf3b46d6 | 25 | fi |
cbd44157 | 26 | |
cf3b46d6 AF |
27 | |
28 | # See how we were called. | |
29 | case "$1" in | |
30 | start) | |
31 | # Check if the service is already running? | |
01d1f289 | 32 | if [ ! -f /etc/ssh/ssh_host_key ]; then |
33 | msg_Not_Running OpenSSH | |
34 | nls "No SSH host key found! You must run \"$0 init\" first." | |
35 | exit 1 | |
36 | fi | |
cf3b46d6 | 37 | if [ ! -f /var/lock/subsys/sshd ]; then |
cbd44157 | 38 | msg_starting OpenSSH |
2a63b97e | 39 | daemon /usr/sbin/sshd |
cbd44157 | 40 | RETVAL=$? |
41 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sshd | |
cf3b46d6 | 42 | else |
cbd44157 | 43 | msg_Already_Running OpenSSH |
cf3b46d6 | 44 | fi |
cf3b46d6 AF |
45 | ;; |
46 | stop) | |
cbd44157 | 47 | if [ -f /var/lock/subsys/sshd ]; then |
48 | msg_stopping OpenSSH | |
49 | killproc sshd | |
50 | rm -f /var/run/sshd.pid /var/lock/subsys/sshd >/dev/null 2>&1 | |
51 | else | |
52 | msg_Not_Running OpenSSH | |
53 | exit 1 | |
54 | fi | |
cf3b46d6 | 55 | ;; |
cbd44157 | 56 | restart) |
cf3b46d6 AF |
57 | $0 stop |
58 | $0 start | |
59 | ;; | |
60 | status) | |
61 | status sshd | |
cbd44157 | 62 | exit $? |
cf3b46d6 | 63 | ;; |
01d1f289 | 64 | init) |
65 | echo "Now the SSH host key will be generated. Please note, that if you" | |
66 | echo "will use password for the key, you will need to type it on each" | |
67 | echo "reboot." | |
cf14c2df AM |
68 | /usr/bin/ssh-keygen -b 1024 -f /etc/ssh/ssh_host_key |
69 | chmod 600 /etc/ssh/ssh_host_key | |
70 | /usr/bin/ssh-keygen -d -f /etc/ssh/ssh_host_dsa_key | |
71 | chmod 600 /etc/ssh/ssh_host_dsa_key | |
01d1f289 | 72 | exit $? |
73 | ;; | |
cf3b46d6 | 74 | *) |
cbd44157 | 75 | msg_Usage "$0 {start|stop|status|restart}" |
cf3b46d6 AF |
76 | exit 1 |
77 | esac | |
78 | ||
cbd44157 | 79 | exit $RETVAL |