-1

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?

IMSoP
  • 89,526
  • 13
  • 117
  • 169
thebugbear
  • 9
  • 1
  • 3

2 Answers2

1

First i though that you can use PHP Functions: shell_exec()

shell_exec('/path/to/ssh root@192.162.0.5 /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');
?>

Source: https://stackoverflow.com/a/7749185/14807111

Maik Lowrey
  • 15,957
  • 6
  • 40
  • 79
0

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

mending3
  • 586
  • 7
  • 21