Webserver : cannot create folder through FTP

NethServer Version: 7.6
Module: webserver


I activated the FTP server for the “default" vhost in the NS Gui and logged in successfully using a FTP client, in the /var/www/html folder as expected.

There is a problem however : the FTP user cannot create a folder. I guess that’s a permission problem, but is this expected ?

Wed Jun  5 09:41:18 2019 [pid 18645] [default] OK LOGIN: Client "xxx"                                                    │
Wed Jun  5 09:41:29 2019 [pid 18647] [default] FAIL MKDIR: Client "xxx", "/test"                                         │

More info :

# ls -lai /var/www/    
total 16
1312016 drwxr-xr-x  4 root root 4096 Jun  4 10:34 .
1310721 drwxr-xr-x 21 root root 4096 Jun  4 13:51 ..
1312017 drwxr-xr-x  2 root root 4096 Apr 24 13:46 cgi-bin
1312018 drwxr-xr-x  6 root root 4096 Jun  5 08:56 html

Yes. Permissions to parent directory are not changed for security reasons (and respect upstream defaults).
You should change the permissions manually or change the directory owner.

Txs @Giacomo. It looked a bit to obvious to be a bug :slight_smile:

Any pointer to help me do that correctly ? I’m new to web hosting and I don’t want to do something stupid.

Maybe I should create a vhost (It works with vhosts) ? But how to make it handle the www.domain.tld and the domain.tld adresses ? Or forget about FTP ? Wordpress seems to depend on it (locally) to install modules.

I ended up by trial and error to set /var/www/html and all subfolders to 775 and changed the owner of all files and folders to root:ftp. Files rights are set to 644. Now it seems to be working as expected.

I’m really not sure of the security issues it could create. Could anybody advice me ?

Hi pagaille,

WordPress takes care of downloading files and doesn’t need FTP from the system.

Also, if the html folder (or vhost folder) has ftp:apache as owner:group, you will be able to update extensions but not WordPress itself. User other doesn’t need any right at all.

 chown apache:apache /var/www/html
 cd /var/www/html
 #### for vhosts:
 #### cd /var/lib/nethserver/vhost/
  find . -type f -exec chmod 2640 {} \;
 find . -type d -exec chmod 2750 {} \;
 chown -R apache:apache *
 chown -R apache:apache .*

If WordPress complains about not finding wp-content, add these lines at the end of wp-config.php:

 add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
 define( 'FS_CHMOD_DIR', 0751 );

Ref: https://juliencrego.com/wordpress-impossible-de-localiser-le-repertoire-de-contenu/



Maybe this is the safest choice.

But you could safely go with the default vhost.

It should be ok :slight_smile:

1 Like

That definitely did it @michelandre ! Txs !!