%E4%B8%8A%E5%82%B3%E7%9A%84%E6%AA%94%E6%A1%88%E7%BE%A4%E7%B5%84.png)
我正在使用 vsftpd 創建一個 ftp 伺服器,我幾乎完成了,唯一剩下的就是當我上傳檔案(以用戶 U 身份登入)時,該檔案屬於具有相同名稱的群組(因此群組名稱= U),但用戶位於不同的組別。
我們舉個例子:
使用者=publichttp
usergroup=ftpusers(且只有 1 個群組)
當我上傳文件時,文件按照我想要的那樣以 775 權限上傳,但是 ls -l 顯示文件所有者是 publichttp:publichttp 而不是 publichttp:ftpusers,因為它應該是和我想要的。
/home/ 中的資料夾權限:
drwxrwxr-x 3 publichttp ftpusers 4096 nov. 8 17:20 publichttp
在 /home/publichttp/ 中:
-rwxrwxr-x 1 publichttp publichttp 98789 nov. 8 17:20 Extras.Txt
(我想)
-rwxrwxr-x 1 publichttp ftpusers 98789 nov. 8 17:20 Extras.Txt
不知道怎麼辦,查了一整天
vsftpd.conf:
listen=YES
connect_from_port_20=YES
use_localtime=YES
xferlog_enable=YES
dirmessage_enable=YES
ftpd_banner=myftp.
anonymous_enable=NO
local_enable=YES
write_enable=YES
nopriv_user=publichttp
secure_chroot_dir=/var/run/vsftpd/empty
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list #empty file
allow_writeable_chroot=YES
userlist_enable=YES
userlist_deny=NO
userlist_file=/etc/vsftpd.user_list #just contains publichttp
anon_upload_enable=YES
anon_mkdir_write_enable=YES
local_umask=002
file_open_mode=0777
是否可以 ? (最簡單的解決方案是最好的)
謝謝 !
答案1
vsftpd 從 /etc/passwd 和 /etc/groups 取得本機使用者的所有資訊。為了讓你的publichttp使用者上傳的檔案屬於ftpusers群組,你需要在/etc/passwd中將publichttp使用者的主gid設定為ftpusers群組。