sshd never restarts
freebsd-questions-local at be-well.ilk.org
Tue Jan 30 18:50:50 UTC 2007
Noah <admin2 at enabled.com> writes:
> FreeBSD 4.9
> so I have a script /usr/local/etc/rc.d/sshd.sh that I use to restart sshd
> but sshd most of the time never comes back.
> there is nothing relevant that makes it to /var/log/messages
> if I start sshd manually with /usr/local/etc/rc.d/sshd.sh there are no
> error messages. My /etc/ssh/sshd_config configuration is fine and has
> no errors.
> how can I assure that sshd restarts each time? when I am remote to
> the machine. I am locked out of it.
The first thing you need to understand is why this is happening. The
script starts executing, and shuts down sshd. The output from that
command is being sent to your terminal, which is no longer reachable.
The shell closes, and the script stops before it gets around to
starting sshd up again. [This type of problem is also common in
resetting firewall settings from a remote terminal.]
There are many ways to work around this problem. My favorite is
probably to use screen (ports/sysutils/screen), which will disconnect
the shell from the terminal session and allow you to reconnect later.
You would probably be okay with just redirecting the standard output
(and error output) of the script, but the shell is going to close
anyway, because the ssh session is closed by shutting sshd down. In
some cases, it can also be useful to run the script via cron(8) or
at(1). You can decide for yourself.
I must say, though, that resetting sshd isn't something I do often.
Are you sure it is necessary at all?
More information about the freebsd-questions