基于本地用户的vsftpd搭建

发布时间:2020-07-24 10:19:09 作者:390892467
来源:网络 阅读:427

要求:

   一、禁止匿名账号和系统账号登录FTP服务器

   二、普通账号被禁锢在家目录

   三、开启指定用户能切换到其他目录

   四、设置系统登录日志记录

1、安装

#yum install vsftpd lftp -y
#rpm -ql vsftpd
/etc/logrotate.d/vsftpd
/etc/pam.d/vsftpd
/etc/rc.d/init.d/vsftpd
/etc/vsftpd
/etc/vsftpd/ftpusers
/etc/vsftpd/user_list
/etc/vsftpd/vsftpd.conf
/etc/vsftpd/vsftpd_conf_migrate.sh
/usr/sbin/vsftpd
/usr/share/doc/vsftpd-2.2.2
/usr/share/doc/vsftpd-2.2.2/AUDIT
/usr/share/doc/vsftpd-2.2.2/BENCHMARKS
/usr/share/doc/vsftpd-2.2.2/BUGS
/usr/share/doc/vsftpd-2.2.2/COPYING
/usr/share/doc/vsftpd-2.2.2/Changelog
/usr/share/doc/vsftpd-2.2.2/EXAMPLE
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE/vsftpd.xinetd
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/INTERNET_SITE_NOINETD/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/PER_IP_CONFIG/hosts.allow
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_HOSTS/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/README.configuration
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/logins.txt
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.conf
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS/vsftpd.pam
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2
/usr/share/doc/vsftpd-2.2.2/EXAMPLE/VIRTUAL_USERS_2/README
/usr/share/doc/vsftpd-2.2.2/FAQ
/usr/share/doc/vsftpd-2.2.2/INSTALL
/usr/share/doc/vsftpd-2.2.2/LICENSE
/usr/share/doc/vsftpd-2.2.2/README
/usr/share/doc/vsftpd-2.2.2/README.security
/usr/share/doc/vsftpd-2.2.2/REWARD
/usr/share/doc/vsftpd-2.2.2/SECURITY
/usr/share/doc/vsftpd-2.2.2/SECURITY/DESIGN
/usr/share/doc/vsftpd-2.2.2/SECURITY/IMPLEMENTATION
/usr/share/doc/vsftpd-2.2.2/SECURITY/OVERVIEW
/usr/share/doc/vsftpd-2.2.2/SECURITY/TRUST
/usr/share/doc/vsftpd-2.2.2/SIZE
/usr/share/doc/vsftpd-2.2.2/SPEED
/usr/share/doc/vsftpd-2.2.2/TODO
/usr/share/doc/vsftpd-2.2.2/TUNING
/usr/share/doc/vsftpd-2.2.2/vsftpd.xinetd
/usr/share/man/man5/vsftpd.conf.5.gz
/usr/share/man/man8/vsftpd.8.gz
/var/ftp
/var/ftp/pub

2、配置


#sed '{/^#/d;/^$/d}' /etc/vsftpd/vsftpd.conf
anonymous_enable=NO                             #设定不让匿名登录
local_enable=YES                                #指定在/etc/passwd内的账号才能以真实用户登录
write_enable=YES                                #允许用户上传文件与目录
local_umask=022                                 #建立新目录755和文件644权限     
dirmessage_enable=YES                           #若目录下有.message则会显示其中的内容
connect_from_port_20=NO                         #支持主动式联机功能
xferlog_enable=YES                              #启动登录文件记录,记录于/var/log/xferlog
dual_log_enable=YES                             #启用独立日志功能
vsftpd_log_file=/var/log/vsftpd.log             #ftp访问日志位置
xferlog_file=/var/log/xferlog                   #登录日志位置
xferlog_std_format=YES                          #支持wuftp日志格式,可以使用wuftp登录文件的分析软件
chroot_list_enable=YES                          #启用chroot禁锢用户列表模式,和下项配合使用
chroot_list_file=/etc/vsftpd/chroot_list        #如果为YES,设定不被chroot用户列表
chroot_local_user=YES                           #限制默认用户chroot
pasv_enable=YES                                 #支持数据流的被动连接模式
pasv_min_port=40000                             #被动连接模式支持的
pasv_max_port=40080                             端口范围
pasv_promiscuous=YES                            #禁用pasv检查
listen=YES                                      #独立进程启动
listen_port=10090                               #使用命令通道端口,服务器侦听端口
pam_service_name=/etc/pam.d/vsftpd              #pam模块名称
userlist_enable=YES                             #开启userlist机制管理登录账号
userlist_deny=YES                               #默认YES,拒绝列表
userlist_file=/etc/vsftpd/user_list             #列表位置
tcp_wrappers=YES                                #支持tcp wrappers的防火墙机制
max_clients=10                                  #最多支持10个用户的连接
max_per_ip=50                                   并且一个用户最多50的连接

3、新建测试账号


#useradd nagios
#echo 'nagios' | passwd --stdin nagios
Changing password for user nagios.
passwd: all authentication tokens updated successfully.

4、不受chroot控制的用户

#cat /etc/vsftpd/chroot_list
nagios

5、测试

#lftp -p 10090 -u nagios,nagios ServerIP
#lftp nagios@192.168.100.10:~> ls
-rw-r--r--    1 501      501          1578 May 05 03:41 passwd
-rw-r--r--    1 501      501           220 May 05 03:41 rc.localcheng
lftp nagios@ServerIP:~cd /etc/
cd ok, cwd=/etc
lftp nagios@ServerIP:/etc> pwd

逃离Home成功

6、一般用户测试

# lftp -p 10090 -u cytxmanager,centos ServerIP
lftp cytxmanager@ServerIP:~> ls
-rw-r--r--    1 500      500          1578 May 05 03:14 passwd
lftp cytxmanager@ServerIP:/> cd /etc/
cd: Access failed: 550 Failed to change directory. (/etc)

被chroot

推荐阅读:
  1. 怎么搭建vsftpd服务器
  2. 怎样搭建vsftpd并实现虚拟用户

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

vsftp 本地用户

上一篇:如何修改phpcms后台

下一篇:如何清理phpcms缓存文件

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》