ftp有两个端口(21是控制端口,20数据端口),有两种工作模式:1.端口模式/主动模式 2.被动模式
客户端决定服务器
telnet测试
1.先安装 yum install telnet
[root@slave1 ~]# telnet 192.168.88.101 21 Trying 192.168.88.101... Connected to 192.168.88.101. Escape character is '^]'. 220 (vsFTPd 3.0.2) user ftp 331 Please specify the password. pass ftp 230 Login successful. PORT 192,168,88,102,48,57 # 256*48+57=12345 200 PORT command successful. Consider using PASV. list 150 Here comes the directory listing. 226 Directory send OK. quit 221 Goodbye. Connection closed by foreign host.
2. 安装 yum install nc
[root@slave1 ~]# nc -l 192.168.88.102 12345 -rw-r--r-- 1 0 0 0 Jul 15 02:37 1.txt -rw-r--r-- 1 0 0 0 Jul 15 02:37 2.txt drwxr-xr-x 2 0 0 6 Jul 15 02:35 aa drwxr-xr-x 2 0 0 6 Oct 30 2018 pub
二.匿名服务
1.更改配置文件
[root@mysqlb ~]# vim /etc/vsftpd/vsftpd.conf
anon_upload_enable=YES 允许匿名用户上传文件 # # Uncomment this if you want the anonymous FTP user to be able to create # new directories. #anon_mkdir_write_enable=YES
2.给目录加权限
[root@mysqlb ftp]# mkdir /var/ftp/panda [root@mysqlb ftp]# ls 1.txt 2.txt aa panda pub [root@mysqlb ftp]# chmod 777 panda [root@mysqlb ftp]# ll -d panda drwxrwxrwx. 2 root root 6 7月 15 18:17 panda
3.重启服务
[root@mysqlb ~]# systemctl restart vsftpd
4.用另一个用户登录ftp
[root@slave1 ~]# lftp 192.168.88.101 lftp 192.168.88.101:~> ls -rw-r--r-- 1 0 0 0 Jul 15 02:37 1.txt -rw-r--r-- 1 0 0 0 Jul 15 02:37 2.txt drwxr-xr-x 2 0 0 6 Jul 15 02:35 aa drwxrwxrwx 2 0 0 6 Jul 15 10:17 panda drwxr-xr-x 2 0 0 6 Oct 30 2018 pub lftp 192.168.88.101:/> cd panda lftp 192.168.88.101:/panda> put /etc/passwd 1027 bytes transferred lftp 192.168.88.101:/panda> ls -rw------- 1 14 50 1027 Jul 15 10:18 passwd lftp 192.168.88.101:/panda> quit