Witam
Mam taki skrypcik do backupu bazy. Wszystko gra do momentu, kiedy wywoluje komende 'scp' (linia 36) - w tym momencie skrypt sie zatrzymuje - normalnie scp powinno zapytać o hasło.

  1. <?php
  2. if(!($shell = ssh2_shell($sshc, 'xterm'))){
  3.        echo "[error] unable to establish shell", PHP_EOL;
  4.    } else {
  5.  
  6.        echo "[info] shell established. starting commands.", PHP_EOL;
  7.        usleep(500000);
  8.  
  9.        stream_set_blocking( $shell, true );
  10.  
  11.        /*
  12.         * sending commands
  13.         */
  14.        if ($server['su_pass'] !== '')
  15.        {
  16.            fwrite($shell, 'su' . PHP_EOL);
  17.            fwrite($shell, $server['su_pass'] . PHP_EOL);
  18.        }
  19.  
  20.        fwrite($shell, "rm -rf {$server['remote_backup_dir']};" . PHP_EOL);
  21.        fwrite($shell, "mkdir {$server['remote_backup_dir']};" . PHP_EOL);
  22.        
  23.        $mysqlhotcopy_options = '';
  24.        if ($server['mysql_user'] !== '')
  25.        {
  26.            $mysqlhotcopy_options = " --user={$server['mysql_user']} ";
  27.        }
  28.        if ($server['mysql_pass'] !== '')
  29.        {
  30.            $mysqlhotcopy_options = " --password={$server['mysql_pass']} ";
  31.        }
  32.        
  33.        fwrite($shell, "mysqlhotcopy {$mysqlhotcopy_options} --regexp='.+' {$server['remote_backup_dir']};" . PHP_EOL);        
  34.        fwrite($shell, "chmod -R 777 {$server['remote_backup_dir']};".PHP_EOL);
  35.        fwrite($shell, "scp -v -r {$server['remote_backup_dir']} {$backup_server['user']}@{$backup_server['host']}:{$temp_dir}".PHP_EOL);
  36.        fwrite($shell, $backup_server['pass'] . PHP_EOL);
  37.        fwrite($shell, "echo '__COMMAND_FINISHED__';" . PHP_EOL);
  38.        
  39.        $data = "";
  40.        while($buf = fgets($shell))
  41.        {
  42.            flush();
  43.            echo "\t", $buf;
  44.            if(strpos($buf, "__COMMAND_FINISHED__") !== false){
  45.                break;
  46.            }
  47.        }
  48.  
  49.        fclose($shell);        
  50.  
  51.    }
  52. ?>


i załączam jeszcze debug z scp:

CODE

debian:~# scp -v -r /tmp/mysql_backup root@192.168.0.103:/tmp/backup_temp
Executing: program /usr/bin/ssh host 192.168.0.103, user root, command scp -v -r -t /tmp/backup_temp
OpenSSH_4.3p2 Debian-9etch3, OpenSSL 0.9.8c 05 Sep 2006
debug1: Reading configuration data /etc/ssh/ssh_config^M
debug1: Applying options for *^M
debug1: Connecting to 192.168.0.103 [192.168.0.103] port 22.^M
debug1: Connection established.^M
debug1: permanently_set_uid: 0/0^M
debug1: identity file /root/.ssh/identity type -1^M
debug1: identity file /root/.ssh/id_rsa type 1^M
debug1: identity file /root/.ssh/id_dsa type -1^M
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3p2 Debian-9etch3^M
debug1: match: OpenSSH_4.3p2 Debian-9etch3 pat OpenSSH*^M
debug1: Enabling compatibility mode for protocol 2.0^M
debug1: Local version string SSH-2.0-OpenSSH_4.3p2 Debian-9etch3^M
debug1: An invalid name was supplied
Cannot determine realm for numeric host address
^M
debug1: An invalid name was supplied
A parameter was malformed
Validation error
^M
debug1: An invalid name was supplied
Cannot determine realm for numeric host address
^M
debug1: An invalid name was supplied
A parameter was malformed
Validation error
^M
debug1: SSH2_MSG_KEXINIT sent^M
debug1: SSH2_MSG_KEXINIT received^M
debug1: kex: server->client aes128-cbc hmac-md5 none^M
debug1: kex: client->server aes128-cbc hmac-md5 none^M
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent^M
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP^M
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent^M
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY^M
debug1: Host '192.168.0.103' is known and matches the RSA host key.^M
debug1: Found key in /root/.ssh/known_hosts:7^M
debug1: ssh_rsa_verify: signature correct^M
debug1: SSH2_MSG_NEWKEYS sent^M
debug1: expecting SSH2_MSG_NEWKEYS^M
debug1: SSH2_MSG_NEWKEYS received^M
debug1: SSH2_MSG_SERVICE_REQUEST sent^M
debug1: SSH2_MSG_SERVICE_ACCEPT received^M
debug1: Authentications that can continue: publickey,password^M
debug1: Next authentication method: publickey^M
debug1: Trying private key: /root/.ssh/identity^M
debug1: Offering public key: /root/.ssh/id_rsa^M
debug1: Authentications that can continue: publickey,password^M
debug1: Trying private key: /root/.ssh/id_dsa^M
debug1: Next authentication method: password^M


Pomóżcie ludzie, bo już nie wiem gdzie szukać.