一、FTP介绍

FTP(FileTransferProtocol,文件传输合同)是TCP/IP合同组中的合同之一。FTP合同包括两个组成部份国内linux主机,其二为FTP服务器,其一为FTP顾客端。默认情况下FTP合同使用TCP端口中的20和21这两个端口,其中20用于传输数据,21用于传输控制信息。并且linux ftp服务器软件,是否使用20作为传输数据的端口与FTP使用的传输模式有关linux开发培训,假若采用主动模式,这么数据传输端口就是20;假若采用被动模式,则具体最终使用那个端口要服务器端和顾客端协商决定。

二、环境介绍

FTP服务端:hostname为controlIP:192.168.200.150

FTP顾客端:hostname为node1IP: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:

linux ftp服务器软件_linux服务器软件_linux服务器管理软件

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

linux服务器管理软件_linux服务器软件_linux ftp服务器软件

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

linux服务器管理软件_linux ftp服务器软件_linux服务器软件

5.关掉selinux及防火墙

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

备注:

防火墙假如要开启linux ftp服务器软件,则可开启以下端口:

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

linux ftp服务器软件_linux服务器软件_linux服务器管理软件

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

Tagged:
Author

这篇优质的内容由TA贡献而来

刘遄

《Linux就该这么学》书籍作者,RHCA认证架构师,教育学(计算机专业硕士)。

发表回复