Apache、组权限和用户上传

Rya*_*iss 5 ftp permissions centos group apache-httpd

我有一个名为“digitalgoods”的文件夹,其所有权如下——apache:apache 位于 htdocs 文件夹之外,因此公众无法访问。但是,我需要一组用户(Jack、John、James)可以访问同一个文件夹——我们将它们统称为“上传者”。

我希望“上传者”能够尽可能轻松地将每个文件上传到“digitalgoods”文件夹,然后 apache 可以通过购买访问服务。

我的问题是设置它的最佳方法是什么?我目前正在使用 SSH 访问服务器,但是为用户安装 ftp 服务器以获得访问权限是否更有意义?如果是这样,我应该如何处理帐户和权限?或者我应该将每个用户的主目录设置为“digitalgoods”并以某种方式适当地修改权限以通过 SSH 访问?

我试图让客户端尽可能轻松地上传文件。在这方面的任何帮助表示赞赏。

小智 3

有 2 种解决方案使用 2 个不同的 ftp 服务器

\n\n

1 - 将 proftpd 与 VirtualServer 功能和本地用户强制结合使用。我的配置文件的片段:

\n\n
ServerType standalone\nDefaultServer on\nAccessGrantMsg "User %u logged in."\nDeferWelcome off\n\n# Use pam to authenticate (default) and be authoritative\nAuthPAMConfig proftpd\nAuthOrder mod_auth_pam.c* mod_auth_unix.c\n\n\n<VirtualHost xxx.xxx.xxx.xxx>\nServerAdmin nwildner@xxx.xxx.xxx.xxx\nServerName  "FTP"\nTransferLog /var/log/proftpd/transfer.log\nExtendedLog /var/log/proftpd/full.log ALL\nDefaultRoot /var/www/digitalgoods\nUser                    apache\nGroup                   apache\nAllowOverwrite          yes\nMaxLoginAttempts        3\nRequireValidShell       no\n</VirtualHost>\n
Run Code Online (Sandbox Code Playgroud)\n\n

创建3个用户,并让他们使用ftp。他们将被“chroot”到/var/www/digitalgoods并且上传的任何文件都将具有权限设置为apache:apache

\n\n

2 - 使用 vsftpd chroot,并创建 3 个用户,其用户 ID 与 apache 相同,并且主目录将被 chroot(是的,\xc2\xb4s 是一个拼凑,但它应该可以工作):

\n\n

内容/etc/vsftpd/vsftpd.conf

\n\n
anonymous_enable=NO\nlocal_enable=YES\nwrite_enable=YES\nlocal_umask=022\nanon_upload_enable=NO\nanon_mkdir_write_enable=NO\ndirmessage_enable=YES\ncheck_shell=NO\nsyslog_enable=YES\nconnect_from_port_20=YES\nxferlog_std_format=NO\nidle_session_timeout=3600\nftpd_banner=FTP XXX\nchroot_local_user=YES\nls_recurse_enable=YES\nlisten=YES\npam_service_name=vsftpd\nuserlist_enable=NO\nuserlist_deny=NO\ntcp_wrappers=YES\n
Run Code Online (Sandbox Code Playgroud)\n\n

由于我们使用的是最小权限,因此我们必须声明将访问此 ftp 的登录名:/etc/vsftpd/user_list

\n\n
# vsftpd userlist\n# If userlist_deny=NO, only allow users in this file\n# If userlist_deny=YES (default), never allow users in this file, and\n# do not even prompt for a password.\n# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers\n# for users that are denied.\n#\ndevel\nmanuals\n
Run Code Online (Sandbox Code Playgroud)\n\n

创建 2 个用户 ( /etc/passwd) 并使用 apache 用户的相同用户 ID(同样,这是一个该死的拼凑,但至少你将有 2 个用户以相同的权限上传到他们的 chrooted 主页)。随着check_shell=NO您\xc2\xb4t 不需要为这些用户提供有效的shell

\n\n
[root@]# grep \'apache\\|desenv\\|man\\|\' /etc/passwd\napache:x:48:48:Apache:/var/www:/sbin/nologin\ndevel:x:48:48::/var/www/digitalgoods:/sbin/nologin\nmanuals:x:48:48::/var/www/digitalgoods:/sbin/nologin\n
Run Code Online (Sandbox Code Playgroud)\n