Thursday, May 5, 2022

[SOLVED] Chown directory via SSH on server using NPM script

Issue

I am trying to chown a directory via an NPM script. The script looks like the following:

chown -R 755 www-data [email protected]:/var/www/test.com

But the message I get back is: chown: www-data: No such file or directory even though this exists. Any ideas much appreciated.


Solution

chown operates locally, not on remote servers. In your example, chown is attempting to operate on ./www-data and ./[email protected]:/var/www/test.com, which don't exist in the directory of wherever you were when you executed the command.

You will need to execute chown as a command through ssh:

ssh [email protected] chmod -R 755 /var/www/test.com/



Answered By - JoshuaRLi
Answer Checked By - Senaida (WPSolving Volunteer)