#!/bin/sh # # sshd sshd (secure shell daemon) # # chkconfig: 345 55 45 # # description: sshd (secure shell daemon) is a server part of the ssh suite. # Ssh can be used for remote login, remote file copying, TCP port # forwarding etc. Ssh offers strong encryption and authentication. # Source function library . /etc/rc.d/init.d/functions # Get network config . /etc/sysconfig/network # Get service config [ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd # Check that networking is up. if is_no "${NETWORKING}"; then msg_Network_Down OpenSSH exit 1 fi # See how we were called. case "$1" in start) # Check if the service is already running? if [ ! -f /etc/ssh/ssh_host_key ]; then msg_Not_Running OpenSSH nls "No SSH host key found! You must run \"$0 init\" first." exit 1 fi if [ ! -f /var/lock/subsys/sshd ]; then msg_starting OpenSSH daemon /usr/sbin/sshd -h /etc/ssh/ssh_host_key RETVAL=$? [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sshd else msg_Already_Running OpenSSH fi ;; stop) if [ -f /var/lock/subsys/sshd ]; then msg_stopping OpenSSH killproc sshd rm -f /var/run/sshd.pid /var/lock/subsys/sshd >/dev/null 2>&1 else msg_Not_Running OpenSSH exit 1 fi ;; restart) $0 stop $0 start ;; status) status sshd exit $? ;; init) echo "Now the SSH host key will be generated. Please note, that if you" echo "will use password for the key, you will need to type it on each" echo "reboot." ssh-keygen -f /etc/ssh/ssh_host_key exit $? ;; *) msg_Usage "$0 {start|stop|status|restart}" exit 1 esac exit $RETVAL