Linux下vsftp服务器—上传、下载

一.  FTP 说明
Linux下常用的FTP Server是vsftp(Very Security File Transfer Protocol),及profpt(Professtional ftp)。本文简单说明下vsfpt的配置。

vsftp提供3种登陆方式:
1、匿名登录方式
   就是不需要用户名,密码。就能登录到ftp服务器。
2、本地用户方式
   需要帐户名和密码才能登录。而且,这个帐户名和密码,都是在你linux系统里面,已经有的用户。
3、虚拟用户方式
   同样需要用ftp户名和密码才能登录。但是和上面的区别就是,这个用户名和密码,在你linux系统中是没有的(没有该用户帐号)

二.  Vsftp的安装配置
2.1  安装
# yum install vsftpd

2.2. 相关命令
2.2.1 启动与关闭
# service vsftpd start
Redirecting to /bin/systemctl  start vsftpd.service

# service vsftpd stop
Redirecting to /bin/systemctl  stop vsftpd.service

# service vsftpd restart
Redirecting to /bin/systemctl  restart vsftpd.service

2.2.2 ftp相关操作(此处演示用本地用户登陆操作)
(1)以系统用户及密码登陆
$ ftp 192.168.0.100
Connected to 192.168.0.100 (192.168.0.100).
220 (vsFTPd 3.0.0)
Name (192.168.0.100:tough): tough
331 Please specify the password.
Password:

230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

(2)pwd-打印ftp服务器端的当前目录
ftp> pwd
257 "/home/tough"

(3)cd-进入ftp服务器端的子目录
ftp> cd ftp
250 Directory successfully changed.

(4)ls-显示ftp服务器端的文件列表
ftp> ls
227 Entering Passive Mode (192,168,0,100,149,127).
150 Here comes the directory listing.
-rw-rw-r--    1 1000     1000            0 Oct 16 16:18 a.txt
-rw-rw-r--    1 1000     1000            0 Oct 16 16:18 b.txt
-rw-rw-r--    1 1000     1000            0 Oct 16 16:18 c.txt

226 Directory send OK.

(5)!pwd-打印客户端的当前目录
ftp> !pwd
/tmp/testftp

(6)!ls-显示客户端的文件列表
ftp> !ls -l
total 0
-rw-rw-r-- 1 tough tough 0 Oct 17 00:18 a.java
-rw-rw-r-- 1 tough tough 0 Oct 17 00:21 a.php
-rw-rw-r-- 1 tough tough 0 Oct 17 00:18 b.java
-rw-rw-r-- 1 tough tough 0 Oct 17 00:21 b.php

(7)get-从服务器端下载文件
ftp> get a.txt 
local: a.txt remote: a.txt
227 Entering Passive Mode (192,168,0,100,67,53).
150 Opening BINARY mode data connection for a.txt (0 bytes).
226 Transfer complete.

(8)mget-批量下载
ftp> mget *
mget a.txt? 
227 Entering Passive Mode (192,168,0,100,150,33).
150 Opening BINARY mode data connection for a.txt (0 bytes).
226 Transfer complete.
mget b.txt? 
227 Entering Passive Mode (192,168,0,100,227,239).
150 Opening BINARY mode data connection for b.txt (0 bytes).
226 Transfer complete.
mget c.txt? 
227 Entering Passive Mode (192,168,0,100,203,53).
150 Opening BINARY mode data connection for c.txt (0 bytes).
226 Transfer complete.

ftp> !ls -l
total 0
-rw-rw-r-- 1 tough tough 0 Oct 17 00:18 a.java
-rw-rw-r-- 1 tough tough 0 Oct 17 00:21 a.php

-rw-rw-r-- 1 tough tough 0 Oct 17 00:20 a.txt
-rw-rw-r-- 1 tough tough 0 Oct 17 00:18 b.java
-rw-rw-r-- 1 tough tough 0 Oct 17 00:21 b.php

-rw-rw-r-- 1 tough tough 0 Oct 17 00:20 b.txt
-rw-rw-r-- 1 tough tough 0 Oct 17 00:20 c.txt

(为了区分,此处我们将ftp服务器端文件标为绿色,本地文件标为蓝色)

(9)put-上传本地文件到ftp服务器
ftp> put a.php
local: a.php
227 Entering Passive Mode (192,168,0,100,201,17).
150 Ok to send data.
226 Transfer complete.

(10)mput-批量上传
ftp> mput *.java /home/tough/ftp
mput a.java? 
227 Entering Passive Mode (192,168,0,100,148,208).
150 Ok to send data.
226 Transfer complete.
mput b.java? 
227 Entering Passive Mode (192,168,0,100,207,24).
150 Ok to send data.
226 Transfer complete.
mput /home/tough/ftp? 
/home/tough/ftp: not a plain file.

ftp> ls -l
227 Entering Passive Mode (192,168,0,100,107,170).
150 Here comes the directory listing.
-rw-r--r--    1 1000     1000            0 Oct 16 16:23 a.java
-rw-rw-r--    1 1000     1000            0 Oct 16 16:18 a.txt
-rw-r--r--    1 1000     1000            0 Oct 16 16:23 b.java
-rw-r--r--    1 1000     1000            0 Oct 16 16:21 a.php

-rw-rw-r--    1 1000     1000            0 Oct 16 16:18 b.txt
-rw-rw-r--    1 1000     1000            0 Oct 16 16:18 c.txt

226 Directory send OK.

 

原文地址:https://www.cnblogs.com/toughhou/p/3778774.html