FTP: Difference between revisions

From Alpine Linux
(More grammar corrections, typo fixes, rearrangements, enhancements, and a bit of restructuring. Added new banner to notify that content should be restructured)
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
"FTP" means '''File Transfer Protocol''' one of the most olders file transfers protocols used over TCP/IP infraestructure, has a client/service filosophy (it needs a listening server and users are clients to make requests for files).
{{Style|This page has been rampant with typos and grammar errors before,  most of which have been corrected. However, this page could probably be restructured so that the content flows more smoothly, although this is currently being worked on.}}


About FTP software Alpine Linux has only the right solutions packaged:
FTP (or '''F'''ile '''T'''ransfer '''P'''rotocol) is a protocol that allows you to transfer files from a server to a client and vice versa (as FTP uses a client-server architecture). FTP is among the oldest protocols as its origins can be traced as far back as 1971 according to [https://en.wikipedia.org/wiki/Ftp#History_of_FTP_servers Wikipedia].


* The most secure and fasted FTP server as {{Pkg|vsftpd}} for the service part if you plan to install a FTP service on Alpine servers
There are also variants of FTP. Such include SFTP (SSH FTP, not to be confused with Simple FTP), FTPS (FTP SSL), and others. SFTP, as the name implies, is done over SSH. FTPS is plain FTP with TLS/SSL encryption.
* The most profiling and perfect client as {{Pkg|ncftp}} and also {{Pkg|lftp}} for the client part if you dessire to use at the command line
* Also you can use {{Pkg|pcmanfm}} with {{Pkg|gvfs}} plugins to handle ftp request too


'''In this document we will show you general information about FTP software related to Alpine linux'''
Alpine Linux has various FTP clients and servers that you can install and use:


= The FTP service: vsftpd =
* {{Pkg|vsftpd}} (server)
* {{Pkg|ncftp}} (client)
* {{Pkg|lftpd}} (client, but see below for more details).


As alpine linux (simple, secure and eficientely) the provided FTP service software are {{Pkg|vsftpd}}
There are also plenty of other clients available too, some not available in Alpine's repositories in fact. However, we will only be covering the clients and servers mentioned above. In addition, there are several graphical clients. See [[#FTP Clients]] for more details.


{{Pkg|vsftpd}} are not so used due common hosting panels does not handle it's configurations management.. in contrash {{Pkg|vsftpd}} are secured respect rest of others without so much updates.
= Servers =
== vsftpd ==


=== About vsftpd package ===
In Alpine Linux the default FTP server is {{Pkg|vsftpd}}. However, it's not widely used due to common hosting panels not handling it's configuration management. In contrast {{Pkg|vsftpd}} is more secure and doesn't require many updates.


'''It was the most secured FTP server'''.  It is the default FTP server in the NimbleX and Slackware Linux distributions and many others.
== About vsftpd ==


{{Note|As for minimal FTP's and fast server purposes are very recommended due it easy configuration process and perfect performance without much configuration.}}
vsftpd claims to be the "most secure and fastest FTP server for UNIX-like systems".  It's the default FTP server in NimbleX, Slackware, and many others. In addition, it's also recommended because of relatively easy configuration.


{| class="wikitable"
{| class="wikitable"
|-
|-
! Feature/Artifac !! Value/Name !! Observations
! Feature !! Value/Name !! Observations
|-
|-
| Main package name || vsftpd || <code><nowiki>apk add vsftpd</nowiki></code>
| Package name || vsftpd || <code><nowiki>apk add vsftpd</nowiki></code>
|-
|-
| Manpages and DOCs packages || vsftpd-doc || <code><nowiki>apk add vsftpd-doc</nowiki></code>
| Manpages and DOCs packages || vsftpd-doc || <code><nowiki>apk add vsftpd-doc</nowiki></code>
|-
|-
| Configuration file || {{Path|/etc/vsftpd/vsftpd.conf}} || It's not close to alpine, just vanilla provived!
| Configuration file || {{Path|/etc/vsftpd/vsftpd.conf}} || Little to no customizations are made by Alpine
|-
|-
| Default place for files || {{Path|/var/lib/ftp}} || cos anonnimous are default, is home for daemon user
| Default path for files || {{Path|/var/lib/ftp}} || cos anonymous are default, is home for daemon user
|-
|-
| Log files (error, access, etc) || {{Path|/var/log/vsftpd.log}} || Defined in vsftp.conf also
| Log files (error, access, etc) || {{Path|/var/log/vsftpd.log}} || Defined in vsftp.conf
|-
|-
| User running the service || vsftpd || Others Linux used "ftp" alpine has as a group
| User running the service || vsftpd || Others Linux used "ftp" alpine has as a group
|-
|-
| Group to common to || vsftpd || Used to share things amont others daemons or services, like redis or apache files
| Group to common to || vsftpd || Used to share things among others daemons or services, like Redis or Apache
|-
|-
| Programed on || C || Main engine code in C
| Written in || C || Main engine code in C
|}
|}


==== Important Limitations ====
==== Limitations ====


'''No SFTP support, BUT ''has support for FTPS''.'''
* vsftp does not support SFTP, but it does have support for FTPS.


=== Install vsftpd ===
=== Installing vsftpd ===


The installation does not work out of the box, cos enable by default anonimous and ipv4 only.
The installation does not work out of the box, cos enable by default anonymous access is enabled and it only works with IPv4 only.


Per user ftp files can be supported by special directive in the vsftp.conf file using <code>user_sub_token</code> to somethign like {{Path|/home/$USER/public_ftp}} directory by example if we enable it (process are described below in further section "vsftpd configuration".
Per user ftp files can be supported by special directive in the vsftp.conf file using <code>user_sub_token</code> to something like {{Path|/home/$USER/public_ftp}} directory by example if we enable it (process are described below in further section "vsftpd configuration".


{{Pkg|vsftd}} is available in the Alpine Linux repositories. To install, simple launch the commands below:
{{Pkg|vsftpd}} is available in the Alpine Linux repositories. To install and run vsftpd, simply run the commands below:


<pre>
<pre>
Line 64: Line 65:
</pre>
</pre>


=== vsftpd Configuration ===
=== Configuring vsftpd ===


By default alpine vsftpd package does not provide any special configuration, just vanilla provided so we must specify what we want!
By default, Alpine's vsftpd package does not modify the default configuration. If you leave the configuration untouched, then vsftpd will be configured exactly the same as if you downloaded vsftpd from [[https://security.appspot.com/vsftpd.html its site]]. Regardless, you might want to change the server configuration anyways.


Configurations depends of the purpose of the FTP nature to serve, the most common cases are anonymously ftp service, user system ftp service and virtual users ftp service..  
The server configuration obviously depends on the your needs. Some common server configuration schemes include allowing anonymous access of files, user system FTP services, and virtual users (on the server end).  


For production purposes the [[Production FTP virtual users: vsftpd + MySQL]] wiki page will explain in details all the needs for a virtual users case, there's the [[Production FTP user service: vsftpd]] wiki page with futher information to use with system users and lets encrypt certificates.
For production purposes, the [[Production FTP virtual users: vsftpd + MySQL]] wiki page will explain all the requirements for setting up virtual users. The [[Production FTP user service: vsftpd]] wiki page also has further information on how to use vsftpd with system users and Let's Encrypt certificates ['''fixme''': pages doesn't exist].


Due to the minimalism of alpine linux, '''unfortunately the vsftpd packaging only provided vanilla configurations not close to alpine or easy admin maintenance''', see the [[Production VSFTP system: vsftpd + MySQL + SFTP]] wiki page to goin in deep about configuring lighttpd web server.
Because there are no customizations to the default configuration (in other words no Alpine-specific customizations), the configuration may not mean easy maintenance of the server, among other things. See the [[Production VSFTP system: vsftpd + MySQL + SFTP]] wiki page, which goes in depth about configuring the lighttpd web server and others ['''fixme''': page does not exist].


==== Controlling vsftpd ====
==== Controlling vsftpd ====


'''''Start vsftpd''''': After the installation {{Pkg|vsftpd}} is not running. As we said in first section, was started already but if you want to start {{Pkg|vsftpd}} manually use:
'''''Starting vsftpd''''': After the installation {{Pkg|vsftpd}} is not running. As we said in first section, was started already but if you want to start {{Pkg|vsftpd}} manually use:


{{Cmd|rc-service vsftpd start}}
{{Cmd|rc-service vsftpd start}}


You will get a feedback about the status.
After you issue this command, OpenRC will tell you the status of vsftpd.


<pre>
<pre>
Line 87: Line 88:
</pre>
</pre>


'''''Stop vsftpd''''': If you want to stop the web server use ''stop'' in the same way of previous command:
'''Stopping vsftpd''': If you want to stop the web server use ''stop'' in the same way of previous command:


{{Cmd|rc-service vsftpd stop}}
{{Cmd|rc-service vsftpd stop}}


'''''Restart lighttpd''''': After changing the configuration file lighttpd needs to be restarted.
'''Restarting or reloading vsftpd''': After changing the configuration file, you must either restart or reload vsftpd in order for the new configuration to take effect. You can issue one of the following commands below to achieve the desired effect:


{{Cmd|rc-service vsftpd restart}}
{{Cmd|rc-service vsftpd restart}}
{{Cmd|rc-service vsftpd reload}}


'''''Proper Runlevel''''': By default no services are added to start process, sysadmin must know what we want and what will services do, also other main reason are due in dockers there's no runlevels per se and Alpine linux are mostly used in dockers containers. You must added the servide only to the default runlevel, not to boot, because need networking activated
The latter command entirely restarts vsftpd, while the former only reloads vsftpd's configuration file. The former command might be more desired as it prevents having to reload vsftpd entirely.
 
After issuing one of the commands, you might see something similar either to this output:
<pre>
* Stopping vsftpd...                                        [ ok ]
* Starting vsftpd...                                        [ ok ]
</pre>
 
(for restarting vsftpd) or to this output:
 
<pre>
* Reloading vsftpd...                                        [ ok ]
</pre>
 
(for reloading vsftpd).
 
'''Using the proper runlevel''': By default no services are added to start process. You must know what you want and what will these services do. Furthermore, runlevels aren't present in Docker containers (per se), and Alpine is used mostly in those containers. You must add the service only to the 'default' runlevel, not to the 'boot' runlevel. Networking isn't enabled during the the 'boot' runlevel, and thus it doesn't make much sense to run an FTP server without networking.


{{Cmd|rc-update add vsftpd default}}
{{Cmd|rc-update add vsftpd default}}
Line 102: Line 120:
=== Testing vsftpd ===
=== Testing vsftpd ===


This section is assuming that vsftpd is running. Well, at the moment there is no user ftp allowed available but the server is up and running.
This section is assuming that vsftpd is running. At the moment, there might not be a user 'ftp' allowed available but the server is up and running.
 
{{Cmd|nc -zv 127.0.0.1 21}}


Note that we used "127.0.0.1" if you are using alpine as the only machine for all as your main desktop/pc/machine.
{{Cmd|nc -zv server_address}}


If you are using alpine remotelly as web server and just install it the package, chnage <code><nowiki>127.0.0.1</nowiki></code> with ip of the alpine machine. The "webserveripaddres" are the ip address of your setup/server machine.
Be sure to change <code>server_address</code> with the actual IP address of the server. The common response will be '''OPEN''' if the server is running.
 
The common response will be '''OPEN''' if server are running.


=== See also about vsftpd ===
=== See also about vsftpd ===
Line 121: Line 135:
* [[Alpine newbie lammers]]
* [[Alpine newbie lammers]]


= The FTP clients: lftp and ncftp =
= FTP Clients =


The FTP protocol need also a client support to property used. Alpine Linux provides two packages for command line and batch procesing of FTP protocol, apart of the {{Pkg|firefox}} package: the {{Pkg|lftp}} and the {{Pkg|ncftp}} packages.
As FTP uses a client-server architecture, you will need an FTP client if you want to interact with an FTP server. Alpine provides two packages for command line and batch processing of files over FTP. The following is a list of some graphical FTP clients:


{{Warning|So we need at leas one of a ftp client package.. either at leas the  {{Pkg|lftp}}, the {{Pkg|ncftp}} or {{Pkg|firefox}} are optional or can be used as well.}}
* {{Pkg|pcmanfm}}. Check out [[#PCManFM with GVfs]]
* {{Pkg|firefox}}, before [https://www.mozilla.org/en-US/firefox/88.0/releasenotes/ Firefox 88], or any other web browser supporting FTP.


So then, '''commonly a web browser (firefox) supports FTP protocol''' so our FTP server just configured can be '''browsed using the address <code><nowiki>ftp://<webserveripaddres></nowiki></code> The "webserveripaddres" are the ip address of your setup/server machine.'''
The following is a list of some command line FTP clients:
* {{Pkg|lftp}}. Check out [[#lftp]]
* {{Pkg|ncftp}}


== About lftp package ==
You can also use any web browser that supports FTP as an FTP client also, as is obvious. To do so, simply enter <nowiki><code>ftp://server_address</code></nowiki>, where "server_address" is the IP address of the FTP server.


LFTP is a sophisticated file transfer program supporting a number of network protocols (ftp, http, sftp, fish, torrent).
== lftp ==


* Has job control and..
LFTP is a sophisticated file transfer program that supports a number of network protocols. Such include FTP, HTTP, SFTP, FISH, BitTorrent, and possibly more.
* uses the readline library for input.
 
* It has bookmarks,
lftp has the following features:
* Has built-in mirror command
 
* Can transfer several files in parallel.
* lftp supports job control
* The readline library is used for input
* lftp has support for bookmarks
* lftp has a built-in mirror command
* lftp can transfer several files in parallel


{| class="wikitable"
{| class="wikitable"
|-
|-
! Feature/Artifac !! Value/Name !! Observations
! Feature !! Value/Name !! Notes
|-
|-
| Main package name || lftp || <code><nowiki>apk add lftp</nowiki></code>
| Main package name || lftp || Install: <code><nowiki>apk add lftp</nowiki></code>
|-
|-
| Manpages and DOCs packages || vsftpd-doc || <code><nowiki>apk add lftp-doc</nowiki></code>
| Manpages and DOCs packages || vsftpd-doc || Install: <code><nowiki>apk add lftp-doc</nowiki></code>
|-
|-
| Configuration file (system) || {{Path|/etc/lftp.conf}} || It's not close to alpine, just vanilla provived!
| Configuration file (system) || {{Path|/etc/lftp.conf}} || Little to no customizations are made by Alpine
|-
|-
| Configuration file (user) || {{Path|~/.lftprc}} || if found the first to parse!
| Configuration file (user) || {{Path|~/.lftprc}} || The first user configuration file to read from.
|-
|-
| Configuration file (user) || {{Path|~/.lftp/rc}} || second attempt to parse if first not found!
| Configuration file (user) || {{Path|~/.lftp/rc}} || Second user configuration file to read from.
|-
|-
| Programed on || C || Main engine code in C
| Written in || C || Main engine code in C
|}
|}


=== Installing lftp ===
=== Installing lftp ===


Is provided in main repository since 3.6, so '''is a team supported package ready for production''' deploys.
To install lftp, run the following command:


<pre>
<pre>
Line 165: Line 186:
</nowiki>
</nowiki>
</pre>
</pre>
lftp has been provided in the main repository since Alpine 3.6, so it's a supported package that's ready for production use.


=== Configuring lftp ===
=== Configuring lftp ===


The main configuration file, <code><nowiki>/etc/lftp.conf</nowiki></code> comes with various examples and comments. On startup, lftp executes <code>/etc/lftp.conf</code> and then <code>~/.lftprc</code> and <code>~/.lftp/rc</code>. You can use those files to set system-wide and user-specific settings.
The main configuration file, <code><nowiki>/etc/lftp.conf</nowiki></code> comes with different examples and comments. On startup, lftp reads <code>/etc/lftp.conf</code>, <code>~/.lftprc</code>, and <code>~/.lftp/rc</code> (in the specified order). You can use those files to set system-wide and user-specific settings.


In your configuration file, simply use the command set followed by the name of the setting, followed by its value. Use on/off for boolean values. Check this example:
In your configuration file, simply use the command set followed by the name of the setting, followed by its value. Use on/off for boolean values. Here's an example:


<pre>
<pre>
Line 190: Line 213:
</pre>
</pre>


{{Note|The closure for `dns:', `net:', `ftp:', `http:', `hftp:' domain variables is currently just the host name as you specify it in the `open' command (with some exceptions where closure is meaningless, e.g. dns:cache-size). For some `cmd:' domain variables the closure is current URL without path. For other variables it is not currently used. See examples in the sample lftp.conf.}}
{{Note|The closure for `dns:', `net:', `ftp:', `http:', `hftp:' domain variables is currently just the host name as you specify it in the `open' command (with some exceptions where closure is meaningless, e.g. dns:cache-size). For some `cmd:' domain variables the closure is the current URL without path. For other variables it is not currently used. See examples in the sample lftp.conf.}}


=== General lftp usage examples ===
=== More on lftp ===


By default, lftp is silent about the operations it performs in the background. If you need some more output, e.g. for debugging purposes, you can use the 'debug' command (without the 'set' command):
By default, lftp is not very verbose about operations it performs in the background. If you want more output, e.g. for debugging purposes, you can use the 'debug' command (without the 'set' command):


* debug 5 will display the full debug output.
* debug 5 will display the full debug output.
Line 216: Line 239:
The last alias (edit) should be all in one line. It allows you to get a remote file, edit it with vim (change as needed), and place the edited file back on the server. This is very convenient!
The last alias (edit) should be all in one line. It allows you to get a remote file, edit it with vim (change as needed), and place the edited file back on the server. This is very convenient!


* '''Example usage'''
=== Example usage ===


Below is an example of a mult-part download over the SFTP protocol:
Below is an example of a mult-part download over the SFTP protocol:


<nowiki>$ lftp -e 'pget -c -n 5 /path/to/file' sftp://username@server</nowiki>
<code>$ lftp -e 'pget -c -n 5 /path/to/file' <nowiki>sftp://username@server</nowiki></code>


short explanation:
Here's a breakdown of the above command:


* -e: lftp option to execute command
* -e: lftp option to execute command
Line 228: Line 251:
* -c: pget option to resume
* -c: pget option to resume
* -n: pget option for number of parts
* -n: pget option for number of parts
== PCManFM with GVfs ==
While PCManFM is a file manager, installing the {{Pkg|gvfs}} plugin allows you to use it as a graphical FTP client. To connect to an FTP server, you can do the following:
# From the menubar open the "go" menu
# Choose "Connect to a server"
# Choose the FTP protocol and input your username (path is optional)
# After a while you will input the password for the username you input
Check the picture for further reference.
[[File:Ftp-gui-pcmanfm_at_2020-09-11_14-13-03.png]]


= See Also =
= See Also =
Line 239: Line 275:
[[Category:Web_Server]]
[[Category:Web_Server]]
[[Category:Development]]
[[Category:Development]]
ddd

Revision as of 02:20, 13 May 2021

This material needs wiki syntax or style improvements ...

This page has been rampant with typos and grammar errors before, most of which have been corrected. However, this page could probably be restructured so that the content flows more smoothly, although this is currently being worked on.

FTP (or File Transfer Protocol) is a protocol that allows you to transfer files from a server to a client and vice versa (as FTP uses a client-server architecture). FTP is among the oldest protocols as its origins can be traced as far back as 1971 according to Wikipedia.

There are also variants of FTP. Such include SFTP (SSH FTP, not to be confused with Simple FTP), FTPS (FTP SSL), and others. SFTP, as the name implies, is done over SSH. FTPS is plain FTP with TLS/SSL encryption.

Alpine Linux has various FTP clients and servers that you can install and use:

There are also plenty of other clients available too, some not available in Alpine's repositories in fact. However, we will only be covering the clients and servers mentioned above. In addition, there are several graphical clients. See #FTP Clients for more details.

Servers

vsftpd

In Alpine Linux the default FTP server is vsftpd. However, it's not widely used due to common hosting panels not handling it's configuration management. In contrast vsftpd is more secure and doesn't require many updates.

About vsftpd

vsftpd claims to be the "most secure and fastest FTP server for UNIX-like systems". It's the default FTP server in NimbleX, Slackware, and many others. In addition, it's also recommended because of relatively easy configuration.

Feature Value/Name Observations
Package name vsftpd apk add vsftpd
Manpages and DOCs packages vsftpd-doc apk add vsftpd-doc
Configuration file /etc/vsftpd/vsftpd.conf Little to no customizations are made by Alpine
Default path for files /var/lib/ftp cos anonymous are default, is home for daemon user
Log files (error, access, etc) /var/log/vsftpd.log Defined in vsftp.conf
User running the service vsftpd Others Linux used "ftp" alpine has as a group
Group to common to vsftpd Used to share things among others daemons or services, like Redis or Apache
Written in C Main engine code in C

Limitations

  • vsftp does not support SFTP, but it does have support for FTPS.

Installing vsftpd

The installation does not work out of the box, cos enable by default anonymous access is enabled and it only works with IPv4 only.

Per user ftp files can be supported by special directive in the vsftp.conf file using user_sub_token to something like /home/$USER/public_ftp directory by example if we enable it (process are described below in further section "vsftpd configuration".

vsftpd is available in the Alpine Linux repositories. To install and run vsftpd, simply run the commands below:


apk add vsftpd

rc-update add vsftpd default

rc-service vsftpd restart

Configuring vsftpd

By default, Alpine's vsftpd package does not modify the default configuration. If you leave the configuration untouched, then vsftpd will be configured exactly the same as if you downloaded vsftpd from [its site]. Regardless, you might want to change the server configuration anyways.

The server configuration obviously depends on the your needs. Some common server configuration schemes include allowing anonymous access of files, user system FTP services, and virtual users (on the server end).

For production purposes, the Production FTP virtual users: vsftpd + MySQL wiki page will explain all the requirements for setting up virtual users. The Production FTP user service: vsftpd wiki page also has further information on how to use vsftpd with system users and Let's Encrypt certificates [fixme: pages doesn't exist].

Because there are no customizations to the default configuration (in other words no Alpine-specific customizations), the configuration may not mean easy maintenance of the server, among other things. See the Production VSFTP system: vsftpd + MySQL + SFTP wiki page, which goes in depth about configuring the lighttpd web server and others [fixme: page does not exist].

Controlling vsftpd

Starting vsftpd: After the installation vsftpd is not running. As we said in first section, was started already but if you want to start vsftpd manually use:

rc-service vsftpd start

After you issue this command, OpenRC will tell you the status of vsftpd.

 * Caching service dependencies ...                           [ ok ]
 * Starting vsftpd...                                         [ ok ]

Stopping vsftpd: If you want to stop the web server use stop in the same way of previous command:

rc-service vsftpd stop

Restarting or reloading vsftpd: After changing the configuration file, you must either restart or reload vsftpd in order for the new configuration to take effect. You can issue one of the following commands below to achieve the desired effect:

rc-service vsftpd restart

rc-service vsftpd reload

The latter command entirely restarts vsftpd, while the former only reloads vsftpd's configuration file. The former command might be more desired as it prevents having to reload vsftpd entirely.

After issuing one of the commands, you might see something similar either to this output:

 * Stopping vsftpd...                                         [ ok ]
 * Starting vsftpd...                                         [ ok ]

(for restarting vsftpd) or to this output:

 * Reloading vsftpd...                                        [ ok ]

(for reloading vsftpd).

Using the proper runlevel: By default no services are added to start process. You must know what you want and what will these services do. Furthermore, runlevels aren't present in Docker containers (per se), and Alpine is used mostly in those containers. You must add the service only to the 'default' runlevel, not to the 'boot' runlevel. Networking isn't enabled during the the 'boot' runlevel, and thus it doesn't make much sense to run an FTP server without networking.

rc-update add vsftpd default


Testing vsftpd

This section is assuming that vsftpd is running. At the moment, there might not be a user 'ftp' allowed available but the server is up and running.

nc -zv server_address

Be sure to change server_address with the actual IP address of the server. The common response will be OPEN if the server is running.

See also about vsftpd

FTP Clients

As FTP uses a client-server architecture, you will need an FTP client if you want to interact with an FTP server. Alpine provides two packages for command line and batch processing of files over FTP. The following is a list of some graphical FTP clients:

The following is a list of some command line FTP clients:

You can also use any web browser that supports FTP as an FTP client also, as is obvious. To do so, simply enter <code>ftp://server_address</code>, where "server_address" is the IP address of the FTP server.

lftp

LFTP is a sophisticated file transfer program that supports a number of network protocols. Such include FTP, HTTP, SFTP, FISH, BitTorrent, and possibly more.

lftp has the following features:

  • lftp supports job control
  • The readline library is used for input
  • lftp has support for bookmarks
  • lftp has a built-in mirror command
  • lftp can transfer several files in parallel
Feature Value/Name Notes
Main package name lftp Install: apk add lftp
Manpages and DOCs packages vsftpd-doc Install: apk add lftp-doc
Configuration file (system) /etc/lftp.conf Little to no customizations are made by Alpine
Configuration file (user) ~/.lftprc The first user configuration file to read from.
Configuration file (user) ~/.lftp/rc Second user configuration file to read from.
Written in C Main engine code in C

Installing lftp

To install lftp, run the following command:


apk add lftp

lftp has been provided in the main repository since Alpine 3.6, so it's a supported package that's ready for production use.

Configuring lftp

The main configuration file, /etc/lftp.conf comes with different examples and comments. On startup, lftp reads /etc/lftp.conf, ~/.lftprc, and ~/.lftp/rc (in the specified order). You can use those files to set system-wide and user-specific settings.

In your configuration file, simply use the command set followed by the name of the setting, followed by its value. Use on/off for boolean values. Here's an example:


set ftp:ssl-force on
set ssl:verify-certificate on
set ftp:use-feat off
set ftp:ssl-protect-data on

You can set specific settings for specific servers only. Simply append a slash (/) and the server name to the setting.


set ftp:use-feat off /example.com
set ftp:ssl-force on /example.com

Note: The closure for `dns:', `net:', `ftp:', `http:', `hftp:' domain variables is currently just the host name as you specify it in the `open' command (with some exceptions where closure is meaningless, e.g. dns:cache-size). For some `cmd:' domain variables the closure is the current URL without path. For other variables it is not currently used. See examples in the sample lftp.conf.

More on lftp

By default, lftp is not very verbose about operations it performs in the background. If you want more output, e.g. for debugging purposes, you can use the 'debug' command (without the 'set' command):

  • debug 5 will display the full debug output.
  • debug 3 will only display greeting messages and error messages.

Note that if you use the -d switch from the command line, the debug setting will be overruled and the full debug output will be displayed.

If you prefer some commands to be called by another name, you can set aliases:


alias dir ls
alias less more
alias zless zmore
alias bzless bzmore
alias reconnect "close; cache flush; cd ."
alias edit "eval -f "get $0 -o ~/.lftp/edit.tmp.$$ && shell \\"cp -p ~/.lftp/edit.tmp.$$ ~/.lftp/edit.tmp.$$.orig && vim ~/.lftp/edit.tmp.$$ && test ~/.lftp/edit.tmp.$$ -nt ~/.lftp/edit.tmp.$$.orig\\" && put ~/.lftp/edit.tmp.$$ -o $0; shell rm -f ~/.lftp/edit.tmp.$$*"

The last alias (edit) should be all in one line. It allows you to get a remote file, edit it with vim (change as needed), and place the edited file back on the server. This is very convenient!

Example usage

Below is an example of a mult-part download over the SFTP protocol:

$ lftp -e 'pget -c -n 5 /path/to/file' sftp://username@server

Here's a breakdown of the above command:

  • -e: lftp option to execute command
  • pget: is the command for partial download
  • -c: pget option to resume
  • -n: pget option for number of parts

PCManFM with GVfs

While PCManFM is a file manager, installing the gvfs plugin allows you to use it as a graphical FTP client. To connect to an FTP server, you can do the following:

  1. From the menubar open the "go" menu
  2. Choose "Connect to a server"
  3. Choose the FTP protocol and input your username (path is optional)
  4. After a while you will input the password for the username you input

Check the picture for further reference.

See Also

ddd