Vsftpd在centos6.4的尝试

1 安装软件

可以去官网下载,我直接yum安装了,版本为vsftpd.x86_64 0:2.2.2-14.el6   ,我的测试都比较简单,大家可以照着做一下。

2文件服务器的三种登录方式

匿名登录

vsftpd.conf默认是开启匿名登录的,不信你看

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).

anonymous_enable=YES

如果没开启请把注释取消

默认情况下,匿名的家目录在/var/ftp/pub目录下

在windows宿主测试,发现如何都是未连接,后来发现时iptables on了

最终可以登录,也可以下载

在图形界面也是ok的

不过你可能想到,不能上传文件,原因是未开启权限

解决办法是在vsftpd.conf添加几行,顺便咱们修改下家目录

#ano‘s directory

anon_root=/var/liuliancao

把如下功能打开,也可以自己写哈

anon_upload_enable=YES

anon_mkdir_write_enable=YES

可以上传

可以创建文件夹

删除就不行,当然也用不到,毕竟不是一个安全的配置。

使用本地用户登录

此时就建议禁用anonymous了,一般公司肯定不会开启anonymous

所以在vsftpd.conf的anonymous_enable=YES改为NO,此时即关闭了匿名

默认情况下是允许所有本地用户登录,当要分别考虑授权的时候,就得启动ftp_users(你可以看看里面的内容)文件

默认情况:

使用本地用户可以在外网登录,root除外,这个通常是由列表确定

默认情况下,

在配置文件的结尾有这行

userlist_enable=YES    #使用userlist,且userlist上的全部不给登录

userlist_deny=YES       #在使用userlist情况下,列表中的用户被拒绝

如果

userlist_deny=NO

则userlist指定的是允许的用户,当然如果你不想考虑这些,那么就把你讨厌的人拉入ftpusers这个黑名单吧

我建议使用userlist_enable=YES  userlist_deny=NO组合,这样,ftpusers放黑名单,userlist放白名单,这样更安全点

当我在ftpusers放置liuliancao时,对于liuliancao和lqx两个用户

而此时进入的是用户的家目录,由于刚建的用户没有文件,所以这样,不信可以试下,但是此时用户可以cd到根,显然不符合安全性,所以这里建议要设置chroot,把用户绑定在其家目录下

所以修改如下几行,先别改,咱们分析下

chroot_local_user=YES

这里的YES指的是什么呢?

首先是启用一个特殊的列表,其次是默认所有用户都限制在家目录中,但列表时特殊名单,不被限制

如果是NO呢

也启用那个特殊的列表,但是默认所有用户不限制在家目录中,

那思考下,此时我有两个用户,一个liuliancao,一个lqx,我把chroot_local_user设为NO,那个特殊的列表中有liuliancao,没有lqx,此时谁会被限制在家目录中?

肯定是黑名单liuliancao会被限制,^_^

测试下,我修改了下这几行文件

chroot_local_user=NO

chroot_list_enable=YES

# (default follows)

chroot_list_file=/etc/vsftpd/chroot_list

在chroot_list增加了liuliancao

结果为:

一般情况肯定设置chroot为YES哦,毕竟为了安全着想啊

另外可以通过增加一条

local_root=/var/liuliancao来指定本地用户连接ftp的默认家目录

③虚拟用户设置 参考http://bbs.51cto.com/thread-557955-1.html

第一步,创建txt列表,记录虚拟用户

Tec为普通用户,可以下载

Ball为vip 可以下载,上传,创建目录

# cat /etc/vsftpd/vuser.txt   #奇数行用户名,偶数行密码哦

Tec

Tec

Ball

Ball

第二步,使用db_load命令生成db数据库(我的centos6.4最小安装没有,没有请yum -y install db4)

这个命令想来也挺好记

db_load -T  -t hash -f /etc/vsftpd/vuser.txt /etc/vsftpd/vuser.db

-T:让程序把非数据库的文本转换为数据库db型

-t hash:转换为hash数据库

-f file:txt文件位置,即源文件

最后参数:目标文件

然后记得修改下数据库的权限

# chmod 600 /etc/vsftpd/vuser.db   #bash中,最后一个参数可以使用esc+.(centos支持)或者alt+.调出来,很方便

顺便添加以下系统用户,即虚拟用户对应的系统用户,Tec是普通ftp用户,只允许下载,Ball允许上传下载

第三步,为vsftpd添加pam认证,64位和32位肯定不一样,db不用加db

# cat /etc/pam.d/vsftpd

#%PAM-1.0

#session    optional     pam_keyinit.so    force revoke

#auth       requiredpam_listfile.so item=user sense=deny file=/etc/vsftpd/ftpusers onerr=succeed

#auth       requiredpam_shells.so

#auth       includepassword-auth

#account    includepassword-auth

#session    required     pam_loginuid.so

#session    includepassword-auth

auth     required   /lib64/security/pam_userdb.so     db=/etc/vsftpd/vuser       #64位是这样,vuser不用写db

account        required   /lib64/security/pam_userdb.so  db=/etc/vsftpd/vuser

第四步,为用户设置家目录,提供权限访问,这里的用户可以不同名,我只是为了方便点,所以建议同名

# useradd -d /var/ftp/Tec/   Tec

# useradd -d /var/ftp/Ball/   Ball

# chmod 500 /var/ftp/Tec

# chmod 700 /var/ftp/Ball

第五步,修改主配置文件

pam_service_name=vsftpd

user_config_dir=/etc/vsftpd/vuserconfig   #自己等会创建的配置文件目录

max_clients=300

max_per_ip=10;

userlist_enable=YES

tcp_wrappers=YES

第六步,修改用户配置文件

对于普通用户Tec有:

# cat  /etc/vsftpd/vuserconfig/Tec

guest_enable=YES            #允许虚拟用户登录

write_enable=NO            #不准写入,即上传等写操作

gues_username=Tec     #指定guest用户名

anon_world_readable_only=no #这里指定

anon_max_rate=50000   指定最大下载速率#

对于特权用户Ball来说:

# cat /etc/vsftpd/vuserconfig/Ball

guest_enable=YES

guest_username=Ball

write_enable=YES

anon_mkdir_write_enable=YES

anon_upload_enable=YES

anon_world_readable_only=NO

anon_max_rate=100000

登录发现报错

在网上看到这篇博文,挺好的,http://www.it165.net/admin/html/201305/1296.html,当然我建议你要检查你的user_list究竟是允许还是不允许用户登录,最好的办法就是控制变量

结果我重新生成了以下就行了,然后接着报错

看来我输错了

修改下配置文件

就好了

但是不可以dir

发现我的Tec家目录居然是root创建的,所以修改家目录属主就好了

# chown Tec:Tec /var/ftp/Tec

下面测试下功能是否完整

Tec:

可以下载

不可以上传和创建目录

对于Ball:

可上传,下载,创建目录

此时我的配置文件为下面的,仅供参考

# Make sure PORT transfer connectionsoriginate from port 20 (ftp-data).

connect_from_port_20=YES

#

# If you want, you can arrange for uploadedanonymous 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 whenxferlog_enable=YES and xferlog_std_format=YES

# WARNING - changing this filename affects/etc/logrotate.d/vsftpd.log

xferlog_file=/var/log/vsftpd.log

#

# Switches between logging into vsftpd_log_fileand xferlog_file files.

# NO writes to vsftpd_log_file, YES toxferlog_file

xferlog_std_format=YES

#

# You may change the default value fortiming out an idle session.

#idle_session_timeout=600

#

# You may change the default value fortiming out a data connection.

#data_connection_timeout=120

#

# It is recommended that you define on yoursystem a unique user which the

# ftp server can use as a totally isolatedand unprivileged user.

#nopriv_user=ftpsecure

#

# Enable this and the server will recogniseasynchronous ABOR requests. Not

# recommended for security (the code isnon-trivial). Not enabling it,

# however, may confuse older FTP clients.

#async_abor_enable=YES

#

# By default the server will pretend toallow ASCII mode but in fact ignore

# the request. Turn on the below options tohave the server actually do ASCII

# mangling on files when in ASCII mode.

# Beware that on some FTP servers, ASCIIsupport allows a denial of service

# attack (DoS) via the command "SIZE/big/file" in ASCII mode. vsftpd

# predicted this attack and has always beensafe, reporting the size of the

# raw file.

# ASCII mangling is a horrible feature ofthe protocol.

#ascii_upload_enable=YES

#ascii_download_enable=YES

#

# You may fully customise the login bannerstring:

#ftpd_banner=Welcome to blah FTP service.

#

# You may specify a file of disallowedanonymous e-mail addresses. Apparently

# useful for combatting certain DoSattacks.

#deny_email_enable=YES

# (default follows)

#banned_email_file=/etc/vsftpd/banned_emails

#

# You may specify an explicit list of localusers 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=NO

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 ableto cause excessive I/O on large

# sites. However, some broken FTP clientssuch 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 isenabled, vsftpd runs in standalone mode and

# listens on IPv4 sockets. This directivecannot be used in conjunction

# with the listen_ipv6 directive.

listen=YES

#

# This directive enables listening on IPv6sockets. To listen on IPv4 and IPv6

# sockets, you must run two copies ofvsftpd with two configuration files.

# Make sure, that one of the listen optionsis commented !!

#listen_ipv6=YES

pam_service_name=vsftpd

user_config_dir=/etc/vsftpd/vuserconfig

max_clients=300

max_per_ip=10

userlist_enable=YES

userlist_deny=NO

tcp_wrappers=YES

由于db的操作比较简单,如果用户多可以使用脚本,所以我觉得mysql可能就没必要了。

最后还发现一个问题:

资源管理器默认不会提示登录,反而会提示无法访问,最后通过

考虑原因可能是默认不允许匿名登录,所以只要在输入ftp://[email protected]即可,即添加好用户名的方式,最终可以登录

时间: 2024-08-27 16:54:44

Vsftpd在centos6.4的尝试的相关文章

Ubuntu14.04安装vsftpd

之前学会了在centos6.7系统上安装vsftpd服务,这次从Ubuntu14.04上安装vsftpd服务 先安装vsftpd包 [email protected]:~# apt-get install vsftpd 与centos6.7不同的是,在Ubuntu中没有vsftpd文件夹,在/etc下只有主配置文件vsftpd.conf和ftpusers文件,并没有user_list文件 新建一个宿主目录 [email protected]:~# mkdir /home/uftp 新建一个用户指

vsftpd实战练习

Vsftpd文件系统服务 实验:vsftpd中禁止匿名用户的登录,yixuan与xiaozhu同时映射系统用户vuser,但是两个虚拟用户却一个有上传权限,一个没有,主要的原因是在vsftpd.conf配置文件中有一个user_upload_dir=/etc/vsftpd/vusers.conf.d 1.Vsftpd服务介绍 vsftpd:very secure ftpdaemon一个安全的ftp服务 启动文件:/usr/sbin/vsftpd 主配置文件:/etc/vsftpd/vsftpd.

linux vsftpd配置

vsftpd是一款在Linux发行版中最受推崇的FTP服务器程序.特点是小巧轻快,安全易用. 如果你想在你的Linux/Unix服务器上搭建一个安全.高性能.稳定性好的FTP 服务器,那么vsftpd可能是你的首选应用.vsftpd意思为“very secure FTP daemon(非常安全的FTP进程)”,是一个基于GPL发布的类UNIX类操作系统上运行的服务器的名字(是一种守护进程),可以运行在诸如 Linux.BSD.Solaris.HP-UX以及Irix等系统上面.vsftpd支持很多

不断尝试,终能到达彼岸

看山是山,看水是水:看山不是山,看水不是水:看山还是山,看水还是水.——佛家中人生三大境界 最近有一个用django开发的项目需要部署,项目用到了djangorestfulframework,MySQL-python和PIL.要求是要在没有网络的小黑屋里安装!经过一翻折腾后,终于有了一个简且有效的方案展现在眼前,不禁让人感叹.于是想把这个过程与大家分享一下.分析自己的思维过程,应该也是一件非常有趣的事. 很简单,安装软件包   是的,很简单.我很快就找到了mysql社区版地址,不知道怎么回事,单

CentOS7 搭建FTP

对于linux,只在上个微信公众号开发的时候,玩了CentOS6.5. 现在学习Docker技术,官方建议升级到7.2.于是乎只能捣鼓一下了. 花了一晚上的时间才真正把vsftpd安装好,flashfxp 正常上传下载文件.这中间碰到一些问题,顺便记录下. 首先,centos7.2 虚拟机安装完后,要配置网络. nmcli connection show   --- 显示当前网络连接 cd /etc/sysconfig/network-scripts/ ls vi ifcfg-ens33 --把

FTP基于PAM和MySQL/MariaDB实现虚拟用户访问控制

前言 vsftpd是一款在Linux发行版中最受推崇的FTP服务器程序,特点是小巧轻快,安全易用,目前在开源操作系统中常用的FTP套件主要有proftpd.pureftp.ServU和wu-ftpd等.本文将讲解vsftpd的基本功能和如何基于PAM和MySQL/MariaDB实现虚拟用户访问控制. 基础配置介绍 工作原理 状态响应码 1xx:信息码 2xx:成功状态码 3xx:进一步提示补全信息的状态码 4xx:客户端错误 5xx:服务器端错误 用户认证 虚拟用户:仅用于访问某特定服务中的资源

FTP(二)相关配置

FTP服务是由vsftpd包提供的 不再由xinetd服务管理 用户认证配置文件:/etc/pam.d/vsftpd 服务脚本: centos7:/usr/lib/systemd/system/vsftpd.service centos6:/etc/rc.d/init.d/vsftpd 主配置文件:/etc/vsftpd/vsftpd.conf 格式:option=value "注意:= 前后不要有空格" 查看帮助:man 5 vsftpd.conf 匿名用户(映射为系统用户ftp )

实现基于mysql验证的vsftpd虚拟用户 (centos6)

实现基于mysql验证的vsftpd虚拟用户 (centos6) 说明:本实验在两台Cento主机上实现,一台作为FTP服务器,一台作为数据库服务器 FTP服务器ip:172.16.250.90 Mysql服务器ip:172.16.252.16 一.安装ftp服务器安装包 yum install vsftpd pam_mysql 二.数据库服务器创建虚拟用户帐号   1.建立虚拟用户数据库      mysql> create database vsftpd;     mysql> show 

CentOS6.5 vsftpd 配置

CentOS6.5vsftpd 配置文件为/etc/vsftpd/vsftpd.conf 安装完软件后:1.默认匿名用户能够登陆,且限制在/pub目录内,2.本地用户可以登陆但因SElinux而无法登陆.3.ftpuser内用户无法登陆.(PAM限制)4.可利用 /etc/hosts.{allow|deny} 来作为基础防火墙:5.主动式联机的埠口为 port 206.使用格林威治时间 (GMT).『 use_localtime=YES 』可修改成本地时间. 限制用户登陆的文件有两个:1./et