1 |
<? |
<? |
2 |
/* das script benötigt folgende tabellen in der datenbank: |
include('include/common-functions.php'); |
|
* ssh_auth_clients spalten -> serial [int 11], public_key [text] |
|
|
* 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'); |
|
3 |
|
|
4 |
echo '<body onload="window.setTimeout(\'window.close()\', 1750)">'; |
echo '<body onload="window.setTimeout(\'window.close()\', 1750)">'; |
5 |
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>'; |
6 |
|
|
7 |
$pubkey = mysql_query('select public_key from ssh_auth_clients where serial='.$client.''); |
# reboot des clients |
8 |
while ($row = mysql_fetch_row ($pubkey)) { |
if(online($ip) == 0) |
9 |
|
{ |
10 |
|
echo '<img src="pics/online.gif" align=top> '.strtoupper($op.'ing client #'.$client.' ('.$ip.')...<br>'); |
11 |
|
sshdo('/sbin/'.$op, $ip); |
12 |
|
} |
13 |
|
else echo '<img src="pics/offline.gif" align=top> '.strtoupper('Client not online, try again later...<br>'); |
14 |
|
|
15 |
# 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>'; |
|
16 |
?> |
?> |