博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
centOS7安装FTP
阅读量:4073 次
发布时间:2019-05-25

本文共 5178 字,大约阅读时间需要 17 分钟。

centOS7安装FTP

1 以管理员运行:yum install vsftpd#安装ftp

2 chkconfig vsftpd on#设置开机启动
3 service vsftpd start #启动ftp服务
4 yum -y install ftp #安装组件,

5创建ftp根目录:mkdir -p /ftpserver

ftp localhost #测试登陆,输入用户名ftp,密码随便(因为默认是允许匿名的)登录成功,就代表ftp服务可用了。但是,外网是访问不了的,所以还要继续配置。
vim /etc/sysconfig/iptables #找到一行22 -j ACCEPT 把它复制一行到下面,把端口号22改成21,保存退出
service iptables restart #重启防火墙
vim /etc/vsftpd/vsftpd.conf #去掉两行注释 #chroot_list_enable=YES 和  #chroot_list_file=/etc/vsftpd.chroot_list 的#号
service vsftpd restart #重启ftp服务
useradd -d /www aaa #新建用户aaa,并指定/www为访问目录
passwd aaa #给用户aaa设置密码
usermod -d /www/app aaa #修改aaa的主目录为/www/app
 

6 vi /etc/vsftpd/vsftpd.conf进入文件编辑状态,在后面加上pasv_min_port=30000和pasv_max_port=30999表示端口范围为    30000~30999,这个可以随意改。 
   6.1修改完后重启一下vsftpd,指令service vsftpd restart。 
   6.2由于指定这段端口范围,iptables也要相应的开启这个范围,所以像上面那样打开iptables文件。 
   6.3也是在21上下面另起一行,更那行差不多,只是把21 改为30000:30999,然后wq保存。 
   6.4service iptables restart指令重启下iptables。
--------------------- 

vsftpd-3.0.2-10.el7.x86_64 (显示也就安装成功了!)

如果没有则安装vsftpd

[root@localhost ~]# yum install -y vsftpd1

安装完成后可以查看到安装的目录

[root@localhost ~]# whereis vsftpd1

vsftpd: /usr/sbin/vsftpd /etc/vsftpd /usr/share/man/man8/vsftpd.8.gz

查看vsftpd服务的状态

[root@localhost ~]# systemctl status vsftpd.service1

● vsftpd.service - Vsftpd ftp daemon 

 Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled) 
   Active: active (running) since 三 2017-07-05 14:29:53 CST; 3s ago 
Process: 3951 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS) 
 Main PID: 3953 (vsftpd) 
   CGroup: /system.slice/vsftpd.service 
           ├─3953 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf 
           ├─3963 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf 
           └─3964 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

7月 05 14:29:53 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon… 

7月 05 14:29:53 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.

开启vsftpd服务

[root@localhost ~]# systemctl start vsftpd.service1

设置vsftpd服务开机自启

[root@localhost ~]# systemctl enable vsftpd.service
(或者:[root@localhost ~]# chkconfig vsftpd on)12

2、配置vsftpd.conf文件(正确设置)

[root@localhost ~]# vi /etc/vsftpd/vsftpd.conf

1 anonymous_enable=YES

2local_enable=YES

3anon_umask=077

4 chroot_local_user=NO

5 chroot_list_enable=YES

6 chroot_list_file=/var/public_root

7 listen_port=1802

8 pasv_enable=NO

9 pasv_min_port=3000

10 pasv_max_port=30999

11 pasv_promiscuous=YES

12pasv_service_name=vsftpd

13userlist_enable=NO

 

 

3、添加FTP账户

这里设置的账户名为“test”,密码为“123456”

[root@localhost ~]# useradd test -s /sbin/nologin

[root@localhost ~]# passwd 12345612

4、编辑user_list文件,允许test用户访问FTP

[root@localhost ~]# vi /etc/vsftpd/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.
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
test
~                                                                                      
~                                                                                      
~                                                                                      
~                                                                                      
"/etc/vsftpd/user_list" 21L, 366C1234567891011121314151617181920212223242526272829

5、建根目录,并设置访问权限

[root@localhost ~]# mkdir /var/public_root

[root@localhost ~]# chown -R test /var/public_root
[root@localhost ~]# chmod -R 777 /var/public_root123

 

5 ftp localhost #测试登陆,输入用户名ftp,密码随便(因为默认是允许匿名的)登录成功,就代表ftp服务可用了。但是,外网是访问不了的,所以还要继续配置。

--------------------- 

 

 

另一种FTP

1 yum install vsftpd

2 systemctl start vsftpd.service
3 systemctl enable vsftpd.service

3 yum -y install ftp

4ftp localhost
ftp>exit  退出

2 vim /etc/vsftpd/vstfpd.conf

配置:
anonymous_enable=NO

重起

systemctl restart vsftpd.service
1 设置 anonymous_enable=NO

2 chroot_local_user=YES

  chroot_list_enable=YES 删除注释

3 allow_writeable_chroot=YES

第一、配置文件修改

vi /etc/vsftpd/vsftpd.conf

首先需要在vsftpd配置文件中添加:

listen_port=1802

pasv_enable=YES
pasv_min_port=30000
pasv_max_port=30999
pasv_promiscuous=YES
ftpd_banner=Welcome to https://www.itbulu.com FTP service
listen_port端口我们可以自己设置。pasv_min_port和pasv_max_port也是随意设置的,后面我们开启防火墙的时候对应就可以了。

第二、修改services文件

vi /etc/services

如果我们不方便用VI工具的话就下载到本地,因为文件比较多。直接将两处的FTP参数后面21修改成我们上面设置的端口。

修改services文件

第三、端口防火墙设置

上面我们设置了新的端口,如果有iptables设置的,我们需要开放端口。

vi /etc/sysconfig/iptables

在合适的位置添加:

-A INPUT -p tcp -m state --state NEW -m tcp --dport 30000:30999 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 1802 -j ACCEPT
保存重启iptables

service iptables restart

第四、重启vsftpd检测

service vsftpd restart

groupadd ftpgroups

mkdir /home/ftp
useradd -d /home/ftp  -g ftpgroups shumeigang
出错 不从skel 目录里向其中复制任何文件
usermod -s /sbin/nologin shumeignag

4CentOS7

[root@localhost ~]# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

1.关闭firewall

[root@localhost ~]# systemctl stop firewalld.service            //停止firewall

[root@localhost ~]# systemctl disable firewalld.service        //禁止firewall开机启动

centOS 6.5关闭防火墙步骤

关闭命令:  service iptables stop 
永久关闭防火墙:chkconfig iptables off
两个命令同时运行,运行完成后查看防火墙关闭状态
service iptables status

2.安装iptables

[root@localhost ~]# yum install iptables-services            //安装

[root@localhost ~]# systemctl restart iptables.service #重启防火墙使配置生效

[root@localhost ~]# systemctl enable iptables.service #设置防火墙开机启动

[root@localhost ~]# systemctl disable iptables.service #禁止防火墙开机启动

passwd shumeigang

systemctl restart vsftpd.service

 

转载地址:http://mlfni.baihongyu.com/

你可能感兴趣的文章
将file文件内容转成字符串
查看>>
循环队列---数据结构和算法
查看>>
优先级队列-数据结构和算法
查看>>
链接点--数据结构和算法
查看>>
servlet中请求转发(forword)与重定向(sendredirect)的区别
查看>>
Spring4的IoC和DI的区别
查看>>
springcloud 的eureka服务注册demo
查看>>
eureka-client.properties文件配置
查看>>
MODULE_DEVICE_TABLE的理解
查看>>
platform_device与platform_driver
查看>>
platform_driver平台驱动注册和注销过程(下)
查看>>
.net强制退出主窗口的方法——Application.Exit()方法和Environment.Exit(0)方法
查看>>
c# 如何调用win8自带的屏幕键盘(非osk.exe)
查看>>
build/envsetup.sh 简介
查看>>
Android framework中修改或者添加资源无变化或编译不通过问题详解
查看>>
linux怎么切换到root里面?
查看>>
linux串口操作及设置详解
查看>>
安装alien,DEB与RPM互换
查看>>
编译Android4.0源码时常见错误及解决办法
查看>>
Android 源码编译make的错误处理
查看>>