#!/sbin/sh # Control Method for openSSH (/lib/svc/method/ossh (c) esm@mnemonic.no 2006) make_hostkeys () { #making host-keys if they dont exist if [ ! -r /etc/ssh/ssh_host_dsa_key ] ; then mkdir -p /var/empty ; chown root:sys /var/empty ; chmod 755 /var/empty mkdir -p /usr/local/etc ; chown root:sys /usr/local/etc ; chmod 755 /usr/local/etc /usr/sbin/groupadd sshd ; sleep 1 /usr/sbin/useradd -g sshd -c 'sshd privsep' -d /var/empty -s /bin/false sshd /usr/local/bin/ssh-keygen -t dsa -f /usr/local/etc/ssh_host_dsa_key -N "" /usr/local/bin/ssh-keygen -t rsa -f /usr/local/etc/ssh_host_rsa_key -N "" fi } case "$1" in '-u') rm -f /usr/local/etc/ssh_host_???_key* ;; '-c') make_hostkeys ;; 'restart') /usr/bin/pkill -f -1 -P1 /usr/local/sbin/sshd ;; 'start') make_hostkeys ; /usr/local/sbin/sshd -f /usr/local/etc/sshd_config ;; 'stop') /usr/bin/pkill -f -9 -P 1 /usr/local/sbin/sshd || /usr/bin/pkill -9 /usr/local/sbin/sshd ;; *) echo "Usage: $0 { start | stop |restart | -u | -c }" exit 1 esac exit 0