在 Ubuntu 上连接 FTP 服务器,常见有几种方式:命令行(推荐)、图形界面、挂载为本地目录。下面按常见场景给你详细说明。
ftp 命令(基础)sudo apt update
sudo apt install ftp
连接:
ftp ftp.example.com
或指定端口:
ftp -p ftp.example.com 2121
登录后常用命令:
ls
cd dir
get file.txt
put file.txt
bye
⚠️ 注意:ftp 不加密,不推荐在公网使用。
lftp(强烈推荐 ✅)支持 FTP / FTPS / SFTP,功能强大。
sudo apt install lftp
lftp ftp://user@ftp.example.com
lftp -u user,password ftp://ftp.example.com
set ftp:ssl-allow yes
或者:
lftp
open ftp://ftp.example.com
set ftp:ssl-allow yes
login user password
ls
get file.zip
mirror remote_dir local_dir
put file.zip
sftp(如果是 SSH 协议)如果服务器是 SFTP(SSH File Transfer Protocol):
sftp user@ftp.example.com
命令类似:
ls
get file
put file
exit
✅ 加密、安全、推荐
安装:
sudo apt install filezilla
使用:
FTP / FTPS / SFTPftp.example.com✅ 支持 FTPS(TLS)
打开 文件(Files)
点击:
其他位置 → 连接到服务器
输入:
ftp://user@ftp.example.com
或
ftps://user@ftp.example.com
⚠️ 部分 FTPS 支持有限
curlftpfssudo apt install curlftpfs
mkdir ~/ftp
curlftpfs ftp://user:password@ftp.example.com ~/ftp
卸载:
fusermount -u ~/ftp
✅ 像本地目录一样使用
ping ftp.example.com
telnet ftp.example.com 21
lftp
set ftp:passive-mode yes
set ssl:verify-certificate no
| 场景 | 推荐方式 |
|---|---|
| 安全传输 | SFTP / FTPS + lftp |
| 图形界面 | FileZilla |
| 脚本/自动化 | lftp |
| 临时使用 | Nautilus |
如果你愿意,可以告诉我:
我可以直接给你一条可用的连接命令 ✅