FTP: Difference between revisions
m (Format fix + some more typo fixes) |
(Added more info about FTP, more typo fixes and improvements) |
||
Line 1: | Line 1: | ||
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 (more on [https://en.wikipedia.org/wiki/Ftp#History_of_FTP_servers Wikipedia]). | 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 (more on [https://en.wikipedia.org/wiki/Ftp#History_of_FTP_servers Wikipedia]). | ||
There are also varients 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: | Alpine Linux has various FTP clients and servers that you can install and use: | ||
Line 5: | Line 7: | ||
* {{Pkg|vsftpd}} (server) | * {{Pkg|vsftpd}} (server) | ||
* {{Pkg|ncftp}} (client) | * {{Pkg|ncftp}} (client) | ||
* {{Pkg|lftpd}} (client, | * {{Pkg|lftpd}} (client, but see below for more details). | ||
* You can also use {{Pkg|pcmanfm}} with the {{Pkg|gvfs}} plugin as a graphical FTP client. | * You can also use {{Pkg|pcmanfm}} with the {{Pkg|gvfs}} plugin as a graphical FTP client. | ||
There are also plenty of other clients available too. However | There are also plenty of other clients available too. However, we will only be covering the clients and servers mentioned above. | ||
= FTP Server: vsftpd = | |||
{{Pkg|vsftpd}} is not very used due common hosting panels does not handle it's configurations management. | In Alpine Linux the default FTP server is {{Pkg|vsftpd}}. However, it is not very used due common hosting panels does not handle it's configurations management. In constrast {{Pkg|vsftpd}} are secured respect rest of others without so much updates. | ||
=== FTP server: About vsftpd package === | === FTP server: About vsftpd package === | ||
'''It was the most secured FTP server'''. It is the default FTP server in | '''It was the most secured FTP server'''. It is the default FTP server in NimbleX, Slackware, and many others. | ||
{{Note|As for minimal FTP's and fast server purposes are very recommended due it easy configuration process and perfect performance without much configuration.}} | {{Note|As for minimal FTP's and fast server purposes are very recommended due it easy configuration process and perfect performance without much configuration.}} | ||
Line 26: | Line 26: | ||
! Feature !! Value/Name !! Observations | ! Feature !! Value/Name !! Observations | ||
|- | |- | ||
| | | 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> | ||
Line 32: | Line 32: | ||
| Configuration file || {{Path|/etc/vsftpd/vsftpd.conf}} || It's not close to alpine, just vanilla provived! | | Configuration file || {{Path|/etc/vsftpd/vsftpd.conf}} || It's not close to alpine, just vanilla provived! | ||
|- | |- | ||
| Default | | Default path for files || {{Path|/var/lib/ftp}} || cos anonnimous 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 also | ||
Line 40: | Line 40: | ||
| Group to common to || vsftpd || Used to share things among 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 files | ||
|- | |- | ||
| Written | | Written in || C || Main engine code in C | ||
|} | |} | ||
Line 109: | Line 109: | ||
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. | 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. | ||
If you are using alpine | If you are using alpine remotely as web server and just install it the package, change <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. | ||
The common response will be '''OPEN''' if server are running. | The common response will be '''OPEN''' if server are running. | ||
Line 122: | Line 122: | ||
* [[Alpine newbie lammers]] | * [[Alpine newbie lammers]] | ||
= | = 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 Linux provides two packages for command line and batch processing of FTP protocol, apart of the {{Pkg|firefox}} package: the {{Pkg|lftp}} and the {{Pkg|ncftp}} packages. | |||
* | * GUI programs: | ||
** {{Pkg|pcmanfm}} | ** {{Pkg|pcmanfm}}. Check out [[#Gui_FTP_client:_About_pcmanfm_package]] | ||
** {{Pkg|firefox}} | ** {{Pkg|firefox}} | ||
* | * CLI programs: | ||
** {{Pkg|lftp}} | ** {{Pkg|lftp}}. Check out [[#lftp]] | ||
** {{Pkg|ncftp}} | ** {{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.''' | 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.''' | ||
== | == lftp == | ||
LFTP is a sophisticated file transfer program that supports a number of network protocols. Such include FTP, HTTP, SFTP, FISH, and BitTorrent (and potentially more). | |||
lftp has the following features: | |||
* Has job control and.. | * Has job control and.. | ||
Line 147: | Line 149: | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! Feature | ! Feature !! Value/Name !! Observations | ||
|- | |- | ||
| Main package name || lftp || <code><nowiki>apk add lftp</nowiki></code> | | Main package name || lftp || <code><nowiki>apk add lftp</nowiki></code> | ||
Line 159: | Line 161: | ||
| Configuration file (user) || {{Path|~/.lftp/rc}} || second attempt to parse if first not found! | | Configuration file (user) || {{Path|~/.lftp/rc}} || second attempt to parse if first not found! | ||
|- | |- | ||
| | | Written in || C || Main engine code in C | ||
|} | |} | ||
=== Installing lftp === | === Installing lftp === | ||
lftp has been provided in the main repository since 3.6, so '''is a team supported package ready for production''' deploys. | |||
<pre> | <pre> | ||
Line 235: | Line 237: | ||
* -n: pget option for number of parts | * -n: pget option for number of parts | ||
== | == PCManFM with GVfs == | ||
While PCManFM is a filemanager, by using the {{Pkg|gvfs}} plugin, we can use PCManFM as a graphical FTP client. To use PCManFM as an FTP client, you can do the following: | |||
# From the | # From the menubar open the "go" menu | ||
# | # Choose "Connect to a server" | ||
# Choose the FTP protocol and input username (path is optional) | # Choose the FTP protocol and input username (path is optional) | ||
# After a while you will input the password | # After a while you will input the password | ||
Check the picture for | Check the picture for further reference: | ||
[[File:Ftp-gui-pcmanfm_at_2020-09-11_14-13-03.png]] | [[File:Ftp-gui-pcmanfm_at_2020-09-11_14-13-03.png]] |
Revision as of 19:28, 9 February 2021
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 (more on Wikipedia).
There are also varients 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:
- vsftpd (server)
- ncftp (client)
- lftpd (client, but see below for more details).
- You can also use pcmanfm with the gvfs plugin as a graphical FTP client.
There are also plenty of other clients available too. However, we will only be covering the clients and servers mentioned above.
FTP Server: vsftpd
In Alpine Linux the default FTP server is vsftpd. However, it is not very used due common hosting panels does not handle it's configurations management. In constrast vsftpd are secured respect rest of others without so much updates.
FTP server: About vsftpd package
It was the most secured FTP server. It is the default FTP server in NimbleX, Slackware, and many others.
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 | It's not close to alpine, just vanilla provived! |
Default path for files | /var/lib/ftp | cos anonnimous are default, is home for daemon user |
Log files (error, access, etc) | /var/log/vsftpd.log | Defined in vsftp.conf also |
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 files |
Written in | C | Main engine code in C |
Important Limitations
vsftp does not support SFTP, but it does have support for FTPS.
Install 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".
vsftd is available in the Alpine Linux repositories. To install, simply launch the commands below:
apk add vsftpd rc-update add vsftpd default rc-service vsftpd restart
vsftpd Configuration
By default, Alpine's 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.
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.
Controlling vsftpd
Start 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
You will get a feedback about the status.
* Caching service dependencies ... [ ok ] * Starting vsftpd... [ ok ]
Stop vsftpd: If you want to stop the web server use stop in the same way of previous command:
rc-service vsftpd stop
Restart lighttpd: After changing the configuration file lighttpd needs to be restarted.
rc-service vsftpd restart
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
rc-update add vsftpd default
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.
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.
If you are using alpine remotely as web server and just install it the package, change 127.0.0.1
with IP of the alpine machine. The "webserveripaddres" are the IP address of your setup/server machine.
The common response will be OPEN if server are running.
See also about vsftpd
- Production Lets Encrypt: dehydrated
- Production FTP user service: vsftpd
- Production FTP virtual users: vsftpd + MySQL
- Production VSFTP system: vsftpd + MySQL + SFTP
- Alpine newbie developer
- Alpine newbie lammers
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 Linux provides two packages for command line and batch processing of FTP protocol, apart of the firefox package: the lftp and the ncftp packages.
- GUI programs:
- pcmanfm. Check out #Gui_FTP_client:_About_pcmanfm_package
- firefox
- CLI programs:
So then, commonly a web browser (firefox) supports FTP protocol so our FTP server just configured can be browsed using the address ftp://<webserveripaddres>
The "webserveripaddres" are the ip address of your setup/server machine.
lftp
LFTP is a sophisticated file transfer program that supports a number of network protocols. Such include FTP, HTTP, SFTP, FISH, and BitTorrent (and potentially more).
lftp has the following features:
- Has job control and..
- uses the readline library for input.
- It has bookmarks,
- Has built-in mirror command
- Can transfer several files in parallel.
Feature | Value/Name | Observations |
---|---|---|
Main package name | lftp | apk add lftp
|
Manpages and DOCs packages | vsftpd-doc | apk add lftp-doc
|
Configuration file (system) | /etc/lftp.conf | It's not close to alpine, just vanilla provived! |
Configuration file (user) | ~/.lftprc | if found the first to parse! |
Configuration file (user) | ~/.lftp/rc | second attempt to parse if first not found! |
Written in | C | Main engine code in C |
Installing lftp
lftp has been provided in the main repository since 3.6, so is a team supported package ready for production deploys.
apk add lftp
Configuring lftp
The main configuration file, /etc/lftp.conf
comes with various examples and comments. On startup, lftp executes /etc/lftp.conf
and then ~/.lftprc
and ~/.lftp/rc
. 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:
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
General lftp usage examples
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):
- 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
short explanation:
- -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 filemanager, by using the gvfs plugin, we can use PCManFM as a graphical FTP client. To use PCManFM as an FTP client, you can do the following:
- From the menubar open the "go" menu
- 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 further reference: