3 # sshd sshd (secure shell daemon)
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.
11 # Source function library
12 . /etc/rc.d/init.d/functions
15 . /etc/sysconfig/network
18 PIDFILE=/var/run/sshd.pid
21 [ -f /etc/sysconfig/sshd ] && . /etc/sysconfig/sshd
23 # Check that networking is up.
24 if is_yes "${NETWORKING}"; then
25 if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then
26 msg_network_down "OpenSSH"
34 if [ -e $PIDFILE ]; then
35 for pid in $(cat $PIDFILE); do
36 echo "$SSHD_OOM_ADJUST" 2>/dev/null > /proc/$pid/oom_score_adj
43 /usr/sbin/sshd -t || exit 1
47 @@LIBEXECDIR@@/sshd-keygen
51 # Check if the service is already running?
52 if status --pidfile $PIDFILE sshd >/dev/null; then
53 msg_already_running "OpenSSH"
59 if [ "$(echo /etc/ssh/ssh_host*key)" = "/etc/ssh/ssh_host*key" ]; then
60 msg_not_running "OpenSSH"
61 nls "No SSH host key found! You must run \"%s init\" first." "$0"
65 if is_yes "$IPV4_NETWORKING" && is_no "$IPV6_NETWORKING"; then
68 if is_yes "$IPV6_NETWORKING" && is_no "$IPV4_NETWORKING"; then
72 msg_starting "OpenSSH"
73 daemon --pidfile $PIDFILE /usr/sbin/sshd $OPTIONS
76 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/sshd
80 if [ ! -f /var/lock/subsys/sshd ]; then
81 msg_not_running "OpenSSH"
85 msg_stopping "OpenSSH"
86 # we use start-stop-daemon to stop sshd, as it is unacceptable for such
87 # critical service as sshd to kill it by procname, but unfortunately
88 # rc-scripts does not provide way to kill *only* by pidfile
89 start-stop-daemon --stop --quiet --pidfile $PIDFILE && ok || fail
90 rm -f /var/lock/subsys/sshd >/dev/null 2>&1
94 if [ ! -f /var/lock/subsys/sshd ]; then
95 msg_not_running "OpenSSH"
101 msg_reloading "OpenSSH"
107 if [ ! -f /var/lock/subsys/sshd ]; then
108 msg_not_running "OpenSSH"
119 # See how we were called.
142 nls "Now the SSH host key will be generated. Please note, that if you"
143 nls "will use password for the key, you will need to type it on each"
148 status --pidfile $PIDFILE sshd
152 msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|configtest|init|status}"