Linux系统之部署FTP服务器

简介: Linux系统之部署FTP服务器

一、FTP介绍

FTP(File Transfer Protocol,文件传输协议) 是 TCP/IP 协议组中的协议之一。FTP协议包括两个组成部分,其一为FTP服务器,其二为FTP客户端。默认情况下FTP协议使用TCP端口中的 20和21这两个端口,其中20用于传输数据,21用于传输控制信息。但是,是否使用20作为传输数据的端口与FTP使用的传输模式有关,如果采用主动模式,那么数据传输端口就是20;如果采用被动模式,则具体最终使用哪个端口要服务器端和客户端协商决定。

二、环境介绍

FTP服务端:hostname为control IP:192.168.200.150
FTP客户端:hostname为node1 IP: 192.168.200.135

三、FTP服务端搭建步骤

1.安装相关软件包

[root@control ~]# yum -y install ftp.x86_64 
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:01:45 ago on Tue 11 May 2021 06:57:05 PM CST.
Dependencies resolved.
====================================================================================================================================================================
 Package                            Arch                                  Version                                    Repository                                Size
====================================================================================================================================================================
Installing:
 ftp                                x86_64                                0.17-78.el8                                AppStream                                 70 k

Transaction Summary
====================================================================================================================================================================
Install  1 Package

Total size: 70 k
Installed size: 112 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                            1/1 
  Installing       : ftp-0.17-78.el8.x86_64                                                                                                                     1/1 
  Running scriptlet: ftp-0.17-78.el8.x86_64                                                                                                                     1/1 
  Verifying        : ftp-0.17-78.el8.x86_64                                                                                                                     1/1 
Installed products updated.

Installed:
  ftp-0.17-78.el8.x86_64                                                                                                                                            

Complete!

2.启动FTP并检查状态

[root@control ~]# systemctl enable --now vsftpd
Created symlink /etc/systemd/system/multi-user.target.wants/vsftpd.service → /usr/lib/systemd/system/vsftpd.service.
[root@control ~]# systemctl status vsftpd
● vsftpd.service - Vsftpd ftp daemon
   Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2021-05-11 18:59:51 CST; 9s ago
  Process: 2825 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
 Main PID: 2826 (vsftpd)
    Tasks: 1 (limit: 24900)
   Memory: 864.0K
   CGroup: /system.slice/vsftpd.service
           └─2826 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf

May 11 18:59:51 control systemd[1]: Starting Vsftpd ftp daemon...
May 11 18:59:51 control systemd[1]: Started Vsftpd ftp daemon.

3.检查服务端口运行状态

[root@control mail]# netstat -antup | grep ftp
tcp6       0      0 :::21                   :::*                    LISTEN      2826/vsftpd  

4.修改FTP配置文件

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

pam_service_name=vsftpd
userlist_enable=YES

5.关闭selinux及防火墙

 sed -i 's/SELINUX=enforcing/SELIUNUX=disabled/' /etc/selinux/config
 systemctl stop firewalld.service

备注:
防火墙如果要开启,则可开启以下端口:

firewall-cmd --zone=public --add-port=20/tcp --permanent
firewall-cmd --zone=public --add-port=21/tcp --permanent
firewall-cmd --zone=public --add-port=22/tcp --permanent
firewall-cmd --zone=public --add-port=30000-35000/tcp --permanent

三、客户端操作

1.安装软件包

[root@node1 ~]# yum -y install lftp
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Repository AppStream is listed more than once in the configuration
Repository BaseOS is listed more than once in the configuration
ansiable                                                                                                                            0.0  B/s |   0  B     00:00    
Failed to synchronize cache for repo 'ansiable', ignoring this repo.
Last metadata expiration check: 0:00:17 ago on Tue 11 May 2021 07:04:23 PM CST.
Dependencies resolved.
====================================================================================================================================================================
 Package                            Arch                                 Version                                      Repository                               Size
====================================================================================================================================================================
Installing:
 lftp                               x86_64                               4.8.4-1.el8                                  AppStream                               885 k

Transaction Summary
====================================================================================================================================================================
Install  1 Package

Total size: 885 k
Installed size: 3.0 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                            1/1 
  Installing       : lftp-4.8.4-1.el8.x86_64                                                                                                                    1/1 
  Running scriptlet: lftp-4.8.4-1.el8.x86_64                                                                                                                    1/1 
  Verifying        : lftp-4.8.4-1.el8.x86_64                                                                                                                    1/1 
Installed products updated.

Installed:
  lftp-4.8.4-1.el8.x86_64                                                                                                                                           

Complete!

2.查看客户端状态

[root@node1 ~]# ps -ef |grep ftp
root       1746   1745  0 18:56 ?        00:00:00 /usr/libexec/openssh/sftp-server

四.客户端测试登录情况

1.使用客户端本地账号user1登录

lftp 192.168.200.150:~> pwd
ftp://192.168.200.150
lftp 192.168.200.150:~> user user1
Password: 
lftp user1@192.168.200.150:~> ls
-rw-r--r--    1 0        0            3541 May 11 13:08 passwd
lftp user1@192.168.200.150:~> pwd
ftp://user1@192.168.200.150/%2Fhome/user1

2.测试上传下载文件

[root@node1 ~]# lftp 192.168.200.150
lftp 192.168.200.150:~> user user1
Password: 
lftp user1@192.168.200.150:~> ls
-rw-r--r--    1 0        0            3541 May 11 13:08 passwd
lftp user1@192.168.200.150:~> lcd /etc
lcd ok, local cwd=/etc
lftp user1@192.168.200.150:~> put group
1154 bytes transferred
lftp user1@192.168.200.150:~> get passwd 
get: /etc/passwd: file already exists and xfer:clobber is unset
相关文章
|
3月前
|
弹性计算 安全 Linux
阿里云服务器ECS安装宝塔Linux面板、安装网站(新手图文教程)
本教程详解如何在阿里云服务器上安装宝塔Linux面板,涵盖ECS服务器手动安装步骤,包括系统准备、远程连接、安装命令执行、端口开放及LNMP环境部署,手把手引导用户快速搭建网站环境。
|
5月前
|
Linux 网络安全 数据安全/隐私保护
使用Linux系统的mount命令挂载远程服务器的文件夹。
如此一来,你就完成了一次从你的Linux发车站到远程服务器文件夹的有趣旅行。在这个技术之旅中,你既探索了新地方,也学到了如何桥接不同系统之间的距离。
820 21
|
4月前
|
Java Linux 网络安全
Linux云端服务器上部署Spring Boot应用的教程。
此流程涉及Linux命令行操作、系统服务管理及网络安全知识,需要管理员权限以进行配置和服务管理。务必在一个测试环境中验证所有步骤,确保一切配置正确无误后,再将应用部署到生产环境中。也可以使用如Ansible、Chef等配置管理工具来自动化部署过程,提升效率和可靠性。
473 13
|
4月前
|
监控 Linux 网络安全
FinalShell SSH工具下载,服务器管理,远程桌面加速软件,支持Windows,macOS,Linux
FinalShell是一款国人开发的多平台SSH客户端工具,支持Windows、Mac OS X和Linux系统。它提供一体化服务器管理功能,支持shell和sftp同屏显示,命令自动提示,操作便捷。软件还具备加速功能,提升访问服务器速度,适合普通用户和专业人士使用。
842 0
|
4月前
|
存储 安全 Linux
Linux服务器上安装配置GitLab的步骤。
按照以上步骤,一个基础的GitLab服务应该运行并可以使用。记得定期检查GitLab官方文档,因为GitLab的安装和配置步骤可能随着新版本而变化。
341 0
|
6月前
|
存储 安全 Ubuntu
从Linux到Windows:阿里云服务器系统镜像适配场景与选择参考
阿里云为用户提供了丰富多样的服务器操作系统选择,以满足不同场景下的应用需求。目前,云服务器的操作系统镜像主要分为公共镜像、自定义镜像、共享镜像、镜像市场和社区镜像五大类。以下是对这些镜像类型的详细介绍及选择云服务器系统时需要考虑的因素,以供参考。
|
5月前
|
Linux
Linux下版本控制器(SVN) -服务器端环境搭建步骤
Linux下版本控制器(SVN) -服务器端环境搭建步骤
244 0
Linux下版本控制器(SVN) -服务器端环境搭建步骤
|
7月前
|
Ubuntu 安全 网络安全
在Ubuntu系统下使用vsftpd配置FTP服务器的步骤
以上就是在Ubuntu系统下使用vsftpd配置FTP服务器的步骤。这些步骤都是基础的,但足够让你建立一个简单的FTP服务器。如果你需要更高级的功能,例如SSL加密、虚拟用户等,你可能需要进一步研究vsftpd的配置选项。
403 13
|
11月前
|
安全 编译器 Linux
深入解析与防范:基于缓冲区溢出的FTP服务器攻击及调用计算器示例
本文深入解析了利用缓冲区溢出漏洞对FTP服务器进行远程攻击的技术,通过分析FreeFlow FTP 1.75版本的漏洞,展示了如何通过构造过长的用户名触发缓冲区溢出并调用计算器(`calc.exe`)。文章详细介绍了攻击原理、关键代码组件及其实现步骤,并提出了有效的防范措施,如输入验证、编译器保护和安全编程语言的选择,以保障系统的安全性。环境搭建基于Windows XP SP3和Kali Linux,使用Metasploit Framework进行攻击演示。请注意,此内容仅用于教育和研究目的。
329 4
|
网络协议 文件存储 Windows
Windows Server 2019 FTP服务器搭建
Windows Server 2019 FTP服务器搭建
391 0