Hello,
This is my first post and hope i wont be disappointed .
I have setup an intranet of 10 machines(all running Ubuntu).
I use ssh from command line to administer this n/w & to run scripts on each of them.I just thought about creating a browser interface to do this job so that someone else could easily do the same in a user friendly convenient way.In doing so I would be providing a layer of abstraction to the new user.I'm not thinking bout security at the moment!."After an hour of googling,i think PHP could do the job.
In a nutshell
-a browser interface under Apache web server that would connect to any of the machines in the intranet (as selected by the user).
-the connection would be via ssh
To give a more clearer picture:
At the end of it,i would like to have an interface on machine A,say with 9 PCs listed on the GUI.I select machine 3-the click connects to machine 3 from machine A via ssh.I would then have say eg-'buttons' for 3 tasks...select task 1 and it would run a perl script which resides on machine 3.....so on...
Could anyone tell me how to go about accomplishing this.....I have little programming knowledge but trying to work on it,heres what i did so far....
created a form admin.php
<html>
<head><title>ClientForm</title></head>
<body>
<h1>Register for an Account:</h1>
<form action="admin_action.php" method="GET">
servername: <input type="text" name="name" /><br />
Password: <input type="password" name="pword" /><br />
<input type="submit" value="GO" />
</form>
</body>
</html>
then in another file admin_action.php,put in this code
<html>
<title>ClientTerminal</title>
<body>
<p>You entered:</p>
<?php
$servername = $GET['name'];
$password = $GET['pword'];
//echo "<p>servername= " . $servername . "</p>";
//echo "<p>Password = " . $password . "</p>";
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($servername, 22))){
echo "fail: unable to establish connection\n";
} else {
// try to authenticate with username root, password secretpassword
if(!ssh2_auth_password($con, "root", $password)) {
echo "fail: unable to authenticate\n";
} else {
// allright, we're in!
echo "okay: logged in...\n";
// execute a command
$stream = ssh2_exec($con, 'ps ax');
$output = stream_get_contents($stream);
}
}
?>
</body>
</html>
Now i access http://localhost/admin.php
server name:ubuntu.surey.com
password:*******
click the GO button
i get
okay: logged in...
๐
I assume the ssh is working fine๐
but the rest of it is not....how do i get this code to execute the command
Cheers
David