如何vsftp限制ip地址访问vsftp用户不能改变目录到上级目录

vsftpd无法改变虚拟用户的根目录问题 - ITeye问答
当我只使用本地用户的时候,可以改变根目录;但是当我使用虚拟用户的时候,不管怎么设置(使用或者不使用chroot_list_enable都一样),都不能改变虚拟用户的根目录。搞了2天,实在搞不出来,希望高手给予帮助。谢谢
附上vsftpd.conf文件:
# Example config file /etc/vsftpd/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
#anonymous_enable=YES
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# The target log file can be vsftpd_log_file or xferlog_file.
# This depends on setting xferlog_std_format parameter
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# The name of log file when xferlog_enable=YES and xferlog_std_format=YES
# WARNING - changing this filename affects /etc/logrotate.d/vsftpd.log
#xferlog_file=/var/log/xferlog
#
# Switches between logging into vsftpd_log_file and xferlog_file files.
# NO writes to vsftpd_log_file, YES to xferlog_file
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
#idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to blah FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd/banned_emails
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
#chroot_list_enable=YES
# (default follows)
#chroot_list_file=/etc/vsftpd/chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd whith two configuration files.
# Make sure, that one of the listen options is commented !!
#listen_ipv6=YES
guest_enable=yes
guest_username=virtual
pam_service_name=vsftpd.vu
user_config_dir=/etc/vsftpd/user_conf
#userlist_enable=YES
tcp_wrappers=YES
问题补充:baikunhu 写道配置vsftp 虚拟用户
1.生成虚拟用户口令库文件。为了建立此口令库文件,先要生成一个文本文件。该文件
的格式如下,单数行为用户名,偶数行为口令:
#vi account.txt
ylg
1234
zhanghong
4321
gou
5678
2.生成口令库文件,并修改其权限:
#db_load -T -t hash -f ./account.txt /etc/account.db
#chmod 600 /etc/account.db
3.新建一个虚拟用户的PAM文件。加上如下两行内容:
#vi /etc/pam.d/vsftp.vu
auth required /lib/security/pam_userdb.so db=/etc/account
account required /lib/security/pam_userdb.so db=/etc/account
4.建立虚拟用户,设置该用户所要访问的目录,并设置虚拟用户访问的权限:
#useradd -d /ftpsite virtual_user
#chmod 700 /ftpsite
经过该步骤的设置,/ftpsite就是virtual_user用户的主目录,该用户也是/ftpsite目录
的拥有者。除root用户之外,只有该用户具有对该目录的读、写和执行的权限。
5.生成一个测试文件。先切换至virtual_user用户身份,然后在/ftpsite目录下创建一
个文件:
#su -virtual_user
$vi /ftpsite/mytest
This is a
test
file.
$su - root
6.编辑/etc/vsftpd.conf文件,使其整个文件内容如下所示(去掉了注释内容):
anonymous_enable=NO
local_enable=YES
local_umask=022
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
write_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
one_process_model=NO
chroot_local_user=YES
ftpd_banner=Welcom to my FTP server.
anon_world_readable_only=NO
guest_enable=YES
guest_username=virtual_user
pam_service_name=vsftp.vu
上面代码中,guest_enable=YES表示启用虚拟用户;guest_username=virtual则是将虚拟
用户映射为本地用户,这样虚拟用户登录后才能进入本地用户virtual的目录/ftpsite;
pam_service_name=vsftp.vu指定PAM的配置文件为vsftp.vu。
非常感谢您的回答,我的操作跟你的几乎一样。每一步骤的意思我都很清楚,之前搭建过一个vsftpd是成功的,这次就有这么点瑕疵。还在探索原因中、
配置vsftp 虚拟用户
1.生成虚拟用户口令库文件。为了建立此口令库文件,先要生成一个文本文件。该文件
的格式如下,单数行为用户名,偶数行为口令:
#vi account.txt
ylg
1234
zhanghong
4321
gou
5678
2.生成口令库文件,并修改其权限:
#db_load -T -t hash -f ./account.txt /etc/account.db
#chmod 600 /etc/account.db
3.新建一个虚拟用户的PAM文件。加上如下两行内容:
#vi /etc/pam.d/vsftp.vu
auth required /lib/security/pam_userdb.so db=/etc/account
account required /lib/security/pam_userdb.so db=/etc/account
4.建立虚拟用户,设置该用户所要访问的目录,并设置虚拟用户访问的权限:
#useradd -d /ftpsite virtual_user
#chmod 700 /ftpsite
经过该步骤的设置,/ftpsite就是virtual_user用户的主目录,该用户也是/ftpsite目录
的拥有者。除root用户之外,只有该用户具有对该目录的读、写和执行的权限。
5.生成一个测试文件。先切换至virtual_user用户身份,然后在/ftpsite目录下创建一
个文件:
#su -virtual_user
$vi /ftpsite/mytest
This is a
test
file.
$su - root
6.编辑/etc/vsftpd.conf文件,使其整个文件内容如下所示(去掉了注释内容):
anonymous_enable=NO
local_enable=YES
local_umask=022
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=YES
write_enable=YES
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
one_process_model=NO
chroot_local_user=YES
ftpd_banner=Welcom to my FTP server.
anon_world_readable_only=NO
guest_enable=YES
guest_username=virtual_user
pam_service_name=vsftp.vu
上面代码中,guest_enable=YES表示启用虚拟用户;guest_username=virtual则是将虚拟
用户映射为本地用户,这样虚拟用户登录后才能进入本地用户virtual的目录/ftpsite;
pam_service_name=vsftp.vu指定PAM的配置文件为vsftp.vu。
已解决问题
未解决问题vsftpd添加用户并限制目录及指定用户访问指定目录(2) - Ftp服务器 - 编程入门网
vsftpd添加用户并限制目录及指定用户访问指定目录(2)
2. 开启匿名FTP服务器上传权限
在配置文件中添加以下的信息即可:
Anon_upload_enable=yes (开放上传权限)
Anon_mkdir_write_enable=yes (可创建目录的同时可以在此目录中上传文件)
Write_enable=yes (开放本地用户写的权限)
Anon_other_write_enable=yes (匿名帐号可以有删除的权限)
3. 开启匿名服务器下传的权限
在配置文件中添加如下信息即可:
Anon_world_readable_only=no
注:要注意文件夹的属性,匿名帐户是其它(other)用户要开启它的读写执行的权限
(R)读&&下传 (W)写&-上传 (X)执行&-如果不开FTP的目录都进不去
4.普通用户FTP服务器的连接(独立服务器)
在配置文件中添加如下信息即可:
Local_enble=yes (本地帐户能够登陆)
Write_enable=no (本地帐户登陆后无权删除和修改文件)
功能:可以用本地帐户登陆vsftpd服务器,有下载上传的权限
注:在禁止匿名登陆的信息后匿名服务器照样可以登陆但不可以上传下传
5. 用户登陆限制进其它的目录,只能进它的主目录
设置所有的本地用户都执行chroot
Chroot_local_user=yes (本地所有帐户都只能在自家目录)
设置指定用户执行chroot
Chroot_list_enable=yes (文件中的名单可以调用)
Chroot_list_file=/任意指定的路径/vsftpd.chroot_list
注意:vsftpd.chroot_list 是没有创建的需要自己添加,要想控制帐号就直接在文件中加帐号即可
6. 限制本地用户访问FTP
Userlist_enable=yes (用userlistlai 来限制用户访问)
Userlist_deny=no (名单中的人不允许访问)
Userlist_file=/指定文件存放的路径/ (文件放置的路径)
注:开启userlist_enable=yes匿名帐号不能登陆
7. 安全选项
Idle_session_timeout=600(秒) (用户会话空闲后10分钟)
Data_connection_timeout=120(秒) (将数据连接空闲2分钟断)
Accept_timeout=60(秒) (将客户端空闲1分钟后断)
Connect_timeout=60(秒) (中断1分钟后又重新连接)
Local_max_rate=50000(bite) (本地用户传输率50K)
Anon_max_rate=30000(bite) (匿名用户传输率30K)
Pasv_min_port=50000 (将客户端的数据连接端口改在
Pasv_max_port=&60000之间)
Max_clients=200 (FTP的最大连接数)
Max_per_ip=4 (每IP的最大连接数)
Listen_port=5555 (从5555端口进行数据连接)
8. 查看谁登陆了FTP,并杀死它的进程
ps &xf |grep ftp
kill 进程号
本文出自 &Tuesday& 博客,请务必保留此出处http://cuimk./6637vsftp限制用户改变目录到上级_百度文库
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
vsftp限制用户改变目录到上级
上传于||暂无简介
你可能喜欢你的位置: >
> centos中vsftp修改默认路径
如果是默认安装vsftpd的话,以下是一些文件的位置约定:
/usr/sbin/vsftpd —- VSFTPD的主程序
/etc/rc.d/init.d/vsftpd —- 启动脚本
/etc/vsftpd/vsftpd.conf —- 主配置文件
/etc/pam.d/vsftpd —- PAM认证文件
/etc/vsftpd.ftpusers —- 禁止使用VSFTPD的用户列表文件
/etc/vsftpd.user_list —- 禁止或允许使用VSFTPD的用户列表文件
/var/ftp —- 匿名用户主目录
/var/ftp/pub —- 匿名用户的下载目录
如果要更改默认下载目录,修改/etc/vsftpd/vsftpd.conf,加入如下三行:
local_root=/
chroot_local_user=YES
anon_root=/
local_root表示使用本地用户登录到ftp时的默认目录
anon_root表示匿名用户登录到ftp时的默认目录
你上面的chroot_list_file是设定锁定登陆用户在其home目录的列表,要在chroot_list_enable=YES情况下才生效。
另外,如luo_rc所述,最好不要设置默认目录为/,使用建议使用mount –bind来挂载需要的目录。
转载请注明: &
与本文相关的文章

我要回帖

更多关于 vsftp 目录权限 的文章

 

随机推荐