Bad*_*ari 44 chroot ftp account-restrictions vsftpd
我在我的 linux (rasbian) 上运行 vsftpd 作为 ftp 服务器,我以 root 用户身份登录到机器。
我想仍然只能使用 /var/www,我该如何配置 vsftpd conf 来完成它?
Rah*_*til 66
确保存在以下行
chroot_local_user=YES
Run Code Online (Sandbox Code Playgroud)
将用户 HOME 目录设置为/var/www/,如果要更改现有用户,则可以使用:
usermod --home /var/www/ username
Run Code Online (Sandbox Code Playgroud)
然后设置所需的权限 /var/www/
user_sub_token如果您不想更改用户的主目录,则可以使用:
chroot_local_user=YES
local_root=/ftphome/$USER
user_sub_token=$USER
Run Code Online (Sandbox Code Playgroud)
user_sub_token:根据模板为每个虚拟用户自动生成主目录。例如,如果通过guest_username指定的真实用户的家目录是/ftphome/$USER,并且user_sub_token设置为$USER,那么当虚拟用户test登录时,他最终会(通常是chroot()ed)在目录/ftphome/test。如果 local_root 包含 user_sub_token,此选项也会生效。
创建目录并设置权限:
mkdir -p /ftphome/{test,user1,user2}
chmod 770 -R /ftphome
chown -R ftp. /ftphome
usermod -G ftp test
Run Code Online (Sandbox Code Playgroud)
一旦重新启动vsftpd并测试您的设置。
示例成功输出:
[root@mail tmp]# ftp localhost
Connected to mail.linuxian.local.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): test
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> mput vhosts
mput vhosts?
227 Entering Passive Mode (127,0,0,1,146,41)
150 Ok to send data.
226 File receive OK.
24 bytes sent in 3.3e-05 seconds (7.1e+02 Kbytes/s)
ftp> ls -rlt
227 Entering Passive Mode (127,0,0,1,97,90)
150 Here comes the directory listing.
-rw-r--r-- 1 787 787 24 Oct 11 19:57 vhosts
226 Directory send OK.
ftp> 221 Goodbye.
Run Code Online (Sandbox Code Playgroud)