Some of the users getting this “permission denied error” while trying to connect the Google Cloud files via FTP. Our Google cloud support team will be available to assist you with any issues in Google Cloud Platform.
1. Identifying the Error
This permission denied error occurs when you trying to edit a file in GCP by using FTP. When you try to edit the file, you will see an error as below
Error: /etc/apache2/sites-available/wordpress.conf: open for write: permission denied/ Error: File transfer failed
The user getting permission denied error due to insufficient permission to edit the file wordpresss.conf file in GCP.
2. Connecting to VM Instance
To fix this insufficient permission issue you need to edit the file’s permission in Google Cloud. For this first you have to connect the VM instance via SSH terminal.
You can connect a VM instance in GCP by
GCP --> Compute Engine --> VM Instances --> you can see SSH option in the right side of the instance section.
Just click on SSH button to connect the instance via SSH terminal.
3. Check For File Permissions
In order to check the file permissions for the user run the below command in the terminal
stat -c "%a %n" /path to the file
In this scenario our file location is /etc/apache2/sites-available/wordpress.conf. So the command will be
stat -c "%a %n" /etc/apache2/sites-available/wordpress.conf
We can see that the output for this command from the above image that the permission for the file is set to be 644, due to this lack of permission the user got the permission denied error when tried to edit the file using FTP.
4. Changing the File Permission
In order to edit the file by the user, you need to change the file permission from 644 to 777. So that we can edit the file via FTP. To change the file permission to 777 run the below command in the terminal
chmod 777 /etc/apache2/sites-available/wordpress.conf
And finally restart the Apache service by running the below command
sudo service apache2 restart
For the users who are using the Bitnami Apache servers, you can use the below command
sudo /opt/bitnami/ctlscript.sh restart apache
Connect the FTP client again and retry to edit the file, now you will be able to edit the file successfully via FTP.
Kindly note, providing 777 full permission to a file is not recommended as it may have chances for security breach. So we recommend to use a edit the system files via SSH terminal itself.
If you need any assistance in editing files or making any changes in Google cloud instances, our technical team will be available anytime.