CurlFtpFS
外观
CurlFtpFS 是一个基于 FUSE 和 libcurl 的用于访问 FTP 主机的文件系统。
安装
确保 内核模块 已加载。
# 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 的用户的家目录中创建一个 .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) 手册页。
故障排除
无法访问文件名中包含非百分号编码字符的文件
这是一个 Bug,最初于 2011 年在 Launchpad bug 783033 中报告,涉及带有 "#" 的路径,并于 2013 年得到确认但未有进一步进展。一个 上游 Bug 报告链接到一个 潜在的补丁,该补丁也修复了 curl 中的一个 破坏性更改。