温馨提示×

ubuntu如何连接ftpserver

小樊
47
2026-07-07 08:13:59
栏目: 智能运维

在 Ubuntu 上连接 FTP 服务器,常见有几种方式:命令行(推荐)图形界面挂载为本地目录。下面按常见场景给你详细说明。


一、使用命令行连接 FTP 服务器(最常用)

1️⃣ 使用 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 不加密,不推荐在公网使用。


2️⃣ 使用 lftp(强烈推荐 ✅)

支持 FTP / FTPS / SFTP,功能强大。

安装

sudo apt install lftp

连接普通 FTP

lftp ftp://user@ftp.example.com

连接 FTPS(显式加密)

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

3️⃣ 使用 sftp(如果是 SSH 协议)

如果服务器是 SFTP(SSH File Transfer Protocol)

sftp user@ftp.example.com

命令类似:

ls
get file
put file
exit

加密、安全、推荐


二、使用图形界面连接 FTP

1️⃣ 使用 FileZilla(最流行)

安装:

sudo apt install filezilla

使用:

  • 协议:FTP / FTPS / SFTP
  • 主机:ftp.example.com
  • 用户名 / 密码
  • 端口(默认 21)

✅ 支持 FTPS(TLS)


2️⃣ 使用 Ubuntu 自带文件管理器(Nautilus)

打开 文件(Files)

点击:

其他位置 → 连接到服务器

输入:

ftp://user@ftp.example.com

ftps://user@ftp.example.com

⚠️ 部分 FTPS 支持有限


三、将 FTP 挂载为本地目录(高级)

使用 curlftpfs

sudo 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

❌ FTPS 证书错误

set ssl:verify-certificate no

五、推荐方案总结 ✅

场景 推荐方式
安全传输 SFTP / FTPS + lftp
图形界面 FileZilla
脚本/自动化 lftp
临时使用 Nautilus

如果你愿意,可以告诉我:

  • ✅ 是 FTP / FTPS / SFTP
  • ✅ 是否需要 命令行还是图形界面
  • ✅ 服务器地址、端口(可脱敏)

我可以直接给你一条可用的连接命令

0