How to browse FTP in Vifm

From Vifm Wiki
Jump to navigation Jump to search

Below is a tutorial on how to browse FTP servers in Vifm. It's assumed that some *nix-like operating system with support of FUSE is used. Special files described below have .ftp suffix, but it can be any other extension as well.

Alternative: CurlFtpFS[edit]

Install CurlFtpFS[edit]

Install it in whatever way you like the most, which probably depends on your operating system distribution. One can always obtain sources at the official site.

Configure Vifm to handle *.ftp files with CurlFtpFS[edit]

Sample command for vifmrc:

" FtpMount
filetype *.ftp
       \ {Mount with CurlFtpFS}
       \ FUSE_MOUNT2|curlftpfs -o ftp_port=-,,disable_eprt %PARAM %DESTINATION_DIR %CLEAR,

Let's enumerate used options of CurlFtpFS:

  • ftp_port=1 - make CurlFtpFS pick the same IP address that is already used for the control connection;
  • ,, is used to insert , literally as it has special meaning in the argument list of :filetype command (and :filextype);
  • disable_eprt - tell CurlFtpFS to disable the use of the EPRT and LPRT commands; it's there just for better connection performance.

See man curlftpfs for other options.

Create *.ftp file[edit]

Create a file with .ftp suffix for the server you're willing to connect to. Say, it's name is server-name.ftp and content is like:

-o user=<user-name> <server-address>:

The simplest example might be:

$ cat gnu.ftp
ftp.gnu.org

Connect[edit]

In a running instance of Vifm just navigate to the .ftp-file and press l or Enter key.

Alternatively, one can pass path to .ftp-file to Vifm on command-line:

vifm gnu.ftp

which will connect to remote server on Vifm's startup.

Optimization[edit]

Remote FTP servers might be slow to respond, that's why it's a good idea to ask Vifm to reduce number of file-system queries in such directories. It can be done with the following option:

set slowfs=curlftpfs

curlftpfs here is type of FUSE file-system as it's seen in mtab. So if you use fsname=NAME option of CurlFtpFS, don't forget to use that NAME in 'slowfs' option.

Alternative: rclone[edit]

On modern systems CurlFtpFS may fail to work at all: it's unmaintained (last release in 2008) and recent versions of libcurl (8.x) cause it to abort with Error setting curl: before any connection is made. A working replacement is rclone, which provides a FUSE mount via rclone mount and a maintained FTP backend.

Install rclone[edit]

Install it through your distribution's package manager (it's widely packaged), or grab a binary from the official downloads page.

Configure Vifm to handle *.ftp files with rclone[edit]

Sample command for vifmrc:

" FtpMount
filetype *.ftp
       \ {Mount with rclone}
       \ FUSE_MOUNT2|rclone mount --daemon --vfs-cache-mode writes %PARAM %DESTINATION_DIR,

Notes on the options:

  • --daemon - unlike CurlFtpFS, rclone mount does not background itself; this flag makes it fork after mounting so Vifm doesn't block;
  • --vfs-cache-mode writes - enables writing/uploading and in-place edits of remote files.

See rclone mount for other options.

Create *.ftp file[edit]

With rclone the .ftp file holds an on-the-fly connection string instead of CurlFtpFS options, so no rclone.conf entry is required. The password must be obscured with rclone obscure (this also avoids problems with shell-special characters such as > in the password):

$ rclone obscure 'your-password'
KYQntueG2hkiUcmJVZqGvWbed5A9Tc9plxz2bAfBTGw

Then create server-name.ftp with a single line:

:ftp,host=<server-address>,user=<user-name>,pass=<obscured-password>:

For example:

$ cat server-name.ftp
:ftp,host=ftp.example.org,user=alice,pass=KYQntueG2hkiUcmJVZqGvWbed5A9Tc9plxz2bAfBTGw:

The trailing : selects the remote's root directory.

Security note: rclone obscure is reversible obfuscation, not encryption, so anyone who reads the file can recover the password. Protect the file accordingly:

$ chmod 600 server-name.ftp

Connect[edit]

Exactly as with CurlFtpFS: navigate to the .ftp file in a running Vifm and press l or Enter, or pass it on the command line:

vifm server-name.ftp

A harmless NOTICE: Config file ... not found - using defaults line may appear, because the connection string is used instead of an rclone config file.

Optimization[edit]

As with CurlFtpFS, remote FTP servers can be slow, so it's worth reducing the number of file-system queries. The rclone mount appears in mtab with type fuse.rclone, so use:

set slowfs=rclone