routeros-api-php: Export bug ?

Version of RouterOS +100 routers tested. 6.43.x to 6.45.X

To Reproduce examples/export.php

Expected behavior I have only this response:

Array
(
    [0] => !done
)

Best regads, Mickael

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

@EvilFreelancer You can use phpseclib/phpseclib:~2.0

`use phpseclib\Net\SSH2;

… $ssh = new SSH2($this->connectionConfiguration[‘host’]); if (!$ssh->login($this->connectionConfiguration[‘login’], $this->connectionConfiguration[‘password’])) { throw new \Exception(“Error during ssh connection to the router”); } $ssh->write(“/export\n”); $export = $ssh->read(); // ??? Did not try it. ` I use this lib to transfer files via SSH/SCP, works like a charm.

@Griessmeister thanks for idea, but as you can see need to install additional extension which not available in default distribution of php, i think idea with phpseclib (which use standard crypt extensions) by @matracine is little bit more flexible.

Here is how I implemented it via PHP it requires php-ssh2

sudo apt-get install php-ssh2.

$connection = ssh2_connect($this->host, 22);
        ssh2_auth_password($connection, $this->user, $this->pass);
        
        $stream = ssh2_exec($connection, 'export');
        stream_set_blocking($stream, true);
        $stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO);
        return stream_get_contents($stream_out);

@matracine oh, pretty awesome solution, thanks! Ill begin with implementation today, after work.