Restart Windows Remotely through VPN
I often remotely control Windows machines at my office via Remote Desktop and VPN when I’m traveling. Ocassionally a Windows machine will stop responding to requests for Remote Desktop and the only solution I’ve found is to restart the machine but thats difficult to do when you are in London, its 3AM EST, and there isn’t anyone in the office to flick the reset switch for you.
First install OpenSSH. This handy app creates a Windows NT service on your machine that allows you to SSH to the box and run DOS commands remotely. Once the installer completes you need to setup the local Windows users that you want to be able to SSH with. (In my example I won’t specify a user which defaults to all Windows users)
Open up DOS and execute the following (change d:\apps\OpenSSH to your install folder):
mkgroup -l >> ..\etc\group
mkgroup -d >> ..\etc\group
mkpasswd -l >> ..\etc\passwd
mkpasswd -d ..\etc\passwd
Now start the OpenSH service for the first time:
net start opensshd
The OpenSSH service should be running now. To test it go to another machine and attempt to SSH in.
Cool! We’re in.
Finally we want to reboot the machine. Executing the following in the SSH client will restart the machine and force any apps to close. You will lose any unsaved work on the machine.
shutdown -r -f -m \\computername
The shutdown alert is displayed on the remote machine and 30 seconds later it is restarted!