Friday, 18 February 2011

Mounting FTP Directory as a Filesystem

I just discovered a really useful trick to mount the directory structure of a remote FTP server as a directory on a linux computer.   You use a program called curlftps.   On Ubuntu do:
sudo apt-get install curlftps
The directories on the remote ftp server are then mounted using:
 curlftpfs ftp://[username]:[password]@[server address] [local directory mount point] 
This works fine (you do not even need to be root to do it), but the password will be present if you do 'ps -ef | grep ftp'.
A solution is to create a .netrc file in the /root directory containing:

machine [server address]
login [username]
password [password]
You can then add the file system to /etc/fstab by adding the following line to /etc/fstab:
curlftpfs#[server address] [local directory mount point] fuse allow_other,rw,user,noauto 0 0
You can then just do
sudo mount [local directory mount point]
and you get the same effect with the server password invisible.



Post a Comment