Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 30 Jan 2007 13:50:49 -0500
From:      Lowell Gilbert <>
To:        Noah <>
Subject:   Re: sshd never restarts
Message-ID:  <>
In-Reply-To: <> (Noah's message of "Sat, 27 Jan 2007 12:07:33 -0800")
References:  <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
Noah <> writes:

> FreeBSD 4.9
> openssh-3.6.1_6
> so I have a script /usr/local/etc/rc.d/  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/ 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?

Good luck.

Want to link to this message? Use this URL: <>