LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Remotely Reboot Linux Box From a Windows PC. (https://www.linuxquestions.org/questions/programming-9/remotely-reboot-linux-box-from-a-windows-pc-898827/)

mrm5102 08-22-2011 03:32 PM

Remotely Reboot Linux Box From a Windows PC.
 
Hello,

We have a Linux Computer at work that occasionally has some problems and needs to be rebooted. But the problem is that the manager of that Dept isn't the most technical person in the world and would like to make this as painless as possible for her.

She is running Windows XP Pro. If it were a Linux machine she was running I would probably just write a little simple Expect script that would ssh to the server and send the "shutdown -r now" command and that would be it. But how would I go about doing that on a windows machine. Is there a way to write an Expect script and make it executable in windows? So all she would have to do is "Click the icon" and that's it?


Thanks,
Matt

TobiSGD 08-22-2011 03:38 PM

At first, wouldn't it be better to fix the issues then to reboot the server to fix the symptoms?

To your problem, just use a command line client for SSH in Windows that can do key based authorization and allow her account to reboot the machine using sudo. This way you can write a simple batch script she can click on.

millgates 08-22-2011 03:39 PM

hi,
here's what i found with a quick google search.
is that what you need?
http://fixunix.com/ssh/253629-how-pa...h-execute.html

mrm5102 08-22-2011 03:46 PM

TobiSGD,

Quote:

At first, wouldn't it be better to fix the issues then to reboot the server to fix the symptoms?

To your problem, just use a command line client for SSH in Windows that can do key based authorization and allow her account to reboot the machine using sudo. This way you can write a simple batch script she can click on.
Well I think the problem is usually another server that that server connects to. Somehow their connection gets interrupted and the easiest way to fix it is to just do a simple reboot.


millgates,

Quote:

hi,
here's what i found with a quick google search.
is that what you need?
http://fixunix.com/ssh/253629-how-pa...h-execute.html
It's funny you should post that link, because I came across that very same one. But I wanted to see if anyone had other ideas, never used Putty before. (There's more than one way to skin a cat lol)...

Do you know to use ExtraPutty to send commands from I guess another text like file with a separate command on each line?


Thanks,
Matt

millgates 08-22-2011 04:29 PM

Quote:

Originally Posted by mrm5102 (Post 4450523)
millgates,

It's funny you should post that link, because I came across that very same one. But I wanted to see if anyone had other ideas, never used Putty before. (There's more than one way to skin a cat lol)...

That's true :) For example, you may write a script on the linux machine that checks for incoming logins in a cycle and if it detects one, it reboots the pc :)) but that's probably a stupid idea :)))

Quote:

Originally Posted by mrm5102 (Post 4450523)
Do you know to use ExtraPutty to send commands from I guess another text like file with a separate command on each line?

well i never actually tried it, but i guess if you want to run multiple commands, you can put them in a script on the linux machine and run it with a single command via ExtraPutty

mrm5102 08-22-2011 04:57 PM

Millgates,

Quote:

That's true For example, you may write a script on the linux machine that checks for incoming logins in a cycle and if it detects one, it reboots the pc ) but that's probably a stupid idea ))
Actually that doesn't sound too bad. I could do something like just create a user on the Linux box ONLY for this one purpose. And like you said, if it gets a login attempt from that one and only user, then it will run a script or something. I like it... That would basically bypass any need to have to run any kind of script from Windows, and the person who is going to use it already knows how to login. So that's a plus plus...


Thanks for the suggestion, I'll give it a try when I get back to work tomorrow and let you know how it goes.


Thanks again,
Matt

michaelk 08-22-2011 05:41 PM

plink will do automated connections.
http://the.earth.li/~sgtatham/putty/.../Chapter7.html

mrm5102 08-23-2011 08:08 AM

Michaelk,

I'll check that out thanks.


-Matt

sundialsvcs 08-23-2011 08:31 AM

It's axiomatic that a Linux box (and a Windows box, for that matter...) ought not need to be "rebooted." Tools exist ... Nagios, and others ... which can monitor the network connection and automatically restart it.

But, even so, the problem needs to be diagnosed and repaired. (Look at the system log files on both of the machines in question.) Network connections should not "go down unexpectedly." Maybe there's a timeout or something.

When and if things like this do happen, the computer should be perfectly capable of issuing the necessary corrective action with no human intervention required.

I have quite routinely encountered Linux systems (and Windows systems, for that matter :eek: ...) which have 'up times' of more than a year. They are never "rebooted," and they never need to be.

mrm5102 08-23-2011 10:54 AM

sundialsvcs,

Quote:

It's axiomatic that a Linux box (and a Windows box, for that matter...) ought not need to be "rebooted." Tools exist ... the one mentioned, or Nagios, and others ... which can monitor the network connection and automatically restart it.

But, even so, the problem needs to be diagnosed and repaired. (Look at the system log files on both of the machines in question.) Network connections should not "go down unexpectedly." Maybe there's a timeout or something.

When and if things like this do happen, the computer should be perfectly capable of issuing the necessary corrective action with no human intervention required.

I have quite routinely encountered Linux systems (and Windows systems, for that matter ...) which have 'up times' of more than a year. They are never "rebooted," and they never need to be.
Yea your right, that would be the best option. Not sure where to look for the errors though...
Do you know where/what logs I should look at to find the problem? It's basically two computers that somehow get a connection through a flash script.

I dunno if it helps to narrow down what logs to look at but it works like this:
The computer running the flash script connects to the other and pulls out some data and displays it using the flash "video". This program that a coworker wrote contains one flash file (.swf) and one HTML file. To run it you would right-click the HTML file and run it in Firefox. The "video" is then displayed in Firefox somewhat like a slideshow of data.


Thanks,
Matt

frieza 08-23-2011 11:57 AM

one solution i've seen on dd-wrt (though probably a horrible idea on a production server) would be to create a user 'reboot' with permissions to reboot the system, then set it's shell to /sbin/reboot, thus simply logging in with that user triggers a reboot, though unless you can restrict how that account gets accessed that would probably be a last ditch idea

mrm5102 08-25-2011 02:06 PM

Hey Guys,

Thanks for everyone's help. And MillGates thanks for the suggestion with a user whose sole purpose would be to restart the computer, got it working and it works perfectly.

Thanks again,
Matt


All times are GMT -5. The time now is 01:39 AM.