Originally posted by: shargus
Some time ago I needed to run a second copy of SSHD that ran on a special port using it's own config file. I did it by creating a SRC resource for a wrapper script around sshd. It uses SRC to automatically restart, but if it's not configured correctly it turns the auto-restart off.
You do have to use the "-D" option for sshd so it does NOT become a daemon.
Register it with SRC using the following command:
mkssys -s new_sshd -p /usr/local/bin/new_sshd -u 0 -R -d -Q -S -n 15 -f 9 -E 30 -G new_sshd
Here's the script:
#! /usr/bin/sh
export PATH=/usr/bin:/usr/sbin
PID=$$
logger "
$PID: new_sshd: Starting up new_sshd..."
-
If new_sshd_config has not been set up, exit now.
if
! -e /etc/new_sshd_config ;
then
logger "
$PID: new_sshd: /etc/new_sshd_config does not exist. Exiting now."
chssys -s new_sshd -O
sleep 2
stopsrc -s new_sshd
exit 1
fi
-
if new_sshd_config has not been configured yet, exit now.
if ;
then
logger "
$PID: new_sshd: ListenAddress has not yet been configured. Exiting now."
chssys -s new_sshd -O
sleep 2
stopsrc -s new_sshd
exit 1
fi
-
if new_sshd has been configured, set it up to automatically restart if not already done.
flag=`lssrc -S -s new_sshd | awk -F: ' $10 != "action" { print $10; } ' - `
if ;
then
logger "
$PID: new_sshd: Configuring new_sshd to start automatically at boot time."
chssys -s new_sshd -R
fi
-
Start up the sshd daemon.
-
Use the -D option so we don't exit. If we DO exit, SRC will restart us.
logger "
$PID: new_sshd: Starting new ssh server now."
exec /usr/local/sbin/sshd -f /etc/new_sshd_config -D
#AIX-Forum