1 |
<? |
<? |
2 |
/* das script benötigt folgende tabellen in der datenbank: |
include('include/common-functions.php'); |
3 |
* ssh_auth_clients spalten -> serial [int 11], public_key [text] |
include('include/socket_send.php'); |
|
* ssh_auth_server spalten -> id [int 11], public_key [text] |
|
|
* |
|
|
* du musst auf jeden fall den ping befehl anpassen und der pfad zum hostfile auf dem |
|
|
* apache2 lautet '/home/httpd/.ssh/known_host', evtl müsste das verzeichnis .ssh erstellt werden |
|
|
* |
|
|
* that's it, works4me (TM) |
|
|
*/ |
|
|
include('include/dbconn.php'); |
|
4 |
|
|
5 |
echo '<body onload="window.setTimeout(\'window.close()\', 1750)">'; |
echo '<body onload="window.setTimeout(\'window.close()\', 1750)">'; |
6 |
echo '<table width=100% height=100% style="border:solid black 1px; background-color:#d5e5ff"><tr><td valign=middle align=center>'; |
echo '<table width=100% height=100% style="border:solid black 1px; background-color:#d5e5ff"><tr><td valign=middle align=center>'; |
7 |
|
|
8 |
$pubkey = mysql_query('select public_key from ssh_auth_clients where serial='.$client.''); |
# reboot des clients |
9 |
while ($row = mysql_fetch_row ($pubkey)) { |
passthru($pingcmd." ".$ip." &> /dev/null && exit 0 || exit 1",$retval); |
10 |
|
if($retval==0) |
11 |
|
{ |
12 |
|
echo '<img src="pics/online.gif" align=top> '.strtoupper($op.'ing client #'.$client.' ('.$ip.')...<br>'); |
13 |
|
//@sshdo('/sbin/'.$op, $ip); |
14 |
|
mcore_socket_send($ip, $mcore_port, "set system.".$op); |
15 |
|
} |
16 |
|
else echo '<img src="pics/offline.gif" align=top> '.strtoupper('Client not online, try again later...<br>'); |
17 |
|
|
18 |
# schreiben der .ssh/known_hosts file mit dem public rsa key des client, |
echo '</td></tr></table>'; |
|
# um die "yes" abfrage zu vermeiden |
|
|
$hostfile = fopen ($home."/.ssh/known_hosts","w"); |
|
|
fwrite($hostfile,$ip." ".$row[0],strlen($row[0])+strlen($ip)+1); |
|
|
fclose($hostfile); |
|
|
|
|
|
# reboot des clients |
|
|
passthru($pingcmd.' '.$ip.' &> /dev/null && exit 0 || exit 1',$retval); |
|
|
if($retval==0) { |
|
|
echo '<img src="pics/online.gif" align=top> '.strtoupper($op.'ing client #'.$client.' ('.$ip.')...<br>'); |
|
|
system($sshcmd.' '.$ip.' /sbin/'.$op); |
|
|
} |
|
|
else echo '<img src="pics/offline.gif" align=top> '.strtoupper('Client not online, try again later...<br>'); |
|
|
} |
|
|
echo '</td></tr></table>'; |
|
19 |
?> |
?> |