vsftpd安装

1.卸载vsftpd 
sudo yum remove vsfftpd

2.安装vsftpd
yum -y install vsftpd

3.在/usr/local/devtools目录创建ftpfile文件夹
[root@xupan001 devtools]# pwd
/usr/local/devtools
[root@xupan001 devtools]# mkdir ftpfile

4.创建用户,只对ftpfile有权限,并且没有登陆权限
[root@xupan001 ~]# cd /usr/local/devtools/ftpfile/
[root@xupan001 ftpfile]# ll
total 0
[root@xupan001 ftpfile]# sudo useradd ftpuser -d /usr/local/devtools/ftpfile/ -s /sbin/nologin 

-d:指定用户登入时的主目录,替换系统默认值/home/<用户名>
-s:指定用户登入后所使用的shell。默认值为/bin/bash。


对/sbin/nologin的理解
系统账号的shell使用 /sbin/nologin ,此时无法登陆系统,即使给了密码也不行。  所谓“无法登陆”指的仅是这个用户无法使用bash或其他shell来登陆系统而已,并不是说这个账号就无法使用系统资源。

 

5.赋值权限
sudo chown -R ftpuser.ftpuser /usr/local/devtools/ftpfile/

6.查看权限
[root@xupan001 devtools]# ll | grep ftpfile
drwxr-xr-x   2 ftpuser ftpuser 4096 Jun  1 12:30 ftpfile
用户名和用户组都是ftpuser

7.重置密码
[root@xupan001 devtools]# passwd ftpuser
Changing password for user ftpuser.
New password: 
BAD PASSWORD: it is based on a dictionary word
BAD PASSWORD: is too simple
Retype new password: 
passwd: all authentication tokens updated successfully

8.创建文件
[root@xupan001 ftpfile]# vim index.html

9.添加内容
[root@xupan001 ftpfile]# vim index.html
here is ftpfile
/usr/local/devtools/ftpfile/index.html

10.配置vsftpd
[root@xupan001 ftpfile]# whereis vsftpd
vsftpd: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz

 

11.编辑配置文件
vim /etc/vsftpd/vsftpd.conf 

anonymous_enable=NO

ftpd_banner=Welcome to xpshop FTP service.
local_root=/usr/local/devtools/ftpfile
#anno_root=/usr/local/devtools/ftpfile
use_localtime=yes

 

chroot_local_user=NO
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_lis

pasv_min_port=61001
pasv_max_port=62000

 


12.添加文件chroot_list,并编辑文件添加f t pu se r
vim /etc/vsftpd/chroot_list

13.防火墙设置
vim /etc/sysconfig/iptables
#vsftpd
-A INPUT -p TCP --dport 61001:62000 -j ACCEPT
-A OUTPUT -p TCP --sport 61001:62000 -j ACCEPT

-A INPUT -p TCP --dport 21 -j ACCEPT
-A OUTPUT -p TCP --dport 21 -j ACCEPT
-A INPUT -p TCP --dport 20 -j ACCEPT
-A OUTPUT -p TCP --dport 20 -j ACCEPT

 

13.重启防火墙和vsftpd
[root@xupan001 ~]# service iptables restart
iptables: Applying firewall rules:                         [  OK  ]
[root@xupan001 ~]# service vsftpd restart
Shutting down vsftpd:                                      [FAILED]
Starting vsftpd for vsftpd:                                [  OK  ]

 

14.修改vim /etc/selinux/config 

#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

15.使之生效 sudo setenforce 0

转载于:https://my.oschina.net/u/2253438/blog/913645

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值