SSH2 execute funktioniert nicht

Irgendwelche Probleme mit XAMPP für Windows? Dann ist hier genau der richtige Ort um nachzufragen.

SSH2 execute funktioniert nicht

Postby NameZero912 » 22. November 2007 16:18

Hallo.

Ich benutze derzeit Version 1.6.3a von XAMPP. Ich möchte auf einen Linux-Rechner per SSH (genauer: SSH2) verbinden, dort in ein bestimmtes Verzeichnis wechseln, dort Unterverzeichnisse erstellen und darin später per SFTP (ebenfalls die ssh2--lib Funktionen) Dateien hineinkopieren.

Folgendes funktioniert noch:
- Verbinden
- Einloggen

Allerdings kann ich durch SSH keinerlei Sachen/Veränderungen/was auch immer durchführen.

Führe ich z.B. "ls- la" aus, ist der Rückgabestream ein leerer Stream. Erstelle ich Verzeichnisse, passiert nichts (output ist leer, Verzeichnis wurde nicht erstellt). Führe ich den Befehl "ichfunktionierenichtundbinstolzdrauf" kommt ebenfalls kein output im Sinne von "unbekannter Befehl".

Ich gehe jetzt einfach mal davon aus, dass ich etwas falsch programmiert habe (trotz c/p aus Tutorials bzw. php.net). Egal. Kann mir einer sagen, was ich falsche mache?

Ich benutze z.B. folgenden Code:

Code: Select all
//connect to SSH
$sshCon = ssh2_connect($config->ssh->host, 22);
if (!$sshCon) {
   //Fehler
} else {
   //authenticate using the username and password from the config file
   if(!ssh2_auth_password($sshCon, $config->ssh->username, $config->ssh->password)) {
        //Fehler
   } else {
      
      try {
         //switch directory
         if(!($stream = ssh2_exec($sshCon, 'cd /tralalala')) ){
            throw new Exception();
         } else {
            stream_set_blocking( $stream, true );
            close($stream);
         }
                  
         //create directories and set rights
         if(!($stream = ssh2_exec($sshCon, 'mkdir xyz')) ){
            throw new Exception();
         } else {
            stream_set_blocking( $stream, true );
            $output = stream_get_contents($stream);
            fclose($stream);
         }
         
         //expect error-output
         if(!($stream = ssh2_exec($sshCon, 'ldasdsddl')) ){
            throw new Exception();
         } else {
            stream_set_blocking( $stream, true );
            $output = stream_get_contents($stream);
            fclose($stream);
         }
                  
         //shell geht leider auch nicht, d.h. kein output und Befele werden fröhlich ignoriert      
         if (!$stream = ssh2_shell($sshCon, 'vt102', null, 80, 24, SSH2_TERM_UNIT_CHARS)) {
            throw new Exception();
         } else {
            stream_set_blocking( $stream, true );
            // send a command
            fwrite($stream,"cd /tralalala\n");
            sleep(1);
            fwrite($stream,"cd mkdir 210\n");            
         }
                  
                  
      } catch (Exception $ex) {
         //Fehlerbehandlung
      }


Es macht auch keinen Unterschied, wenn ich ein "\n" an das Ende eines Befehls in ssh2_exec() einsetze.
NameZero912
 
Posts: 7
Joined: 21. January 2006 20:55

Return to XAMPP für Windows

Who is online

Users browsing this forum: No registered users and 52 guests