rebooting a server from email

Rob

New member
I wonder if its possible to reboot an server / service via email

Say for instance i setup an email account services@domain.com and then got a php script to read the email's within the email account and if any service commands were listed in the email body like 'service httpd restart' the php script interpreted the command and executed it - thus rebooting Apache
 
Last edited:
HHS-Rob, this would be virtually impossible, unless the script was setup to recognize the commands given.

There would be a lot of factors to take into consideration as well.
1. The script would have to be located on an account that has root level, or super user level SSH access.

2. At the very least, shell_exec would need to be enabled.

3. Email piping takes the incoming message, and sends it off, it doesn't interpret any of it. It just receives and sends by default. The script would need to be configured to interpret the command, before it actually could.
 
Hi Mark,

Thanks for your reply. I thought it would be a bit complicated to achieve. But still no harm in asking :)
 
Interesting but if you have access to email don't have access to the server ??
and if the server is completely locked up sending an email to said server is not going to do much good or I did I miss something ?
 
It should be possible. You can parse your email boy. Something like:

if (cat /var/spool/INBOX | grep "reboote server") do

do something

fi
 
Like mr_brain said, it is possible. Make sure you think about security - the email should make sure that the sender has the correct credentials for the particular server they are wanting to reboot.

That said, I haven't seen anyone provide such a service...

Dave
 
I would say it's possible, but it would require some good security (to ensure random emails cannot be received with other dangerous commands).

I personally would use a remote reboot service which I could telnet/ssh in to from my PDA. Right now I have that option and assistance from my hosting company who monitor and reboot services as required.
 
Right now I have that option and assistance from my hosting company who monitor and reboot services as required.
[\quote]

Thats the same for us, the servers are managed.

I just thought it was something to possibly think about and wether it was possible. I do see your point about security and you could also have the problem of fake mailers posing to be from that specific email address.
 
I just thought it was something to possibly think about and wether it was possible. I do see your point about security and you could also have the problem of fake mailers posing to be from that specific email address.

However the solution to fake mailers would be to setup a rule that will only process if the email is coming from one of your own mail servers ONLY.
 
However the solution to fake mailers would be to setup a rule that will only process if the email is coming from one of your own mail servers ONLY.

Even still, there are soooo many ways this can be compromised its not even funny.
 
Back
Top