CentOS 7搭建 ftp 服务器

CentOS 7搭建 ftp 服务器,第1张

一、实验环境

一台Linux客户端、一台Linux服务器、一台Windows客户端

二、实验内容

1、创建一个ftp服务器,提供文件下载和上传功能。 2、提供匿名登录功能,用户能够上传文件,但不能删除文件。 3、创建用户登录ftp服务,允许用户任意写 *** 作。 4、ftp黑白名单。

三、实验步骤

1.软件安装

Linux系统中,是vsftpd提供的ftp的服务(没有依赖包,看直接使用yum安装,也可光盘安装)。

[root@localhost /]# yum install vsftpd -y

查询是否成功安装FTP服务。

[root@localhost ~]# rpm -q vsftpd vsftpd-3.0.2-22.el7.x86_64

FTP默认配置文件目录

etc/vsftpd/vsftpd.comf ftp服务器的配置文件 /etc/pam.d/vsftpd /etc/vsftpd/ftpusers 禁止登录用户名单,默认root不能登录 /etc/vsftpd/user_list 可以通过设置只有这个名单里的用户可以登录,如果同一用户同时出现在ftpusers和user_listname该用户也是被禁止登录,取最高权限 /var/ftp ftp的根目录,默认登陆位置 /var/ftp/pub


实验内容 1 :创建一个 f t p 服务器,提供文件下载和上传功能。 实验内容1:创建一个ftp服务器,提供文件下载和上传功能。 实验内容1:创建一个ftp服务器,提供文件下载和上传功能。

1、编辑etc/vsftpd/vsftpd.comf配置文件。确认以下状态为YES。

anonymous_enable=YES #开启匿名用户访问,默认已开启。 write_enable=YES #开放服务器的写权限(若要上传必须开启)。默认已开启。 anon_upload_enable=YES #允许匿名用户上传文件,默认是注释的,需要取消注释 。 anon_mkdir_write_enable=YES #允许匿名用户创建(上传)目录,默认是注释的,需要取消注释。

2、防火墙放行FTP服务

[root@localhost ~]# firewall-cmd --add-service=ftp --permanent success [root@localhost ~]# firewall-cmd --reload success

3、关闭selinux

临时关闭selinux,如未关闭可能导致服务访问不成功。

[root@localhost ~]# setenforce 0 [root@localhost ~]# getenforce Permissive

在/etc/selinux/config 文件下永久性关闭selinux

4、启动FTP服务

[root@localhost ~]# systemctl start vsftpd //启动服务器 [root@localhost ~]# systemctl enable vsftpd //开机自启服务 Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/systemd/system/vsftpd.service. [root@localhost ~]# systemctl status vsftpd //查看服务器状态 ● vsftpd.service - Vsftpd ftp daemon Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled) Active: active (running) since 三 2022-11-16 22:08:50 EST; 1min 43s ago Main PID: 51249 (vsftpd) CGroup: /system.slice/vsftpd.service └─51249 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf11月 16 22:08:50 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon... 11月 16 22:08:50 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.

5、Linux客户端测试服务,安装客户端工具


CentOS 7搭建 ftp 服务器,在这里插入图片描述,第2张

测试服务

[root@localhost ~]# ftp 192.168.137.128 //连接服务 Connected to 192.168.137.128 (192.168.137.128). 220 (vsFTPd 3.0.2) Name (192.168.137.128:root): anonymous //输入匿名用户 331 Please specify the password. Password: //无密码 回车 230 Login successful. //登录成功 Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 227 Entering Passive Mode (192,168,137,128,214,191). 150 Here comes the directory listing. drwxr-xr-x 2 0 0 6 Aug 03 2017 pub 226 Directory send OK. ftp> bye 221 Goodbye.

6、Windows客户端测试服务

匿名用户可以在/var/ftp/pub目录上传文件和创建目录


CentOS 7搭建 ftp 服务器,在这里插入图片描述,第3张

实验内容 2 :提供匿名登录功能,用户能够上传文件,但不能删除文件。 实验内容2:提供匿名登录功能,用户能够上传文件,但不能删除文件。 实验内容2:提供匿名登录功能,用户能够上传文件,但不能删除文件。

匿名用户主目录创建测试文件

root@localhost ~]# cd /var/ftp/ [root@localhost ftp]# touch pub/1.txt

修改配置文件,设置用户匿名用户权限。
CentOS 7搭建 ftp 服务器,在这里插入图片描述,第4张

重启FTP服务

[root@localhost ~]# systemctl restart vsftpd

Windows客户端测试服务
CentOS 7搭建 ftp 服务器,在这里插入图片描述,第5张
实验内容 3 :创建用户登录 f t p 服务,允许用户任意写 *** 作。 实验内容3:创建用户登录ftp服务,允许用户任意写 *** 作。 实验内容3:创建用户登录ftp服务,允许用户任意写 *** 作。

编辑配置文件。将anonymous_enable=YES改为NO。即可使用用户账户登录。

CentOS 7搭建 ftp 服务器,在这里插入图片描述,第6张

设置访问账户与密码。

[root@localhost /]# useradd gd1 [root@localhost /]# passwd gd1 更改用户 gd1 的密码 。 新的 密码: 无效的密码: 密码未通过字典检查 - 它基于字典单词 重新输入新的 密码: passwd:所有的身份验证令牌已经成功更新。

重启服务

[root@localhost ~]# systemctl restart vsftpd

Linux客户端测试,使用用户登录。(测试成功)

[root@localhost /]# ftp 192.168.137.128 Connected to 192.168.137.128 (192.168.137.128). 220 (vsFTPd 3.0.2) Name (192.168.137.128:root): gd1 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> pwd 257 "/home/gd1" ftp> mkdir 1.txt 257 "/home/gd1/1.txt" created

Windows客户端测试
CentOS 7搭建 ftp 服务器,在这里插入图片描述,第7张
CentOS 7搭建 ftp 服务器,在这里插入图片描述,第8张

实验内容 4 : F T P 黑白名单 实验内容4:FTP黑白名单 实验内容4FTP黑白名单

创建用户CentOS 7搭建 ftp 服务器,在这里插入图片描述,第9张

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

文件末尾添加,命令说明:仅允许文件中的用户登录服务(反之如果开启此参数,那么就不能使用文件中的用户进行登录)
CentOS 7搭建 ftp 服务器,在这里插入图片描述,第10张

编辑用户名单文件,加入gd1用户。

CentOS 7搭建 ftp 服务器,在这里插入图片描述,第11张

重启服务

[root@localhost ~]# systemctl restart vsftpd

Linux客户端测试

使用文件中已有的用户登录测试,成功登录

CentOS 7搭建 ftp 服务器,在这里插入图片描述,第12张

使用文件中未出现的用户登录测试,登录失败

CentOS 7搭建 ftp 服务器,在这里插入图片描述,第13张

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/13518104.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-12-27
下一篇 2023-12-29

发表评论

登录后才能评论

评论列表(0条)

保存