Create a txt file with content on a remote location using PHP SSH2

207 views Asked by At

I try to create per PHP SSH2 an txt file with content.

This is the code I tried:

include('Net/SSH2.php');

$ssh = new Net_SSH2('MYIP');
if (!$ssh->login('root', 'MYPASS')) {
    exit('Login Failed');
}

if($ssh->exec('cd /var/test/')){
    echo $ssh->exec('sudo sh -c \'"text\r\ntest1\r\ntest2" > test.txt\'');
}

unset($ssh);

Is there any way to do that?

0

There are 0 answers