CurlFtpFS

出自 ArchWiki

CurlFtpFS 是一个基于 FUSE 和 libcurl 的用于访问 FTP 主机的文件系统。

安装

安装 curlftpfs 软件包。

确保 内核模块 已加载。

# modprobe fuse

以 root 身份挂载 FTP 文件夹

创建挂载点,然后挂载 FTP 文件夹。

# mkdir /mnt/ftp
# curlftpfs ftp.example.com /mnt/ftp/ -o user=username:password

如果您想授予其他(普通)用户访问权限,请使用 allow_other 选项

# curlftpfs ftp.example.com /mnt/ftp/ -o user=username:password,allow_other

请勿在逗号后添加空格,否则 allow_other 参数将无法识别。

要在主动模式下使用 FTP,请添加选项 ftp_port=-

# curlftpfs ftp.example.com /mnt/ftp/ -o user=username:password,allow_other,ftp_port=-

您可以将此行添加到 /etc/fstab 以自动挂载。

curlftpfs#USER:PASSWORD@ftp.example.com /mnt/exampleorg fuse auto,user,uid=1000,allow_other,_netdev 0 0
提示: 当服务器不支持 UTF8,并且您在使用非美式英语字符时遇到问题,您可以使用 codepage="string",例如 codepage="iso8859-1"

为了防止密码显示在进程列表中,请在运行 curlftpfs 的用户的 home 目录下创建一个 .netrc 文件,并使用以下内容 chmod 600

machine ftp.example.com
login username
password mypassword

以普通用户身份挂载 FTP 文件夹

您也可以以普通用户身份挂载(始终使用 .netrc 文件进行凭据和 ssl 加密!)

$ mkdir ~/example
$ curlftpfs -o ssl,utf8 ftp://example.com/ ~/example

如果答案是

Error connecting to ftp: QUOT command failed with 500

那么服务器不支持 utf8 选项。将其省略,一切都会正常。

提示: 如果需要,请尝试使用例如 -o codepage="iso8859-1" 设置编码。

卸载

$ fusermount -u ~/example

连接到加密服务器

在其默认设置中,当连接到非加密连接端口时,CurlFtpFS 将以明文方式进行身份验证。如果远程服务器配置为拒绝非加密身份验证方法/强制加密身份验证,CurlFtpFS 将返回一个

# Error connecting to ftp: Access denied: 530

要使用显式加密身份验证对 ftp 服务器进行身份验证,您必须指定 ssl 选项。

# curlftpfs ftp.example.com /mnt/ftp/ -o ssl,user=username:password

如果您的服务器使用计算机不信任的自生成证书,您可以指定忽略它

# curlftpfs ftp.example.com /mnt/ftp/ -o ssl,no_verify_peer,no_verify_hostname,user=username:password

有关更多详细信息,请参阅 curlftpfs(1) man 页面。

故障排除

无法访问文件名中包含非百分号编码字符的文件

这是一个 bug,最初在 Launchpad bug 783033 中报告,关于带有 "#" 的路径,在 2013 年得到确认,但没有进一步的活动。一个 上游 bug 报告 链接到一个 潜在的补丁,该补丁还修复了 breaking changecurl 中。