vsftp服务
来源:互联网 发布:mp3音频剪辑软件 编辑:程序博客网 时间:2024/05/17 12:20
1、主要的配置文件:
/etc/vsftpd/vsftpd.conf
用户控制列表文件
- 1:/etc/vsftpd/ftpusers(黑名单)
- 2:/etc/vsftpd/user-list(是黑名单,但是也可以反转为白名单)
2、FTP相关用户:
- 匿名用户
- annoymous或者是ftp(大多是的ftp服务会禁用匿名用户)
- 本地用户
- 使用liunx系统用户和密码(用的是添加系统用户的useradd和passwd命令)
- 虚拟用户
- 管理员自己定义的模拟用户,相对来说是最安全的
3、注意事项
1. 关闭防火墙
- 1.setup工具(注意只有在centos里面才会有这样的工具)
- 2.使用iptables -L
2.关闭selinux
vi /etc/selinux/config
使里面的SELINUX=disabled
使用setstate查看selinux的状态。
关闭setenforce为0就是关闭
4、配置文件的具体的信息
## 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.# 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(文件上传的权限是644,目录是755)# # Uncomment this to allow the anonymous FTP user to upload files. This only# 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 parameterxferlog_enable=YES(使用标准的ftp日志的格式)## Make sure PORT transfer connections originate from port 20 (ftp-data).connect_from_port_20=YES(主动的方式去连接,端口为20)## 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_filexferlog_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_local_user=YES#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 with two configuration files.# Make sure, that one of the listen options is commented !!#listen_ipv6=YESpam_service_name=vsftpd(ftp采用的是pam验证,也就是默认的用户名和密码进行验证)userlist_enable=YES(用户登陆限制)tcp_wrappers=YES
4.1设置全局配置
- listen_address=192.168.0.1设置监听的ip
- liten_port=21设置默认监听ftp服务的端口
- download_enable=YES是否允许下载文件
- max_client=100限制客户端的并发连接的数量
- max_per_ip=3限制同一个ip连接的数量
4.2设置被动的访问模式
- pasv_anable=YES开启被动
- pasv_min_port=24500被动模式的最小的端口
- pasv_max_port=24600最大的端口
4.3常用的安全配置
- accept_timeout=60被动模式的安全超时时间
- connect_timeoout=60主动模式的安全的超市时间
- idle_session_timeout=600会话的最大的连接的时间
- data_connection_time=500是说如果传输的时候超过了600秒就会自动挡的断开
5、客户端的使用
5.1 ftp IP
- -help获取帮助
- -get下载
- -mget下载一批文件
- -put上传
- -mput上传一批文件
-exit退出
windows下载的位置到为c:\User\huanghe目录下面
- linux是/home/lm
- get和put命令的弊端是不能下载和上传目录,和断点续传;只能进行文件的上传和下载
5.2 在windows的对话框
- 同样的不识别断点续传
5.3使用工具winscp进行登陆
- 用这个登陆存在的问题是我们一定要把用户限制在根目录下面
6、匿名用户进行访问
6.1匿名用户的配置文件
- anonmous_able=YES允许匿名用户进行访问
- anon_upload_enable=YES允许匿名用户进行上传
- anon_mkdir_write_enable=YES允许匿名用户新建目录
- anon_umask=600默认上传的权限
- 匿名用户不能向上切换目录,实际登陆的位置是在/var/ftp/下面
- 文件的上传和下载,不仅仅是取决于配置文件的内容,而且还取决于文件的系统权限
- 注意不要把目录的文件的权限改成777 chomd 777 /var/ftp
- 可以更改所有者chmod ftp /var/ftp/
- 最好的是改pub的权限chmod ftp pub/
- vsftp服务的为用户是ftp用户
7、本地用户访问
7.1本地用户访问的基本配置
- local_enable=YES允许本地用户进行登陆
- write_enable=YES
- local_umask=022本地上传的umask值
- local_root=/tmp/lm_root设置指定本地用户的登陆位置(需要手动添加上去)不能分辨不同的用户,对所有的用户都是进入到同一个目录里面去了
- local_max_rate=0限制最大的传输速率
- 需要服务权限和系统的权限都允许才可以进行文件的上传
- 创建用户组groupadd tg
- gpasswd -a test1 tg
- gpasswd -a test2 tg
- chown root:tg /tmp/test1_root/
- chmod 775 /tmp/test1_root/
- chroot_local_user=YES开启用户目录限制(把所有的用户目录限制在家目录中)如果只有这句就是限制在家目录下
- chroot_list_enable=YES
- chroot_list_file=/etc/vsftpd/chroot_list
- 写入/etc/vsftpd/chroot_list的文件中的用户可以访问任意的目录,其他的用户限制在用户的主目录中
7.2用户访问控制
userlist_enable=YES开启用户访问控制,系统默认就是这样的
userlist_deny=YES
Userlist_file=/etc/vsftpd/user_list,
写入/etc/vsftpd/user_list,的用户不能访问ftp服务器,没有写入的用户可以访问(默认就是这样的)
- userlise_deny=NO就是相反的,把黑名单转化为了白名单
8、虚拟用户访问设置
8.1、配置虚拟用户访问
- 1添加虚拟用户口令文件
- vi /etc/vsftpd/vuser.txt
- cangls #用户名
- 123#密码
- bols#用户名
- 123#密码
- 2生成虚拟用户口令认证文件
- yum -y install db4-utils
- #如果没有安装口令认证命令,需要安装
- db_load -T -t hash -f /etc/vsftpd/vuser.txt
- /etc/vsftpd/vuser.db
- #把文本文档转变为认证的数据库
- 3编辑vsftpd的PAM认证文件
- vi /etc/pam.d/vsftpd
- auth required /lib/security/pam_userdb.so db=/etc/vsftpd/vuser
- account required /lib/security/pam_userdb.so db=/etc/vsftpd/vuser
- #注释掉其他的行,加入这两行即可
- #注释掉这两行可以禁止本地用户登陆,因为本地用户也要依赖这两行的这个文件
- 4建立本地映射用户并设置宿主目录权限
- useradd -d /home/vftproot -s /sbin/nologin vuser
- #此用户不需要登陆,只是映射用户
- # 用户名必须和下一步配置文件中一致
- chmod 755 /home/vftproot
- 5修改配置文件
- vi /etc/vsftpd/vsftpd.conf
- guest_enable=YES
- #开启虚拟用户
- guest_username=vuser
- #FTP虚拟用户对应的系统用户
- pam_service_name=vsftpd
- #PAM认证文件(默认是存在的)
- 6重启vsftpd服务,并测设
- 虚拟用户可以登陆,查看,能下载,不能上传
- 默认上传文件的位置是宿主用户的家目录
- 权限使用的是匿名用户的权限进行管理的
- 虚拟用户进入的是/home/vsftpd/目录里面
- 7调整虚拟用户的权限
- anonymous_enable=NO
- #关闭匿名用户登陆,更加安全(不影响虚拟用户)
- 下面的是默认的配置文件,每一个文件都可以支持上传,如果想要单独的设置每一个用户的权限则需要参考8.2虚拟用户的访问设置
- anon_upload_enable=YES
- anon_mkdir_write_enable=YES
- anon_other_write_enable=YES
- #给虚拟用户设定权限,允许所以的虚拟用户上传
8.2虚拟用户访问
为每个虚拟用户配置自己的虚拟文件,单独的设置文件的权限
- 关闭
- #anon_upload_enable=YES
- #anon_mkdir_write_enable=YES
- #anon_other_write_enable=YES
- 1.修改配置文件
- vi /etc/vsftpd/vsftpd.conf
- user_config_dir=/etc/vsftpd/vusers_dir
- #指定保存虚拟用户配置文件的目录
- 2.手工建立目录
- mkdir /etc/vsftpd/vusers_dir
- 3.为每个用户建立配置文件
- vi /etc/vsftpd/vusers_dir/cangls
- anon_upload_enable=YES
- anon_mkdir_write_enable=YES
- anon_other_write_enable=YES
- #允许此用户上传
- local_root=/tmp/vcangls
- #给cangls指定独立的上传目录
- 4.建立上传目录
- mkdir /tmp/vcangls
- chown vuser:vuser /tmp/vcangls/
- vsftp服务
- vsftp服务
- VSFTP服务
- VSFTP服务
- vsftp服务
- VSFTP 服务使用
- 重启vsftp服务
- ubuntu 安装 vsftp服务
- 直接启动VSFTP 服务
- 如何启动vsftp服务
- ubuntu 安装 vsftp服务
- ubuntu 安装 vsftp服务 .
- Linux服务-vsftp
- vsftp服务搭建
- vsftp服务搭建
- 服务篇一---vsftp服务
- linux下的vsftp服务
- Linux下的vsftp服务
- 【JVM实用参数】(二)参数分类和即时(JIT)编译器诊断
- Ubuntu14.04配置opencv2.4.11开发环境
- 回眸总结linux的启动过程
- 透过ATS缓存配置看如何判断HTTP资源是否可缓存方法论
- 说说为什么要有CNAME
- vsftp服务
- ATS代理缓存工作机制流程图(自画)
- 调整ATS日志处理机制及相关脚本
- ATS巧玩儿缓存策略增加动态服务吞吐量
- shell脚本——linux主机监控
- shell脚本——爬取域名一级页面元素并判断其可缓存性
- linux下PXE无人值守环境自动安装脚本
- 栈输入月份输出月份
- mysql互主自动化配置脚本