Make SSH connections to other hosts and issue commands to the shell. You can also connect to one device and use that to connect to another. e.g. ssh to a linux server, use that shell to connect to a routerOS device. Then use the second device to connect to a third device (linux or routeros) and so on
You can execute any command you want. There is full parity with the underlying shells
composer require merlinthemagic/mtm-ssh
$ctrlObj = \MTM\SSH\Factories::getShells()->passwordAuthentication("IpAddress", "username", "password");
$username = \MTM\SSH\Factories::getShells()->getRouterOsTool()->getFormattedUsername("username");
$ctrlObj = \MTM\SSH\Factories::getShells()->passwordAuthentication("IpAddress", $username, "password");
$key = "-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgk.....
....S8dBQ==
-----END PRIVATE KEY-----";
$ctrlObj = \MTM\SSH\Factories::getShells()->keyAuthentication("IpAddress", "username", $key);
$key = "-----BEGIN PRIVATE KEY-----
MIIEvAIBBDANBgk.....
....S8dBQ==
-----END PRIVATE KEY-----";
$username = \MTM\SSH\Factories::getShells()->getRouterOsTool()->getFormattedUsername("username");
$ctrlObj = \MTM\SSH\Factories::getShells()->keyAuthentication("IpAddress", $username, $key);
//no public key auth yet
$ctrlObj2 = \MTM\SSH\Factories::getShells()->passwordAuthentication("IpAddress", "username", "password", $ctrlObj);
//NOTE: Both existing shell ($ctrlObj) and built on shell ($ctrlObj2) will execute on the second host
//no public key auth yet
$username = \MTM\SSH\Factories::getShells()->getRouterOsTool()->getFormattedUsername("username");
$ctrlObj2 = \MTM\SSH\Factories::getShells()->passwordAuthentication("IpAddress", $username, "password", $ctrlObj);
//NOTE: Both existing shell ($ctrlObj) and built on shell ($ctrlObj2) will execute on the second host
$data = $ctrlObj->getCmd("whoami")->exec()->get();
echo $data; //the name of the user you connected with
$ctrlObj->getCmd("cd /var")->exec()->get();
$data = $ctrlObj->getCmd("ls -sho --color=none")->exec()->get();
echo $data; //directory and file listing from /var
NOTE: Disable all echo logging on the device or return might get corrupted if a log message echos into the shell while running a command
$data = $ctrlObj->getCmd("/system resource print")->exec()->get();
echo $data; //list of system resources
$data = $ctrlObj->getCmd("/interface print")->exec()->get();
echo $data; //list of interfaces