views:

215

answers:

1

Hi,

I'm uploading one file from one server to other using ssh2_scp_send().

Everything works fine, the only problem is that I don't know how to change the owner and the group of the file after finishig the upload.

How can I preform some kind of chown in the ssh2

+2  A: 

Hi,

Maybe you can do that with the ssh2_exec function, which seems to allow running an arbitrary command on the server you're connected to.
That command could be the chown you're trying to execute.

The example from the doc says :

$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');

$stream = ssh2_exec($connection, '/usr/local/bin/php -i');

Replacing that "/usr/local/bin/php -i" with your "chown user.group filename" might do.

Pascal MARTIN