#cd /etc/yum.repos.d/
# rm -rf *
# wget http://docs.linuxtone.org/soft/lemp/CentOS-Base.repo
# yum clean all
# yum -y install vsftpd
1.关闭匿名用户登录
ftp支持匿名登录是不安全,所以要禁止匿名ftp登录
在/etc/vsftpd/vsftpd.conf修改以下三项
anonymous_enable=NO
#anon_upload_enable=YES (本来就是注释掉的,不需要改)
#anon_mkdir_write_enable=YES (本来就是注释掉的,不需要改)
[root@red-hat-5 ~]# service vsftpd restart
关闭vsftpd: [确定]
为vsftpd启动vsftpd: [确定]
2.创建一个系统用户来登录ftp
[root@red-hat-5 ~]# useradd -s /sbin/nologin viong
建设一个不能登录系统用户. 只用来登录ftp服务 ,这里如果没设置用户目录。默认是在home下
添加ftp用户(用户名:ftpuser ftp根目录/home/wwwroot/ftpuser)
<!--[if !supportLists]-->1. <!--[endif]-->useradd -d /home/wwwroot/ftpuser -g ftp -s /sbin/nologin ftpuser
3.加强vsftp安全设置
从以上可以看出ftp家目录存在安全漏洞,所以要修改以下设置:
(1)限制系统用户锁定在家目录
Vi /etc/vsftpd/vsftpd.conf
去掉前面#号
chroot_list_enable=YES (开启目录锁定选项,默认不锁定)
chroot_list_file=/etc/vsftpd/chroot_list (指定锁定目录的用户列表)
然后把所有用户加入/etc/vsftpd/chroot_list即可
[root@red-hat-5 ~]# ls /etc/vsftpd/ chroot_list
默认是不存在,需要我们手动建立
ftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh
[root@red-hat-5 ~]# touch /etc/vsftpd/chroot_list
[root@red-hat-5 ~]# cut -d : -f 1 /etc/passwd>>/etc/vsftpd/chroot_list
把本地用户都加入到chroot_list
cut命令是切去某一列,-d是每列的分隔符,-f 是切取第几列,然后重定向到chroot文件
[root@red-hat-5 ~]# ll /etc/vsftpd/
总计 24
-rw-r--r-- 1 root root 197 12-25 19:57 chroot_list
-rw--------1 root root 125 2007-12-13 ftpusers
ftpusers指的是阻止这个文件中的用户登陆
-rw------- 1 root root 361 2007-12-13 user_list
-rw------- 1 root root 4396 12-25 19:19 vsftpd.conf
-rwxr--r-- 1 root root 338 2007-12-13 vsftpd_conf_migrate.sh
(2)限制重要系统用户不能登录ftp权限
[root@red-hat-5 ~]# cat /etc/vsftpd/ftpusers
默认会加入一些比较重要系统用户
# Users that are not allowed to login via ftp
root
bin
daemon
adm
lp
sync
shutdown
halt
news
uucp
operator
games
nobody
ftpusers利用系统的pam模块阻止某一些用户登录
(3)利用ftp用户策略允许登录ftp的系统用户
系统添加一个用户也默认有ftp的登陆权限,是不安全,要一个个设置,有点繁琐。利用ftp用户策略解决这个问题,即user_list文件设置,只有user_list中存在的用户才能登录系统
修改配置文件:vi /etc/vsftpd/vsftpd.conf
在userlist_enable=YES文件后面添加
userlist_deny=NO
userlist_file=/etc/vsftpd/user_list
[root@red-hat-5 ~]# service vsftpd restart
关闭vsftpd: [确定]
为vsftpd启动vsftpd: [确定]
user_list使用介绍:
[root@hx10 vsftpd]# more user_list
# vsftpd userlist
# If userlist_deny=NO, only allow users in this file
# If userlist_deny=YES (default), never allow users in this file, and
# do not even prompt for a password.
# Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers
# for users that are denied.
表示:
userlist_deny=NO,那么/etc/vsftpd/user_list的用户才可以登录,需要把刚创建的帐号加入这个文件,当然还会阻止/etc/vsftpd/ftpusers的用户登录
userlist_deny=YES,那么/etc/vsftpd/user_list的用户不可以登录,即使设置密码
(4)设置登录ftp目标ip地址
为了让ftp更安全,我们设置ftp目标ip地址访问
C:\Users\Administrator>ipconfig 查看本地ip
...................................
以太网适配器 VMware Network Adapter VMnet1:6
连接特定的 DNS 后缀 . . . . . . . :
IPv4 地址 . . . . . . . . . . . . : 192.168.184.1
子网掩码 . . . . . . . . . . . . : 255.255.255.0
默认网关. . . . . . . . . . . . . :
只允许这个ip地址访问ftp ssh,可以写条iptable做限制.
如下:
[root@red-hat-5 ~]# iptables -A INPUT -p tcp -s 192.168.184.1 --dport 22 -j ACCEPT
允许192.168.184.1访问本地 22端口
[root@red-hat-5 ~]# iptables -A INPUT -p tcp -s 192.168.184.1 --dport 21 -j ACCEPT
允许192.168.184.1访问本地 21端口
[root@red-hat-5 ~]# iptables -A INPUT -p tcp -s 192.168.184.1 --dport 65341:65351 -j ACCEPT
允许192.168.184.1访问本地 PASV端口
[root@red-hat-5 ~]# iptables -P INPUT DROP 禁止任何输入的数据包
[root@red-hat-5 ~]# service iptables save 保存iptables设置
将当前规则保存到 /etc/sysconfig/iptables: [确定]
[root@red-hat-5 ~]# service iptables status 检查iptables的设置
表格:filter
Chain INPUT (policy DROP)
num target prot opt source destination
1 RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
2 ACCEPT tcp -- 192.168.184.1 0.0.0.0/0 tcp dpt:22
3 ACCEPT tcp -- 192.168.184.1 0.0.0.0/0 tcp dpt:21
4 ACCEPT tcp -192.168.184.1 0.0.0.0/0 tcp dpts:65341:65351
本文出自 “技术在于折腾” 博客,请务必保留此出处http://viong.blog.51cto.com/844766/261342
vsftpd.conf的配置如下
<!--[if !supportLists]-->1. <!--[endif]-->[root@vm3 vsftpd]# cat vsftpd.conf |grep -v ^$ |grep -v "#"
<!--[if !supportLists]-->2. <!--[endif]-->anonymous_enable=NO
<!--[if !supportLists]-->3. <!--[endif]-->local_enable=YES
<!--[if !supportLists]-->4. <!--[endif]-->write_enable=YES
<!--[if !supportLists]-->5. <!--[endif]-->local_umask=022
<!--[if !supportLists]-->6. <!--[endif]-->dirmessage_enable=YES
<!--[if !supportLists]-->7. <!--[endif]-->xferlog_enable=YES
<!--[if !supportLists]-->8. <!--[endif]-->connect_from_port_20=YES
<!--[if !supportLists]-->9. <!--[endif]-->xferlog_std_format=YES
<!--[if !supportLists]-->10.<!--[endif]-->chroot_list_enable=YES
<!--[if !supportLists]-->11.<!--[endif]-->chroot_list_file=/etc/vsftpd/chroot_list
<!--[if !supportLists]-->12.<!--[endif]-->listen=YES
<!--[if !supportLists]-->13.<!--[endif]-->pam_service_name=vsftpd
<!--[if !supportLists]-->14.<!--[endif]-->userlist_enable=YES
<!--[if !supportLists]-->15.<!--[endif]-->userlist_deny=NO
<!--[if !supportLists]-->16.<!--[endif]-->userlist_file=/etc/vsftpd/user_list
<!--[if !supportLists]-->17.<!--[endif]-->tcp_wrappers=YES
<!--[if !supportLists]-->18.<!--[endif]-->[root@vm3 vsftpd]#
相关推荐
linux下安装vsftpd服务的具体操作,简单,便捷
Linux 源代码 编译安装vsftpd-2.3.4,提供开源安全可靠的ftp服务系统,是你搭载ftp的不二之选
可实现在Linux下一键脚本自动化安装vsftpd,可以配合Ansible实现远程装机~
下载安装包后,进行解压,然后执行rpm -Uvh *.rpm --nodeps --force 命令批量安装rpm包,就行啦,快捷简单的
Centos7下安装vsftpd并启用虚拟用户访问
linux环境下安装vsftpd,里面有软件安装包和详细的安装文档~~
亲自经历,亲身体会,linux安装vsftpd详细教程,分享给大家,本来想让你们免积分下载的,可是现在规定至少2积分,我也是无奈了
安装vsftpd搭建ftp服务器
Centos7.9安装配置vsftpd
只需简简单单的8个步骤,教你一步步在Linux中搭建安装vsftpd组件服务。
Linux系统安装vsftpd服务实现远程ftp上传下载,有不明白如何配置的,可以下方评论留言哦,欢迎交流分享!
linux安装vsftpd配置FTP服务器
有时候会遇到客户是内网环境的,无法在线通过apt-get install vsftpd进行安装,本文将提供vsftpd_3.0.3的离线安装包。 安装步骤 1、上传至指定文件夹后,执行命令 tar -zxvf vsftpd_3.0.3.tar.gz 进行解压 2、然后...
在CentOS6上安装vsftpd基于本地用户访问
1. 安装 vsftpd。 sudo apt-get install vsftpd 2. 替换配置文件。 用文本编辑器打开 vsftpd.conf 配置文件,一般在 /etc 目录下。 [sudo joe /etc/vsftpd.conf 可以做如下修改: 把 anonymous_enable=...
安装vsftpd,搭建ftp服务器过程中碰到的问题
安装vsftpd报错sysdeputil.c问题文件的补丁attachment.bin
2)安装或升级vsftpd: rpm -Uvh vsftpd-3.0.5-1.el7.x86_64.rpm rpm -Uvh vsftpd-sysvinit-3.0.5-1.el7.x86_64.rpm 3)然后修改vsftpd.conf文件: sed -i 's|anonymous_enable=YES|anonymous_enable=NO|g' /etc/...
主要介绍了Ubuntu18.04安装vsftpd的实现代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧