FTP: Difference between revisions

From Alpine Linux
(added a gui program for client usage)
m (Section rearrangements; minor cleanups and formatting changes)
 
(15 intermediate revisions by 4 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).
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://datatracker.ietf.org/doc/html/rfc114 RFC 114].


About FTP software Alpine Linux has only the right solutions packaged:
Variants of FTP also exist, including SFTP (SSH FTP, not to be confused with Simple FTP) and FTPS (FTP with TLS). SFTP, as the name implies, is done over SSH. FTPS is plain FTP with TLS encryption.


* 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
Alpine Linux has various FTP clients and servers that you can install and use, including the following:
* 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'''
* {{Pkg|vsftpd|arch=}} (server)
* {{Pkg|ncftp|arch=}} (client)


= The FTP service: vsftpd =
Plenty of other clients also exist, but the ones mentioned above are the only ones covered. See [[#Clients]] for more details.


As alpine linux (simple, secure and eficientely) the provided FTP service software are {{Pkg|vsftpd}}
= Servers =
== vsftpd ==


{{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.
In Alpine Linux the default FTP server is {{Pkg|vsftpd|arch=}}. However, it's not widely used due to common hosting panels not handling it's configuration management. On the other hand, vsftpd is more secure and doesn't require many updates.


=== FTP server: About vsftpd package ===
vsftpd also claims it's the "most secure and fastest FTP server for UNIX-like systems".  It's the default FTP server in NimbleX, Slackware, and many other Linux distributions. In addition, it's also recommended because of relatively easy configuration.


'''It was the most secured FTP server'''.  It is the default FTP server in the NimbleX and Slackware Linux distributions and many others.
Below is a list of features vsftpd has:
 
{{Note|As for minimal FTP's and fast server purposes are very recommended due it easy configuration process and perfect performance without much configuration.}}


{| class="wikitable"
{| class="wikitable"
|-
|-
! Feature/Artifac !! Value/Name !! Observations
! Feature                                 !! Value/Name                       !! Notes
|-
| Main package name || vsftpd || <code><nowiki>apk add vsftpd</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!
|-
|-
| Default place for files || {{Path|/var/lib/ftp}} || cos anonnimous are default, is home for daemon user
| Configuration file                      || {{Path|/etc/vsftpd/vsftpd.conf}} || The default config is stock from vsftpd
|-
|-
| Log files (error, access, etc) || {{Path|/var/log/vsftpd.log}} || Defined in vsftp.conf also
| Default Path For Files                  || {{Path|/var/lib/ftp}}           || Because anonymous access is enabled by default, this is the daemon's default home directory
|-
|-
| User running the service || vsftpd || Others Linux used "ftp" alpine has as a group
| Log Files                              || {{Path|/var/log/vsftpd.log}}    || Configurable in vsftp.conf
|-
|-
| Group to common to || vsftpd || Used to share things amont others daemons or services, like redis or apache files
| User Running The Service                || vsftpd                           || Alpine does '''not''' have an {{ic|ftp}} user; it uses a group with the same name instead.
|-
|-
| Programed on || C || Main engine code in C
| Group(s) to common to                  || vsftpd                          || Used to share things among others daemons or services, like Redis or Apache
|}
|}


==== Important Limitations ====
==== Limitations ====
 
'''No SFTP support, BUT ''has support for FTPS''.'''


=== Install vsftpd ===
* SFTP is not supported


The installation does not work out of the box, cos enable by default anonimous and ipv4 only.
=== Installation ===


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".
To install and run vsftpd, simply run {{ic|apk add vsftpd}}. Optionally install the {{Pkg|vsftpd-doc|arch=}} package alongside for documentation.


{{Pkg|vsftd}} is available in the Alpine Linux repositories. To install, simple launch the commands below:
To enable vsftpd on startup and start it now, run the following commands.


<pre>
<pre>
<nowiki>
apk add vsftpd
rc-update add vsftpd default
rc-update add vsftpd default
 
rc-service vsftpd start
rc-service vsftpd restart
</nowiki>
</pre>
</pre>


=== vsftpd Configuration ===
=== Configuration ===
 
By default alpine vsftpd package does not provide any special configuration, just vanilla provided so we must specify what we want!
 
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..


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.
The default configuration is not ideal because anonymous access is enabled by default and only IPv4 support is enabled. Therefore, the default configuration should not be used in a production environment. Some common server configuration schemes include allowing anonymous access of files, user system FTP services, and virtual users (on the server end).


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.
Per-user FTP files can be supported by special directive in the vsftp.conf file using <code>user_sub_token</code>. For example, this can be set to something like {{Path|/home/$USER/public_ftp}} if we enable it (process are described below in further section "vsftpd configuration")


==== Controlling vsftpd ====
=== Managing 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 vsftpd manually use:


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


You will get a feedback about the status.
If starting vsftpd went OK, you should see output similar to the following:


<pre>
<pre>
Line 87: Line 68:
</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 run 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}}
The latter reloads vsftpd's configuration file while the former restarts vsftpd entirely. The latter might be preferred as it prevents having to reload vsftpd entirely.
If you ''restarted'' vsftpd, there should be output similar to the following:
<pre>
* Stopping vsftpd...                                        [ ok ]
* Starting vsftpd...                                        [ ok ]
</pre>


'''''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
If you ''reloaded'' vsftpd, the output will be similar to the following instead:


{{Cmd|rc-update add vsftpd default}}
<pre>
* Reloading vsftpd...                                        [ ok ]
</pre>
 
'''Using the proper runlevel''': using the "default" runlevel should work in most cases, although there might be custom runlevels present and it might be more desirable to add vsftpd to a runlevel other than "default". However, keep in mind that runlevels aren't present in Docker containers because Alpine is used mostly in Docker.
 
To add vsftpd to a runlevel, use the following command:
 
{{Cmd|rc-update add vsftpd [runlevel]}}
 
Where <code>[runlevel]</code> is the name of the runlevel you want to add the vsftpd service too. For example, if you want to add vsftpd to the "default" run level, run <code>rc-update add vsftpd default</code>




=== 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 the {{ic|ftp}} user allowed or even 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.
You can use {{pkg|netcat|arch=}} to test if a connection to the server is successful:


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.
{{Cmd|nc -zv [server_address]}}


The common response will be '''OPEN''' if server are running.
Be sure to change {{ic|[server_address]}} with the actual IP address of the server. The common response will be '''OPEN''' if the server is running. If you receive another response, review your server configuration.


=== See also about vsftpd ===
= Clients =


* [[Production Lets Encrypt: dehydrated]]
Because FTP uses a client-server architecture, you will need an FTP client if you want to interact with an FTP server. Alpine provides several packages for command-line FTP clients:
* [[Production FTP user service: vsftpd]]
* [[Production FTP virtual users: vsftpd + MySQL]]
* [[Production VSFTP system: vsftpd + MySQL + SFTP]]
* [[Alpine newbie developer]]
* [[Alpine newbie lammers]]


= The FTP clients: lftp, pcmanfm and ncftp =
* {{Pkg|lftp}}. See [[#lftp]] for more details.
* {{Pkg|ncftp}}


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.
If you prefer a graphical client, check out the following:


* Gui programs:
* {{Pkg|pcmanfm}}. See [[#PCManFM with GVfs]]
** {{Pkg|pcmanfm}} check [[#Gui_FTP_client:_About_pcmanfm_package]]
** {{Pkg|firefox}}
* Cli programs:
** {{Pkg|lftp}} check [[#Cli_FTP_client:_About_lftp_package]]
** {{Pkg|ncftp}}


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.'''
Some web browsers also support FTP, although most major brows, such as Chrome and Firefox, have removed support for the protocol.


== Cli FTP client: About lftp package ==
== lftp ==


LFTP is a sophisticated file transfer program supporting a number of network protocols (ftp, http, sftp, fish, torrent).  
lftp is a sophisticated file transfer program that supports a number of network protocols, including FTP, HTTP, SFTP, FISH, and BitTorrent. It also has the following features:


* Has job control and..
* Job control
* uses the readline library for input.
* Support for bookmarks
* It has bookmarks,
* Support for a built-in mirror command
* Has built-in mirror command
* Support for parallel file transfers
* Can transfer several files in parallel.
* Uses <code>readline</code> for input


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


=== Installing lftp ===
=== Installation ===


Is provided in main repository since 3.6, so '''is a team supported package ready for production''' deploys.
To install lftp, run {{ic|apk add lftp}}


<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.
<nowiki>
apk add lftp
</nowiki>
</pre>


=== Configuring lftp ===
=== Configuration ===


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, {{path|/etc/lftp.conf}}, comes with different examples and comments. On startup, lftp reads {{path|/etc/lftp.conf}}, {{path|~/.lftprc}}, and {{path|~/.lftp/rc}} in that exact order. These files are used 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 the configuration file, use the command set followed by the name of the setting followed by its value. Use <code>on</code>/<code>off</code> for boolean values. For example:


<pre>
<pre>
<nowiki>
set ftp:ssl-force on
set ftp:ssl-force on
set ssl:verify-certificate on
set ssl:verify-certificate on
set ftp:use-feat off
set ftp:use-feat off
set ftp:ssl-protect-data on
set ftp:ssl-protect-data on
</nowiki>
</pre>
</pre>


You can set specific settings for specific servers only. Simply append a slash (/) and the server name to the setting.
Specific settings can be set for specific servers only. Append a slash (/) in front of the server name for a specific server.


<pre>
<pre>
<nowiki>
set ftp:use-feat off /example.com
set ftp:use-feat off /example.com
set ftp:ssl-force on /example.com
set ftp:ssl-force on /example.com
</nowiki>
</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 {{ic|dns:}}, {{ic|net:}}, {{ic|ftp:}}, {{ic|http:}}, and {{ic|hftp:}} domain variables is currently just the host name as you specify it in the {{ic|open}} command (with some exceptions where closure is meaningless, e.g., {{ic|dns:cache-size}}). For some {{ic|cmd:}} domain variables the closure is the current URL without path. For other variables, it is currently not used. See examples in the sample {{ic|lftp.conf}}.}}


=== General lftp usage examples ===
=== More Info ===


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, you can use the 'debug' command (without the 'set' command):


* debug 5 will display the full debug output.
* <code>debug 5</code> will display the full debug output.
* debug 3 will only display greeting messages and error messages.
* <code>debug 3</code> 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.
Note that using the -d switch from the command line will override any previous debug settings and the full debug output will be displayed.


If you prefer some commands to be called by another name, you can set aliases:
If you prefer some commands to be called by another name, you can set aliases using the <code>alias</code> command. The syntax is as follows:
 
<pre>
alias [name] [command]
</pre>
 
 
<code>[name]</code> is the name of the lftpd alias and <code>[command]</code> is the name of the lftpd command. A couple of examples are shown below:


<pre>
<pre>
<nowiki>
alias dir ls
alias dir ls
alias less more
alias less more
Line 216: Line 199:
alias reconnect "close; cache flush; cd ."
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.$$*"
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.$$*"
</nowiki>
</pre>
</pre>


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 should all be in one line. It gets a remote file, opens it with vim, and places the modified file back on the server. This can be very convenient when a file needs to be quickly edited and updated on the remote server.
 
* '''Example usage'''


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


<nowiki>$ lftp -e 'pget -c -n 5 /path/to/file' sftp://username@server</nowiki>
Below is an example of a mult-part download over SFTP:


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


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


== Gui FTP client: About pcmanfm package ==
* -e: execute a command
* pget: the command for partial download, in addition to its options:
** -c: option to resume
** -n: option for number of parts
* <nowiki>sftp://username@server</nowiki>: server URL


PCMAnfM is a filemanager.. that by the usage of the {{Pkg|gvfs}} gio we can use with ftp servers as graphical clients, is easy to use just open the pcmanfm program and then:
== PCManFM with GVfs ==


# From the bar menu open the "go" menu
You can use the PCManFM file manager with the {{Pkg|gvfs}} plugin as a graphical FTP client. To connect to an FTP server, you can do the following:
# Then choose "Connect to a server"
# Choose the FTP protocol and input username (path is optional)
# After a while you will input the password


Check the picture for furter reference:
# From the menubar, go to Go > 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


[[File:Ftp-gui-pcmanfm_at_2020-09-11_14-13-03.png]]
[[File:Ftp-gui-pcmanfm_at_2020-09-11_14-13-03.png]]
Line 249: Line 229:
= See Also =
= See Also =


* [[Alpine newbie developer]]
* [[PXE boot]]
* [[Alpine newbie lammers]]
* https://pkgs.alpinelinux.org/packages?name=tftp-hpa related to [[PXE boot]]


[[Category:Newbie]]
[[Category:Newbie]]

Latest revision as of 05:58, 10 October 2024

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 RFC 114.

Variants of FTP also exist, including SFTP (SSH FTP, not to be confused with Simple FTP) and FTPS (FTP with TLS). SFTP, as the name implies, is done over SSH. FTPS is plain FTP with TLS encryption.

Alpine Linux has various FTP clients and servers that you can install and use, including the following:

Plenty of other clients also exist, but the ones mentioned above are the only ones covered. See #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. On the other hand, vsftpd is more secure and doesn't require many updates.

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

Below is a list of features vsftpd has:

Feature Value/Name Notes
Configuration file /etc/vsftpd/vsftpd.conf The default config is stock from vsftpd
Default Path For Files /var/lib/ftp Because anonymous access is enabled by default, this is the daemon's default home directory
Log Files /var/log/vsftpd.log Configurable in vsftp.conf
User Running The Service vsftpd Alpine does not have an ftp user; it uses a group with the same name instead.
Group(s) to common to vsftpd Used to share things among others daemons or services, like Redis or Apache

Limitations

  • SFTP is not supported

Installation

To install and run vsftpd, simply run apk add vsftpd. Optionally install the vsftpd-doc package alongside for documentation.

To enable vsftpd on startup and start it now, run the following commands.

rc-update add vsftpd default
rc-service vsftpd start

Configuration

The default configuration is not ideal because anonymous access is enabled by default and only IPv4 support is enabled. Therefore, the default configuration should not be used in a production environment. Some common server configuration schemes include allowing anonymous access of files, user system FTP services, and virtual users (on the server end).

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

Managing 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

If starting vsftpd went OK, you should see output similar to the following:

 * 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 run one of the following commands below to achieve the desired effect:

rc-service vsftpd restart

rc-service vsftpd reload

The latter reloads vsftpd's configuration file while the former restarts vsftpd entirely. The latter might be preferred as it prevents having to reload vsftpd entirely.

If you restarted vsftpd, there should be output similar to the following:

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

If you reloaded vsftpd, the output will be similar to the following instead:

 * Reloading vsftpd...                                        [ ok ]

Using the proper runlevel: using the "default" runlevel should work in most cases, although there might be custom runlevels present and it might be more desirable to add vsftpd to a runlevel other than "default". However, keep in mind that runlevels aren't present in Docker containers because Alpine is used mostly in Docker.

To add vsftpd to a runlevel, use the following command:

rc-update add vsftpd [runlevel]

Where [runlevel] is the name of the runlevel you want to add the vsftpd service too. For example, if you want to add vsftpd to the "default" run level, run rc-update add vsftpd default


Testing vsftpd

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

You can use netcat to test if a connection to the server is successful:

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. If you receive another response, review your server configuration.

Clients

Because FTP uses a client-server architecture, you will need an FTP client if you want to interact with an FTP server. Alpine provides several packages for command-line FTP clients:

If you prefer a graphical client, check out the following:

Some web browsers also support FTP, although most major brows, such as Chrome and Firefox, have removed support for the protocol.

lftp

lftp is a sophisticated file transfer program that supports a number of network protocols, including FTP, HTTP, SFTP, FISH, and BitTorrent. It also has the following features:

  • Job control
  • Support for bookmarks
  • Support for a built-in mirror command
  • Support for parallel file transfers
  • Uses readline for input
Feature Value/Name Notes
Package Name lftp Install: apk add lftp
Manpages and -doc Packages vsftpd-doc Install: apk add lftp-doc
System Configuration Files /etc/lftp.conf Little to no customizations are made by Alpine
User Configuration Files ~/.lftprc, ~/.lftp/rc The former is read first while the latter is read second if the former was not found.

Installation

To install lftp, run 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.

Configuration

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 that exact order. These files are used to set system-wide and user-specific settings.

In the configuration file, use the command set followed by the name of the setting followed by its value. Use on/off for boolean values. For example:

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

Specific settings can be set for specific servers only. Append a slash (/) in front of the server name for a specific server.

set ftp:use-feat off /example.com
set ftp:ssl-force on /example.com
Note: The closure for dns:, net:, ftp:, http:, and 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 currently not used. See examples in the sample lftp.conf.

More Info

By default, lftp is not very verbose about operations it performs in the background. If you want more output, 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 using the -d switch from the command line will override any previous debug settings and the full debug output will be displayed.

If you prefer some commands to be called by another name, you can set aliases using the alias command. The syntax is as follows:

alias [name] [command]


[name] is the name of the lftpd alias and [command] is the name of the lftpd command. A couple of examples are shown below:

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 should all be in one line. It gets a remote file, opens it with vim, and places the modified file back on the server. This can be very convenient when a file needs to be quickly edited and updated on the remote server.

Example usage

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

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

Breakdown:

  • -e: execute a command
  • pget: the command for partial download, in addition to its options:
    • -c: option to resume
    • -n: option for number of parts
  • sftp://username@server: server URL

PCManFM with GVfs

You can use the PCManFM file manager with the gvfs plugin as a graphical FTP client. To connect to an FTP server, you can do the following:

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

See Also