Linux笔记01:部署FTP服务器

一、FTP协议
FTP协议是一种在互联网上进行文件传输的协议,默认端口20/21端口,端口20用于数据传输,21端口用于接受客户端发出的相关命令和参数

FTP分主动模式和被动模式
主动模式:FTP服务器主动向客户端发起连接请求
被动模式:FTP服务器等待客户端发起连接请求(默认)

二、部署FTP服务器
FTP服务器通过安装vftpd服务程序来进行部署

系统:centos7
准备:关闭防火墙,SElinux
方式:yum安装
软件:vsftpd
配置文件:/etc/vsftpd/vsftpd.conf
端口:21/tcp 命令连接端口
22/tcp 数据连接端口(主动)
FTP根目录:用户宿主目录
访问方式:匿名用户访问
用户认证访问

示例:搭建匿名访问的ftp服务器

[root@ftpserver ~]# yum install -y vsftpd

启动vsftp服务程序,并设置开机自启

[root@ftpserver ~]# systemctl start vsftpd
[root@ftpserver ~]# systemctl enable vsftpd
[root@ftpserver ~]# ss -antp|grep vsftpd
LISTEN    0  32  :::21        :::*               users:(("vsftpd",pid=1059,fd=3))

测试能否访问

[root@client ~]# yum install -y lftp
[root@client ~]# lftp 192.168.122.101
lftp 192.168.122.101:~> ls
drwxr-xr-x    2 0        0               6 Aug 03  2017 pub

允许匿名用户上传文件

[root@ftpserver ~]# chmod o+x /var/ftp/pub/

anon_upload_enable=YES          >>>允许上传文件 
anon_mkdir_write_enable=YES     >>>允许上传目录   
anon_other_write_enable=YES     >>>允许其他的修改(删除、重命名等)

anon_umask=022                  >>>允许其他用户能下载匿名用户的文件     

anon_root=/company              >>>更改匿名用户的FTP的根目录   

验证:

[root@client ~]# lftp 192.168.122.101
lftp 192.168.122.101:/> cd pub/
lftp 192.168.122.101:/pub> mkdir a.file
mkdir 成功, 建立 `a.file'
lftp 192.168.122.101:/pub> ls
drwxr-xr-x    2 14       50              6 Jun 12 02:29 a.file

猜你喜欢

转载自blog.51cto.com/12244079/2128327