安装CurlFtpFS
1.centos
CentOS内置源并没有包含CurlFtpFS,可以先安装epel源,然后再安装CurlFtpFS,复制下面的命令执行即可:
#安装epel
yum -y install epel-release
#安装CurlFtpFS
yum -y install curlftpfs
2.debian、ubuntu
apt-get install curlftpfs
挂载FTP
#创建目录
mkdir /mnt/ftp
#挂载
curlftpfs ftp.yourserver.com /mnt/ftp/ -o user=username:password
ftp.yourserver.com
为FTP地址/mnt/ftp/
本地目录username
为FTP用户名password
为FTP密码
输入df -h
查看下是否挂载成功,是的就这么简单,如下截图。
参考
1.xiaoz博客:https://www.xiaoz.me/archives/9522
2.Curlftpfs简体中文:https://wiki.archlinux.org/index.php/CurlFtpFS_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)
开机自动挂载
要实现开机自动挂载,需要将挂载命令添加到/etc/fstab
文件中。编辑/etc/fstab
文件,并在文件末尾添加一行,格式如下:
curlftpfs#ftp://username:password@ftp.example.com /mnt/ftp fuse defaults,allow_other,_netdev 0 0
其中,_netdev
选项确保网络文件系统在网络连接建立后再进行挂载,defaults
使用默认的挂载选项,allow_other
允许其他用户访问挂载点。
卸载FTP挂载
如果需要卸载FTP挂载,可以使用以下命令:
fusermount -u /mnt/ftp
请注意,将FTP凭据存储在/etc/fstab文件中可能会带来安全风险,因为凭据将以明文形式存储。在实际应用中,应考虑使用更安全的凭据管理方法。
文章评论