大家好,今天来给大家分享一个基于centos 7的ftp服务器搭建

实现功能:匿名访问,本地登录

查看系统版本:

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)

查看本地ip地址

[root@localhost ~]# ifconfig ens33
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.5 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 240e:3a2:743:df40:bb08:8c86:f745:edd4 prefixlen 64 scopeid 0x0<global>
inet6 fe80::617f:ef93:80d4:e14e prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:87:af:a6 txqueuelen 1000 (Ethernet)
RX packets 50282 bytes 3247879 (3.0 MiB)
RX errors 0 dropped 922 overruns 0 frame 0
TX packets 6542 bytes 8519343 (8.1 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

我们连一下xshell   (远程控制终端)

[C:\~]$ ssh 192.168.1.5

Connecting to 192.168.1.5:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Sat Oct 23 11:15:44 2021 from 192.168.1.2
[root@localhost ~]#

测试网络:

[root@localhost ~]# ping www.baidu.com
PING www.a.shifen.com (180.101.49.11) 56(84) bytes of data.
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=1 ttl=54 time=10.0 ms
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=2 ttl=54 time=9.79 ms
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=3 ttl=54 time=7.52 ms
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=4 ttl=54 time=8.06 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 22033ms
rtt min/avg/max/mdev = 7.523/8.862/10.065/1.094 ms

这样的话,我们的服务器就可以上网了 (可使用网络yum源)

接下来我们安装vsftpd服务程序

[root@localhost ~]# yum install vsftpd.x86_64 -y

进入vsftpd主目录

[root@localhost ~]# cd /etc/vsftpd/
[root@localhost vsftpd]# ls
ftpusers user_list vsftpd.conf vsftpd_conf_migrate.sh      
[root@localhost vsftpd]#

将主配置文件内容当中#全部去掉

[root@localhost vsftpd]# cat vsftpd.conf |grep -v "#"
anonymous_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

这些是有效地配置文件,我们需要对它进行改动

对主配置文件改名为vsftpd.conf.bak

[root@localhost vsftpd]# mv vsftpd.conf vsftpd.conf.bak

查看

[root@localhost vsftpd]# ls
ftpusers user_list vsftpd.conf.bak vsftpd_conf_migrate.sh

将vsftpd.conf.bak的#号过滤掉,将这个结果过滤到vsftp.conf

[root@localhost vsftpd]# cat vsftpd.conf.bak |grep -v "#" >vsftpd.conf

编辑vsftpd 主配置文件

[root@localhost vsftpd]# vim vsftpd.conf

anon_umask=022
anon_update_enable=YES
anon_nkdir_write_enable=YES
anon_other_write_enable=YES     //将这四行的配置文件加入vsftpd.conf,(实现匿名访问)

如下

anonymous_enable=YES
anon_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

:wq

保存退出

重启ftp服务器:

[root@localhost vsftpd]# systemctl restart vsftpd

[root@localhost vsftpd]# systemctl enable vsftpd.service    //设置开机自启动

Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service.
[root@localhost vsftpd]#

[root@localhost vsftpd]# systemctl stop firewalld       //关闭防火墙

本地测试,显示vsftpd服务器正常

[root@localhost vsftpd]# cd /var/ftp/
[root@localhost ftp]# ls
pub(本来就有的文件)

[root@localhost ftp]#

[root@localhost ftp]# touch 123.txt       //创建文件123.txt
[root@localhost ftp]#

创建文件报错,(权限不够)

[root@localhost ftp]# chmod 777 pub/       //加权限

匿名用户访问成功

开始做本地用户

[root@localhost ~]# vim /etc/vsftpd/vsftpd.conf      //编辑配置文件

anonymous_enable=YES
anon_umask=022
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES         //这是我们刚刚编辑的配置文件

按箭头去修改

改成:

或者注释掉这四行也是一样的效果:

anonymous_enable=NO
#anon_umask=022
#anon_upload_enable=YES
#anon_mkdir_write_enable=YES
#anon_other_write_enable=YES
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_std_format=YES
listen=NO
listen_ipv6=YES

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

编辑这个文件

[root@localhost vsftpd]# vim ftpusers

# Users that are not allowed to login via ftp
root
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody

根据具体要求,删掉你想登录FTP服务的本地用户。

例如,删掉root。

# Users that are not allowed to login via ftp
bin
daemon
adm
lp
sync
shutdown
halt
mail
news
uucp
operator
games
nobody
~

[root@localhost vsftpd]# systemctl restart vsftpd       //重启vsftpd 服务

实验成功。测试的时候,既可以用windows的文件搜索,也可以用第三方工具

centos7 配置ftp服务器搭建(匿名访问,以及本地登录)的更多相关文章

  1. CentOS7 配置FTP服务器

    1.安装vsftpd yum -y install vsftpd 2.在firewalld中添加规则 为确保成功 先启动firewalld服务 systemctl enable firewalld s ...

  2. centos7 配置 ftp 服务器(本地用户)

    2021-09-02 1. 安装 # 安装 vsftpd yum -y install vsftpd 2. 启动服务并添加到开机自启 # 启动 vsftpd systemctl start vsftp ...

  3. FTP服务器搭建与访问的相关问题

    近期想搭建在云服务器上搭建一个项目,每次远程登陆服务器实在比较繁琐,故而想到使用FTP上传下载方式来进行相应的操作:在网络上搭建FTP服务器的文档还是很丰富的,按照操作一步步来还算方便,楼主就不在这边 ...

  4. 腾讯云下的CentOS7 配置 FTP 服务器

    第一步安装vsftp * yum -y install vsftpd 第二步配置ftp文件 要实现用户不仅可以下载ftp上的内容 还可以删改增加文件到ftp服务器 需要给ftp的目录赋予写入权限 1. ...

  5. Linux Centos7配置ftp服务器

    一.安装 1.安装 yum install  -y vsftpd 2.设置开机启动 systemctl enable vsftpd.service 3.启动 systemctl start vsftp ...

  6. CentOS7配置FTP服务器增强版~(零基础学会FTP配置)

    ps:原文不知出处,但是原文也不能正常启动,这里做了一些修改!如果能正常配置请在下方留言让更多的人看到,因为之前我本人照着网上的教程安装卸载了十多次也无法正常使用,不希望后面的兄弟继续浪费时间,如果不 ...

  7. FTP服务器搭建(Centos7)

    1.1.1 查看是否安装vsftp rpm -qa | grep vsftpd 1.1.2 如果没有安装: yum -y install vsftpd 1.2.3 vsftpd.conf 配置文件 匿 ...

  8. win10用filezilla server搭建ftp服务器一直无法访问

    win10用filezilla server搭建ftp服务器一直无法访问?? 是防火墙导致的,防火墙中允许filezilla server程序的

  9. Linux之匿名FTP服务器搭建

    FTP(File Transfer Protocol)是在服务器与客户端进行文件传输的一种传输协议.本次介绍的是vsftpd的软件体验ftp服务. FTP服务器默认情况下依据用户登录情况分为三种不同的 ...

随机推荐

  1. 2021-06-14 BZOJ4919:大根堆

    BZOJ4919:大根堆 Description: 题目描述   给定一棵n个节点的有根树,编号依次为1到n,其中1号点为根节点.每个点有一个权值v_i. 你需要将这棵树转化成一个大根堆.确切地说,你 ...

  2. 针对Autocad 2014 第二次安装不上的问题

    针对Autocad 2014 第二次安装不上的问题 1. 以下为卸载过程,不用管. 2. 卸载完之后,右击"开始",点击"运行",得到下图:   并输入:&qu ...

  3. C# Dapper基本三层架构使用 (四、WinForm UI层)

    UI层主要功能是显示数据和接受传输用户的数据,可以在为网站的系统运行提供交互式操作界面,表示层的应用方式比较常见,例如Windows窗体和Web页面. 在项目中增加WinForm应用程序,结构如下 添 ...

  4. 显示锁lock

    一.内置锁sync 和 显示锁lock概念 1.synv锁又叫内置锁,不能中断,拿不到无限等待即阻塞: java自带关键字: 隐式可重入: 重入锁:锁对应对象要多次调用对应方法,如递归 2. lock ...

  5. c++ undefined reference

    记录一次c++编程时发现的问题 报错 undefined reference undefined reference to `Student::~Student()' 下面还有类似的好几行,翻译过来就 ...

  6. js不记录某个url链接历史访问,返回时不返回该链接

    (function(){ var fnUrlReplace = function (eleLink) { if (!eleLink) { return; } var href = eleLink.hr ...

  7. php后台解决跨域

    protected function _initalize() { header("content-type:text/html;charset=utf-8"); header(& ...

  8. swiper-wrapper轮滑组件(多组轮滑界面)间隔无效问题

    在多组此种轮滑效果出现时,你需要加两个属性值,即 new Swiper('.swiper-container', { slidesPerView: 3, slidesPerColumn: 2, spa ...

  9. 重磅来袭!!!Elasticsearch7.14.1(ES 7.14.1)与Springboot2.5.4的整合

    1. 概述 前面我们聊了 Elasticsearch(ES)集群的搭建,今天我们来聊一下,Elasticsearch(ES)集群如何与 Springboot 进行整合. Elasticsearch(E ...

  10. 事项同步事项编码(mt_code)长度超过数据库限制的varchar(32)线上问题

    改下长度限制重新同步下,可以恢复正常!