第一步:我们先将linux服务端的ftp安装,命令是:
yum install -y *ftp*(我懒得多打了,就用*号代替)
[root@localhost ~]# yum install -y *ftp*
Last metadata expiration check: 2:50:58 ago on Tue 04 Oct 2022 04:50:42 AM EDT.
Package python3-requests-ftp-0.3.1-11.el8.noarch is already installed.
Dependencies resolved.
===================================================================================================================================================================================================================
Package Architecture Version Repository Size
===================================================================================================================================================================================================================
Installing:
ftp x86_64 0.17-78.el8 AppStream 69 k
lftp x86_64 4.8.4-2.el8 AppStream 882 k
lftp-scripts noarch 4.8.4-2.el8 AppStream 28 k
syslinux-tftpboot noarch 6.04-5.el8 BaseOS 462 k
tftp x86_64 5.2-24.el8 AppStream 41 k
tftp-server x86_64 5.2-24.el8 AppStream 49 k
vsftpd x86_64 3.0.3-35.el8 AppStream 180 k
Installing dependencies:
perl-String-CRC32 x86_64 1.6-4.el8 AppStream 23 k
Transaction Summary
===================================================================================================================================================================================================================
Install 8 Packages
Total size: 1.7 M
Installed size: 4.5 M
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : perl-String-CRC32-1.6-4.el8.x86_64 1/8
Installing : lftp-4.8.4-2.el8.x86_64 2/8
Running scriptlet: lftp-4.8.4-2.el8.x86_64 2/8
Installing : lftp-scripts-4.8.4-2.el8.noarch 3/8
Installing : vsftpd-3.0.3-35.el8.x86_64 4/8
Running scriptlet: vsftpd-3.0.3-35.el8.x86_64 4/8
Installing : tftp-server-5.2-24.el8.x86_64 5/8
Running scriptlet: tftp-server-5.2-24.el8.x86_64 5/8
Installing : tftp-5.2-24.el8.x86_64 6/8
Installing : ftp-0.17-78.el8.x86_64 7/8
Installing : syslinux-tftpboot-6.04-5.el8.noarch 8/8
Running scriptlet: syslinux-tftpboot-6.04-5.el8.noarch 8/8
Verifying : syslinux-tftpboot-6.04-5.el8.noarch 1/8
Verifying : ftp-0.17-78.el8.x86_64 2/8
Verifying : lftp-4.8.4-2.el8.x86_64 3/8
Verifying : lftp-scripts-4.8.4-2.el8.noarch 4/8
Verifying : perl-String-CRC32-1.6-4.el8.x86_64 5/8
Verifying : tftp-5.2-24.el8.x86_64 6/8
Verifying : tftp-server-5.2-24.el8.x86_64 7/8
Verifying : vsftpd-3.0.3-35.el8.x86_64 8/8
Installed:
ftp-0.17-78.el8.x86_64 lftp-4.8.4-2.el8.x86_64 lftp-scripts-4.8.4-2.el8.noarch perl-String-CRC32-1.6-4.el8.x86_64 syslinux-tftpboot-6.04-5.el8.noarch tftp-5.2-24.el8.x86_64 tftp-server-5.2-24.el8.x86_64
vsftpd-3.0.3-35.el8.x86_64
Complete!
第二步:将防火墙和selinux等服务关闭,命令:
setenforce 0
systemctl stop firewalld
[root@localhost ~]# iptables -F
[root@localhost ~]# iptables -X
[root@localhost ~]# iptables -Z #这三条把防火墙默认策略清空
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl stop firewalld
第三步:将ftp服务开启
systemctl restart vsftpd
[root@localhost srv]# systemctl restart vsftpd
[root@localhost srv]# netstat -nltp| grep 21 #查看ftp服务是否开启
tcp6 0 0 :::21 :::* LISTEN 9528/vsftpd
[root@localhost srv]# systemctl status vsftpd #实在不放心可以用这条命令看
● vsftpd.service - Vsftpd ftp daemon
Loaded: loaded (/usr/lib/systemd/system/vsftpd.service; disabled; vendor preset: disabled)
Active: active (running) since Tue 2022-10-04 07:43:08 EDT; 3min 4s ago
Process: 9527 ExecStart=/usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf (code=exited, status=0/SUCCESS)
Main PID: 9528 (vsftpd)
Tasks: 1 (limit: 4770)
Memory: 824.0K
CGroup: /system.slice/vsftpd.service
└─9528 /usr/sbin/vsftpd /etc/vsftpd/vsftpd.conf
Oct 04 07:43:08 localhost.localdomain systemd[1]: Starting Vsftpd ftp daemon...
Oct 04 07:43:08 localhost.localdomain systemd[1]: Started Vsftpd ftp daemon.
好了,linux的就配好了,现在我们来到Windows服务端。
第一步,安装ftp服务:
点击它
按照图中的步骤来
没图的步骤直接下一步就好了
最后安装就好了
第二步,网络的连通性,安装完后,我们就win键+R键打开允许,输入cmd
然后就是ping一下linux服务端,如果跟下面的图一样ping不通的话
我推荐几个解决方法:
一,将防火墙关闭
二,如果是Windows server2016的话,那就进入防火墙的高级配置里,将如图的规则开启
三,如果上面两个都解决不了问题的话,那么看一下是不是网卡不同,两者相通必须要网卡一样,网段,DNS还有网关,都要一样 。
四,如果还是不通那就是网络环境的原因。
第三步,连通后就是登录linux服务端的ftp,但在此之前,我们还要到linux服务端创建一个普通用户cc
[root@localhost ~]# useradd cc
[root@localhost ~]# passwd cc
Changing password for user cc.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
好了,现在再回到Windows服务端在运行界面继续输出
C:\Users\Administrator>ping 20.20.20.22
正在 Ping 20.20.20.22 具有 32 字节的数据:
来自 20.20.20.22 的回复: 字节=32 时间<1ms TTL=64
来自 20.20.20.22 的回复: 字节=32 时间<1ms TTL=64
来自 20.20.20.22 的回复: 字节=32 时间<1ms TTL=64
来自 20.20.20.22 的回复: 字节=32 时间<1ms TTL=64
20.20.20.22 的 Ping 统计信息:
数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
最短 = 0ms,最长 = 0ms,平均 = 0ms
C:\Users\Administrator>ftp #使用ftp服务
ftp> open 20.20.20.22 #用open命令连接linux客服端
连接到 20.20.20.22。
220 (vsFTPd 3.0.3)
200 Always in UTF8 mode.
用户(20.20.20.22:(none)): root #root用户无法登录
530 Permission denied.
登录失败。
ftp> quit #退出重新连接
421 Timeout.
C:\Users\Administrator>ftp #linux的也是一样的
ftp> open 20.20.20.22
连接到 20.20.20.22。
220 (vsFTPd 3.0.3)
200 Always in UTF8 mode.
用户(20.20.20.22:(none)): cc #这个是普通用户
331 Please specify the password.
密码:
230 Login successful.
ftp> cd / #可以使用linux的命令cd进入根目录
250 Directory successfully changed.
ftp> dir #可以使用Windows的命令查看目录
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
lrwxrwxrwx 1 0 0 7 Oct 11 2021 bin -> usr/bin
dr-xr-xr-x 5 0 0 4096 Sep 30 20:05 boot
drwxr-xr-x 20 0 0 3220 Oct 04 08:18 dev
drwxr-xr-x 147 0 0 8192 Oct 04 13:43 etc
drwxr-xr-x 5 0 0 41 Oct 04 13:43 home
lrwxrwxrwx 1 0 0 7 Oct 11 2021 lib -> usr/lib
lrwxrwxrwx 1 0 0 9 Oct 11 2021 lib64 -> usr/lib64
drwxr-xr-x 2 0 0 6 Oct 11 2021 media
drwxr-xr-x 4 0 0 31 Oct 03 06:30 mnt
drwxr-xr-x 2 0 0 6 Oct 11 2021 opt
dr-xr-xr-x 247 0 0 0 Oct 04 08:17 proc
dr-xr-x--- 15 0 0 4096 Oct 04 08:31 root
drwxr-xr-x 43 0 0 1280 Oct 04 08:33 run
lrwxrwxrwx 1 0 0 8 Oct 11 2021 sbin -> usr/sbin
drwxr-xr-x 4 0 0 30 Oct 03 07:55 srv
dr-xr-xr-x 13 0 0 0 Oct 04 08:18 sys
drwxr-xr-x 2 0 0 4096 Oct 04 11:41 tftpboot
drwxrwxrwt 17 0 0 4096 Oct 04 14:26 tmp
drwxr-xr-x 13 0 0 158 Sep 30 17:14 usr
drwxr-xr-x 21 0 0 4096 Sep 30 20:04 var
226 Directory send OK.
ftp: 收到 1284 字节,用时 0.07秒 18.88千字节/秒。
这时我们再来到linux服务端,创建一个/cc/aa/bb.txt,内容是“hi!”的文件
[root@localhost ~]# mkdir -p /cc/aa
[root@localhost ~]# echo "hi!" > /cc/aa/bb.txt
然后再来到Windows服务端这边,将bb.txt文件下载下来
ftp> cd /cc/aa
250 Directory successfully changed.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
bb.txt
226 Directory send OK.
ftp: 收到 11 字节,用时 0.00秒 3.67千字节/秒。
ftp> get bb.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for bb.txt (4 bytes).
226 Transfer complete.
ftp: 收到 4 字节,用时 0.00秒 4000.00千字节/秒。
它被放在C:\用户\Administrator目录里,点击打开,可以看到是内容对的
现在我们再来试一下上传文件
ftp> put C:\haihai.txt
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
ftp: 发送 18 字节,用时 0.00秒 9.00千字节/秒。
我们再到linux上看一下,内容也是对的
[root@localhost ~]# cd /home/cc/
[root@localhost cc]# ls
haihai.txt
[root@localhost cc]# cat haihai.txt
卧槽,尼玛?
不指定安装和发送位置,默认都是在登录用户的家目录下,好了现在就可以了。