Results 1 to 4 of 4
Hi, I'm running a Minecraft server and I would like to have a admin access via a PHP so I could restart stop the server etc. I have the possibility ...
- 11-04-2011 #1Just Joined!
- Join Date
- Oct 2011
- Posts
- 4
Sending SSH or Telnet command via a php page?
Hi, I'm running a Minecraft server and I would like to have a admin access via a PHP so I could restart stop the server etc. I have the possibility to have enable a telnet access to the server or use the SSH access.
The problem is that the telnet access will be diasabled after a server crash because it's a plugin that create that. So I would prefer to send ssh command via the php page.
What I need to send is pretty simple. I need to send as user minecraft the command ".stop" in a screen session called "mc". I tried that via php but I realised that the page (www-data) was unable to change user to minecraft so how can I do this? I'm not a expert in php neither so if you would give me some example that could be nice!
Thanks guys!
- 11-04-2011 #2Linux Guru
- Join Date
- May 2011
- Posts
- 1,813
I assume you have root access to the minecraft server...how about creating a sudo entry for the apache user to be permitted to run screen as the minecraft user?
- 11-04-2011 #3Just Joined!
- Join Date
- Oct 2011
- Posts
- 4
I tried sudo minecraft but seem that www-data is not allowed to do that command so how can I allow it ? thanks
- 11-04-2011 #4Linux Guru
- Join Date
- May 2011
- Posts
- 1,813
You have to edit the sudoers file, usually /etc/sudoers. I assume on Debian you'd do something like:
to open the file as root (somebody correct me if i'm wrong). then you'd add an entry like:Code:sudo visudo
that assumes that apache is the name of the user running your webserver and minecraft is the name of your user running the minecraft server.Code:apache ALL = (minecraft) NOPASSWD: /usr/bin/screen
then in your CGI page, you'd call it like:
Code:sudo -u minecraft /usr/bin/screen


Reply With Quote
