Ankündigung

Einklappen
Keine Ankündigung bisher.

Server Reboot

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Server Reboot

    Hi Ihr,
    Ich habe mal wieder eine frage...
    Unzwar will ich mir grad einen kleinen interface bauen und ich wollte wissen wie es möglich ist, ein Server zu rebooten.
    Natürlich ist es mein eigener Root server.

    ich habe es bis jetzt mit ssh2_connect versucht und durch sudo

    Erster versuch:
    PHP-Code:
    <?php

    // ssh protocols
    // note: once openShell method is used, cmdExec does not work

    class ssh2 {

      var 
    $host '62.75.x.x';
      var 
    $user 'root';
      var 
    $port '22';
      var 
    $password 'xxPasswortxx';
      var 
    $con null;
      var 
    $shell_type 'xterm';
      var 
    $shell null;
      var 
    $log '';

      function 
    __construct($host=''$port=''  ) {

         if( 
    $host!='' $this->host  $host;
         if( 
    $port!='' $this->port  $port;

         
    $this->con  ssh2_connect($this->host$this->port);
         if( !
    $this->con ) {
           
    $this->log .= "Connection failed !"
         }

      }

      function 
    authPassword$user ''$password '' ) {

         if( 
    $user!='' $this->user  $user;
         if( 
    $password!='' $this->password  $password;

         if( !
    ssh2_auth_password$this->con$this->user$this->password ) ) {
           
    $this->log .= "Authorization failed !"
         }

      }

      function 
    openShell$shell_type '' ) {

           if ( 
    $shell_type != '' $this->shell_type $shell_type;
       
    $this->shell ssh2_shell$this->con,  $this->shell_type );
       if( !
    $this->shell $this->log .= " Shell connection failed !";

      }

      function 
    writeShell$command '' ) {

       
    fwrite($this->shell$command."\n");

      }

      function 
    cmdExec( ) {

           
    $argc func_num_args();
           
    $argv func_get_args();

       
    $cmd '';
       for( 
    $i=0$i<$argc $i++) {
           if( 
    $i != ($argc-1) ) {
             
    $cmd .= $argv[$i]." && ";
           }else{
             
    $cmd .= $argv[$i];
           }
       }
       echo 
    $cmd;

           
    $stream ssh2_exec$this->con$cmd );
       
    stream_set_blocking$streamtrue );
       return 
    fread$stream4096 );
          
    ssh2_exec(reboot);

      }

      function 
    getLog() {

         return 
    $this->log

      }

    }
    ?>
    Kein Fehler... oder sonstige hinweiße zu sehen. Aber es führt das Reboot auch nicht aus..

    2.´te versuch
    Sudo
    PHP-Code:
    <?
    passthru('echo reboot | sudo /usr/bin/php -f /sbin/reboot.sh');
    ?>
    inhalt der reboot.sh
    Code:
    ! /bin/sh
    /sbin/shutdown -r 0
    Hat einer ne ahnung was ich falsch mache ?
    oder hat einer von euch vielleicht einen code der mir weiterhelfen könnte...
    Ich habe hier im Forum so wie im Google gesucht, aber nichts gefunden

    Grüße
    Mc-kani

  • #2
    kann mir wirklich keiner weiter helfen ?

    Kommentar


    • #3
      keiner WILL dir helfen, du spinner.
      der server reboot gehört genauso wie das ändern des root-passworts zu dingen, die DU nicht - und schon gar nicht über php - machen darfst.

      siehe auch deinen neuesten thread.

      kauf dir ein buch über serveradministration und/oder spiel mit anderen dingen, solange du keine ahnung von den grundlagen hast.

      Kommentar


      • #4
        Das kann doch sicher alles webmin, http://www.webmin.com/

        Das Ding ist mir wieder ins Gedächtnis gekommen durch: http://www.heise.de/newsticker/meldung/64298

        Kommentar

        Lädt...
        X