SSH meets MSH
Here's a followup on why I couldn't SSH into my home system today.
Sometimes, odd network problems will cause the SSH service to lock up, or refuse connections, or just hang. In the past week, I've seen this happen as a result of both unknown ISP wonkiness and a power outage at the remote connecting site.
For whatever reason, the SSH service doesn't exactly shutdown in the cleanest way possible when things like this happen, so I like to shut the service down manually every once in a while, just to free up some memory and flush some file descriptors.
And sometimes, I forget to turn the service back on before I go to bed. As a result, I was still reaching my home system, but without a running instance of sshd to actually accept the connection, Windows was just refusing every attempt.
Tonight before dinner it occurred to me that I may be able to use this computational technology to double-check whether or not sshd was running. So I made sure I'd uninstalled Visual Studio 2005 C# and C++ Express Editions, uninstalled .NET Framework 2.0 Beta, and uninstalled Windows command shell preview.
It's important that if you want to run MSH, you have to use a certain .NET Framework 2.0 Beta that is incompatible with Visual Studio 2005. So I reinstalled the MSH-friendly .NET Framework Beta and the MSH software itself.
Now, I have recently created a new folder, "C:\Documents and
Settings\user\Scripts". It contains DOS-style batch files, and
I have added a short little MSH script to this directory called
"start-sshd.msh":
$svc = get-service sshd
if ($svc.Status -eq "Stopped")
{
start-service $svc.ServiceName
}
I then created a new Scheduled Task to run this script every morning. Advantages: it will reliably turn sshd on if I forget to do so the night before. Disadvantages: there should exist a mechanism that will silently monitor a given service 24 hours a day and silently restart it if it stops, regardless of time of day.
If anyone knows of a way to accomplish this in Windows, let me know.
No comments:
Post a Comment