You are not logged in.
I setup an Arch server virtual machine and am having some problems. When I tell the vm to shutdown over SSH, it shutdowns fine but never closes the shh connection. I had to add add the servertimeout option otherwise my terminal would freeze. I tried the same thing with a Ubuntu 9.04 server and it does close the shh connection. Anything I should check for in the sshd_config?
Offline
To get that behavior, many distros just check to see if the runlevel is 6 (or 0), and then put a 'killall sshd' line into the 'stop' script.
prog=sshd
if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then
killall $prog 2>/dev/null
fi
I know rc.shutdown checks PRELEVEL, but I don't recall if the init that arch uses (minimal sysv init binary) sets RUNLEVEL=6 on shutdown or not (so you could add a check to the sshd daemon script as above). You could give it a try though.
Make sure it doesn't fire if you do an /etc/rc.d/sshd restart though, as it should only killall sshd on actual system shutdown, and not just daemon shutdown.
Last edited by cactus (2009-04-26 07:37:25)
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
To get that behavior, many distros just check to see if the runlevel is 6 (or 0), and then put a 'killall sshd' line into the 'stop' script.
prog=sshd if [ "x$runlevel" = x0 -o "x$runlevel" = x6 ] ; then killall $prog 2>/dev/null fi
I know rc.shutdown checks PRELEVEL, but I don't recall if the init that arch uses (minimal sysv init binary) sets RUNLEVEL=6 on shutdown or not (so you could add a check to the sshd daemon script as above). You could give it a try though.
Make sure it doesn't fire if you do an /etc/rc.d/sshd restart though, as it should only killall sshd on actual system shutdown, and not just daemon shutdown.
I'm not sure if $runlevel is getting set... Could I use "who -r" instead?
Offline
This seems to work:
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/sshd
PID=`cat /var/run/sshd.pid 2>/dev/null`
case "$1" in
start)
stat_busy "Starting Secure Shell Daemon"
[ -f /etc/ssh/ssh_host_key ] || { /usr/bin/ssh-keygen -t rsa1 -N "" -f /etc/ssh/ssh_host_key >/dev/null; }
[ -f /etc/ssh/ssh_host_rsa_key ] || { /usr/bin/ssh-keygen -t rsa -N "" -f /etc/ssh/ssh_host_rsa_key >/dev/null; }
[ -f /etc/ssh/ssh_host_dsa_key ] || { /usr/bin/ssh-keygen -t dsa -N "" -f /etc/ssh/ssh_host_dsa_key >/dev/null; }
[ -z "$PID" ] && /usr/sbin/sshd $SSHD_ARGS
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon sshd
stat_done
fi
;;
stop)
stat_busy "Stopping Secure Shell Daemon"
[ ! -z "$PID" ] && kill $PID &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon sshd
# remove all running sshd processes
runlevel | grep "[06]" > /dev/null
if [ $? -eq 0 ] ; then
printhl "Killing all sshd processes"
killall -q sshd &> /dev/null
fi
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
Only one minor problem, the killall also kills the script shutting down the sshd daemon. Does anyone know a way around this?
Also, why isn't something like this the default?
Offline
Maybe this problem is caused by /etc/rc.shutdown when killall5 is called, since it won't kill the terminal that is calling the shutdown (the SSH terminal, see the man page for killall5)?
Offline
Also I found this bug report for Gentoo: http://bugs.gentoo.org/show_bug.cgi?id=259183
Also found this: http://www.snailbook.com/faq/background-jobs.auto.html
Last edited by tjwallace (2009-04-26 18:20:38)
Offline