#!/bin/sh # /etc/rc.d/rc.sshd # # Start/stop/restart the secure shell server: # # colours by (or ;o) sshd_start() { # Create host keys if needed. if [ ! -r /etc/ssh/ssh_host_key ]; then /usr/bin/ssh-keygen -t rsa1 -f /etc/ssh/ssh_host_key -N '' fi if [ ! -f /etc/ssh/ssh_host_dsa_key ]; then /usr/bin/ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' fi if [ ! -f /etc/ssh/ssh_host_rsa_key ]; then /usr/bin/ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' fi /usr/sbin/sshd } sshd_stop() { killall sshd } sshd_restart() { if [ -r /var/run/sshd.pid ]; then echo echo " WARNING: killing listener process only!" echo echo " To kill every sshd process, you must use rc.sshd stop" echo " rc.sshd restart kills only the parent sshd to allow an" echo " admin logged in with ssh to use rc.sshd restart without" echo " being cut off! " echo echo " If sshd has been upgraded, new connections will now use" echo " the new version, a fairly safe approach." echo kill `cat /var/run/sshd.pid` else killall sshd fi sleep 1 sshd_start } case "$1" in 'start') echo "$1ing ssh daemon.." sshd_start ;; 'stop') echo "$1ing ssh daemon.." sshd_stop ;; 'restart') echo "$1ing ssh daemon.." sshd_restart ;; *) echo "usage $0 start|stop|restart" esac