I have a local network behind a router, so addresses are like 192.168.1.xxx. I need php to get files from other systems in that network. Looked into php ssh but (1) it's way beyond my skill level and (2) ssh_connect is not available on my installation. I can do it with command line scp, but not php. Is there something easier for a newbie to understand, using php, to get/put files between local systems?
CodePudding user response:
you can try exec()
/ shell_exec
to execute shell script
https://www.php.net/manual/en/function.exec.php
https://www.php.net/manual/en/function.shell-exec.php
CodePudding user response:
First i though that you can use PHP Functions: shell_exec()
shell_exec('/path/to/ssh [email protected] /home/yourdirectory/scripts/StartTest.sh');
https://www.php.net/manual/de/function.shell-exec.php
Update You can use this lib: https://github.com/phpseclib/phpseclib/blob/master/phpseclib/Net/SSH2.php https://stackoverflow.com/a/7749185/14807111
<?php
include('Net/SSH2.php');
$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
exit('Login Failed');
}
echo $ssh->exec('pwd');
echo $ssh->exec('ls -la');
?>