ChrisMartino Posted November 5, 2009 Share Posted November 5, 2009 Well basicaly i have a linux dedicated server, And i have a webhost with openssl installed, What would be the best way to remotley send a command to the box withought using SSH? This is my hosts phpinfo() : http://fotosnap.net/phpinfo.php Link to comment https://forums.phpfreaks.com/topic/180465-what-would-be-the-best-way-to-send-a-command/ Share on other sites More sharing options...
ChrisMartino Posted November 5, 2009 Author Share Posted November 5, 2009 ? Link to comment https://forums.phpfreaks.com/topic/180465-what-would-be-the-best-way-to-send-a-command/#findComment-952085 Share on other sites More sharing options...
ChrisMartino Posted November 6, 2009 Author Share Posted November 6, 2009 Any help? Link to comment https://forums.phpfreaks.com/topic/180465-what-would-be-the-best-way-to-send-a-command/#findComment-952605 Share on other sites More sharing options...
jonsjava Posted November 6, 2009 Share Posted November 6, 2009 here's a script I threw together in a couple minutes. It's not too secure, so I reccommend that you run this on your local machine to make the connections, but only if you have the required software to do this. If you need help setting it up, let me know: <form method="POST" action="?"> <table border="0"> <tr> <td>Secret word to run this:</td> <td><input type="password" name="secret"></td> </tr> <tr> <td>User:</td> <td><input type="text" name="username"></td> </tr> <tr> <td>Pass:</td> <td><input type="password" name="password"></td> </tr> <tr> <td>Command to run:</td> <td><input type="text" name="cmd"></td> </tr> <tr> <td><input type="submit" value="Execute Command"></td> <td> </td> </tr> </table> </form> <?php $secret_word = "cheeseburgerinparadise"; if (isset($_POST) && isset($_POST['secret']) && $_POST['secret'] == $secret_word){ run_ssh_command($_POST['cmd'], $_POST['username'], $_POST['password']); } function run_ssh_command($commaind, $user, $password){ $your_server = "example.com"; /* <-- Change to your server */ if (!function_exists("ssh2_connect")) die("function ssh2_connect doesn't exist"); // log in at server1.example.com on port 22 if(!($con = ssh2_connect($your_server, 22))){ echo "fail: unable to establish connection\n"; } else { // try to authenticate with username root, password secretpassword if(!ssh2_auth_password($con, $user, $password)) { echo "fail: unable to authenticate\n"; } else { // allright, we're in! echo "okay: logged in...\n"; // execute a command if(!($stream = ssh2_exec($con, "ls -al" )) ){ echo "fail: unable to execute command\n"; } else{ // collect returning data from command stream_set_blocking( $stream, true ); $data = ""; while( $buf = fread($stream,4096) ){ $data .= $buf; } fclose($stream); } } } } ?> EDITED to fix a small error. Link to comment https://forums.phpfreaks.com/topic/180465-what-would-be-the-best-way-to-send-a-command/#findComment-952613 Share on other sites More sharing options...
ChrisMartino Posted November 6, 2009 Author Share Posted November 6, 2009 My host dosen't have SSH2 tho Link to comment https://forums.phpfreaks.com/topic/180465-what-would-be-the-best-way-to-send-a-command/#findComment-952618 Share on other sites More sharing options...
jonsjava Posted November 6, 2009 Share Posted November 6, 2009 forgot that part. hm.... You could set up a SOAP server on your box, and send SOAP requests to it remotely. Link to comment https://forums.phpfreaks.com/topic/180465-what-would-be-the-best-way-to-send-a-command/#findComment-952620 Share on other sites More sharing options...
ChrisMartino Posted November 8, 2009 Author Share Posted November 8, 2009 *bump Link to comment https://forums.phpfreaks.com/topic/180465-what-would-be-the-best-way-to-send-a-command/#findComment-953679 Share on other sites More sharing options...
ChrisMartino Posted November 23, 2009 Author Share Posted November 23, 2009 Anyone know the best way?, I'm using the Corporate package: http://x10hosting.com/premium.php Link to comment https://forums.phpfreaks.com/topic/180465-what-would-be-the-best-way-to-send-a-command/#findComment-963568 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.