【问题标题】:FTP upload wrong permissionsFTP上传权限错误
【发布时间】:2017-07-16 06:53:24
【问题描述】:

将“youri”添加到 www-data 组

grep youri /etc/group

www-data:x:33:youri
youri:x:1004:

当我用 FTP 上传东西时,文件权限是-rw-------

ls -all

total 176
drwxr-xr-x 2 youri youri   4096 feb 25 12:38 .
dr-xr-xr-x 3 youri youri   4096 feb 25 12:08 ..
-rw-r--r-- 1 youri youri     17 feb 25 12:27 index.php
-rw------- 1 youri youri 164655 feb 25 12:24 test.pdf (uploaded with FTP)

文件index.php由nano创建,修改权限为sudo chown youri:youri index.php

当我访问我的网站时,它会显示 index.php 但 /test.pdf 给我一个“权限被拒绝”错误

【问题讨论】:

    标签: linux ubuntu nginx permissions ftp


    【解决方案1】:

    您的网络服务器无权读取该文件。

    通常,ftp 服务器有一个名为“umask”的配置值,该值定义不授予的权限(您将赋予 chmod 的值的二进制倒数)

    为了更好的安全性,大多数 ftp 服务器(如 vsftp)都附带默认 umask 055 或 077

    如您所见,您的 index.php 不可执行。尽管从技术上讲它只是读取,但从语义上讲,脚本正在由您的网络服务器执行。并且网络服务器以用户 www-data 的身份运行。

    要进行这项工作,请更改以下内容:

    - Make youri's default group www-data: usermod -g www-data youri
    - Change /etc/vsftpd.conf and set a umask of 022
    - Restart vsftpd
    - chmod 755 index.php (or delete it and upload it again)
    

    【讨论】:

    • 修改默认组为www-data,设置local_umask为022并重启vsftpd,上传后权限为:--w----r--
    • 奇怪的行为。一些问题:1.您是否提前删除了文件? 2. 文件现在是否归 youri:www-data 所有? 3. 手动chmod index.php 会发生什么?
    • 在 chmod 755 之后它可以工作,但我不想每次都 chmod? @Psi
    • --w------- 1 youri www-data 16 feb 25 13:03 index.php
    • 正在尝试使用 file_open_mode=xxx 并且没有 file_open_mode 它现在可以工作。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-04
    • 1970-01-01
    • 2012-05-13
    • 2014-10-21
    • 1970-01-01
    • 2014-09-22
    相关资源
    最近更新 更多