README.TLS 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. ------------------------ TLS SUPPORT ------------------------
  2. Pure-FTPd supports encryption of the control and data channels using
  3. TLS security mechanisms.
  4. When this extra security layer is enabled, login and passwords are no more
  5. sent as cleartext. Neither are other commands sent by your client nor replies
  6. made by the server.
  7. ------------------------ COMPILATION ------------------------
  8. To support TLS, the OpenSSL library must already be installed on your
  9. system. This is a common requirement so your operating system probably
  10. already ships with it.
  11. Pure-FTPd also has to be configured with the --with-tls switch before
  12. compilation :
  13. ./configure --with-tls ...
  14. make install-strip
  15. If something goes wrong, try to bring your OpenSSL library up-to-date.
  16. ------------------------ CERTIFICATES ------------------------
  17. TLS connections require certificates, as well as their key.
  18. Both can be bundled into a single file. If you have both a `.pem` file
  19. and a `.key` file, just concatenate the content of the `.key` file to
  20. the `.pem` file.
  21. By default, Pure-FTPd will look for a cert+key bundle in the
  22. /etc/ssl/private/pure-ftpd.pem file.
  23. The location can be changed at compile-time with the --with-certfile
  24. and --with-keyfile options passed to ./configure.
  25. It can also be changed at runtime, with the CertFile option in the
  26. configuration file:
  27. CertFile /etc/ssl/private/pure-ftpd.pem
  28. or
  29. CertFileAndKey /etc/pure-ftpd.pem /etc/pure-ftpd.key
  30. The former is for a bundle, the later loads two files.
  31. If you already have a certificate for another service on the same host
  32. (commonly for HTTPS), you can use it as well with Pure-FTPd and other
  33. TLS-enabled services.
  34. Both RSA and ECDSA signatures are supported, but not simultaneously.
  35. For testing purposes, a self-signed certificate can be created as follows:
  36. mkdir -p /etc/ssl/private
  37. openssl dhparam -out /etc/ssl/private/pure-ftpd-dhparams.pem 2048
  38. openssl req -x509 -nodes -newkey rsa:2048 -sha256 -keyout \
  39. /etc/ssl/private/pure-ftpd.pem \
  40. -out /etc/ssl/private/pure-ftpd.pem
  41. chmod 600 /etc/ssl/private/*.pem
  42. In this example, 2048 is the number of bits used for the RSA key.
  43. Here's what the /etc/ssl/private/pure-ftpd.pem should look like :
  44. -----BEGIN PRIVATE KEY-----
  45. MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDV8A/fexof9ttn
  46. uqpwCxXN3C019v40ByGqlfmg8SbTnkjtyt5FLw3ICoxBbQtQ65aYSAv5KtiGQbuc
  47. BZC+FGbR3rIokvHnbhsdLvIvWym+W+VR6U2P8VnbHWd3iSe0xMeTwGJgP9TC8r+c
  48. KfLX9a8EkTKL2iAVRhXuu/it7/A3T2rEomBRWGpmbE+AT69vP2T5ruQ9D7w21GcG
  49. S6ylqlfhRBy61ct3WI1jVR2W5BOXfE8LxgGuJYt0XY+dTrluqen9li8w5ju+3tlA
  50. 9PsIl4ckjmYBZm1E7LqoSYDbIh/8D4kUQFLFm6xf27cUOEg3uYAJo5x3SfYlKsSm
  51. 6PKzhzDIKcJ1896XG2AHOdIby9VoL8mZwjuMkmmrl1yro++g4XNnMIaTkajPgFzr
  52. NxQ195lXAgMBAADCggEBAMoqmCVc5Dwuf/mO+T72Cr3FgefMJz4tOxBDt2jyWfmC
  53. S3KC0fZY19IgvZeaHyZx6pavBrmIVqLQfSScUcJ97wgGRR94dSZ48yBp260KnfDo
  54. UFVOfeA3d+1K5RqdvqrhhaPHGm/QAhPTZ2SgUl8fEPqr7eZU4HhAcyPaLCMKFsV/
  55. lbfY2C4Kq54o2m1uHFTertx5niE4Yx6ALqBB66rR4It7lnr7kBhAnIsCYj7ENGrU
  56. 6C1PzjpvrqjWqnYjbmzUov7b4S308YGqWKrfkJxTrviVaITI1XznAHlTBDLkuU1l
  57. eSyZ0YP3Gfd82j9fhdugH2nLxLCttcmGNOaA87VlXL/oZaYI5P5xqjyjkCgYEA6x
  58. Fy30dcPM+VKDhnp2QBbHrJC0zr88Hn4qYxIfyoPtjrvTb+vSI703Cd0rc00alGK6
  59. YZZKDV1NYKw8/r2uHRXgbpptYdRKz+GrsgNdORycKXkmWXw+ChIHsl/UghHG60jy
  60. KNPSkOJgPXIseJDn2ZcqlFLkl6sCgYEA6Pr+L1otzG//ROJdBV58yHO0V2KF9VKM
  61. amt5RUWkqRqfOiE0i5T3nmBPPflNB4bdj8qe+DwoPly2SJMihT7KQqvg54V/ZVb+
  62. jXY0fNLEDhJ0PdboB2I/r6SuWBNJyXF8AAewzcDF3PlBr/JGOHF4XGmOLVmiNL/N
  63. +6RPLW5i6QUCgYA0sRq2M9QsGCy61xkTDwf2xbbSQ/6bTCPpZbHIKn98wDzXkOwr
  64. XMqneD7teYiBUi98jhMiMOMmaygEDsU8TpW2vSa0+CaL6zR17Itr/015Wj6SrkDw
  65. G/TvckxGt5MzB7hYRYZYI0bdCOMPpkAxipluRG/SFh+FvuVZTpsKuDHpFQKBgFrA
  66. ThXzmNlx069BYNj2NGL0AI8ueQlIca84tAlLMAMrPQw5gfgeVSBdzWuRV9SX1+1L
  67. EZuT037XuLaIcMHbsT6N/0u69mwFqn6y6gSQUwbhAoGAYa6eN7KUA0Xri5zrABst
  68. S2PP2rrmrnFLohNJ5CAWR7vvk6aKkMd+hEAJTk6s+vc7B3NHR/icIu1CnXWxKhB7
  69. AI0SIL0losHuBfCst8CTpqZ//Jjvi0IbOm+SNI/aqYcrrHrzdkSWYLC6Ll16Ckrg
  70. xeBXhXuiP9wEJSDmg7wb1t0=
  71. -----END PRIVATE KEY-----
  72. -----BEGIN CERTIFICATE-----
  73. MIIDFDCCAfwCCQC/UlBaK8CNnDANBgkqhkiG9w0BAQUFADBMMQswCQYDVQQGEwJG
  74. UjEOMAwGA1UEBwwFUGFyaXMxEjAQBgNVBAoMCVB1cmUtRlRQZDEZMBcGA1UEAwwQ
  75. ZnRwLnB1cmVmdHBkLm9yZzAeFw0xNTAyMjExNDE1MTlaFw0xNTAMzjMxNDE1MTla
  76. MEwxCzAJBgNVBAYTAkZSMQ4wDAYDVQQHDAVQYXJpczESMBAGA1UECgwJUHVyZS1G
  77. VFBkMRkwFwYDVQQDDBBmdHAucHVyZWZ0cGQub3JnMIIBIjANBgkqhkiG9w0BAQEF
  78. FEBSxZusX9u3FDhIN7mACaOcd0n2JSrEpujys4cwyCnCdfPelxtgBznSG8vVaC/J
  79. IBCgKCAQEA1fAP33saH/bbZ7qqcAsVzdwtNfb+NAchqpX5oPEmqGSIb3DQEB055I
  80. 7creRS8NyAqMQW0LUOuWmEgL+SrYhkG7nAWQvhRm0d6yKJLx524bHS7yL1spvlvl
  81. UelNj/FZ2x1nd4kntMTHk8BiYD/UwvK/nEuspapX4UQcutXLd1iNY1UdluQTl3xP
  82. C8YBriWLdF2PnU65bqnp/ZYvMOY7vt7ZQPT7CJeHJI5mAWZtROy6qEmA2yIf/A+J
  83. mcI7jJJpq5dc6qAAOCAQ8AMIPvoOF3ksmdGD9xn3fNozcUNfeZVwIDAQABMA0GCS
  84. BqUAA4IBAQDT768mdG071/m6V1N4qeM5PVrpa5eB5mulE7JPBOPJADmw6YwYaSWJ
  85. 90wE+YuU6DiDbRxHtWiCMwHoCH42fxU7BDVNrc3L614v1kUQGTLlHPyAUs6KZvz0
  86. Rko2y6Dzj+kVaJiWFKi+zWwWnf9P4wLYafv/n5EHKmEt1K83UE0h5r64fhwX9vH7
  87. 6NHCMbmSDXgHjnv3rZKOOKN85ZYr2vKX+rTvASh2nxp2bbNM1XpfyuH2vbWL3J+E
  88. mFCaj3/lD880kHnTaTwo3Kg0SQy/Axe2LhX3zj+kSD2A9k6wtGcKttjrt4kNGaFc
  89. BlhkOrwnAhqbm5N3VQCB63CRpuuCVmYz
  90. -----END CERTIFICATE-----
  91. If you need client certificate verification, prefix the list of
  92. ciphers (-J/--tlsciphersuite) with -C:
  93. pure-ftpd --tlsciphersuite=-C:HIGH -Y2 ...
  94. If you want to do certificate-based client authentication, their
  95. public key must be included in the pure-ftpd.pem file.
  96. If multiple domains are used on the same server, each with its
  97. own certificate, Pure-FTPd supports SNI and custom certificate
  98. handlers (see down below).
  99. ------------------------ ACCEPTING TLS SESSIONS ------------------------
  100. Once the certificate has been installed, you need to start a TLS-enabled
  101. pure-ftpd daemon with the -Y (or --tls=) switch. Example :
  102. /usr/local/sbin/pure-ftpd --tls=1 &
  103. - With "--tls=0", support for TLS is disabled. This is the default.
  104. - With "--tls=1", clients can connect either the traditional way or through an
  105. TLS layer. This is probably the setting you need if you want to enable
  106. TLS without having too many angry customers.
  107. - With "--tls=2", cleartext sessions are refused and only TLS compatible
  108. clients are accepted.
  109. - With "--tls=3", cleartext sessions are refused and only TLS compatible
  110. clients are accepted. Clear data connections are also refused, so private
  111. data connections are enforced. This is an extreme setting.
  112. When TLS has been successfully negotiated for a connection, you'll see
  113. something similar to this in log files :
  114. <<
  115. TLS: Enabled TLSv1/SSLv3 with ECDHE-ECDSA-AES128-GCM-SHA256, 128 secret bits cipher
  116. >>
  117. ------------------------ CUSTOM CERTIFICATE HANDLERS ------------------------
  118. If multiple domains are used to access the server, each with their own
  119. certificate, Pure-FTPd supports the SNI (Server Name Indication) extension, as
  120. well as a flexible mechanism to map names to certificates.
  121. The pure-certd daemon needs to be started along with the FTP server.
  122. pure-certd listens to certificate requests, runs arbitrary commands written in
  123. any programming language, provides them the client SNI name, and returns what
  124. action has to be taken, and/or where the certificate to use is located.
  125. pure-certd command-line options follow:
  126. -B --daemonize
  127. -g --gid <opt>
  128. -h --help
  129. -p --pidfile <opt>
  130. -r --run <opt>
  131. -s --socket <opt>
  132. -u --uid <opt>
  133. The mandatory ones are --run and --socket. The former indicates what command
  134. to run in order to return actions and certificates, the later is a path to the
  135. local UNIX socket that will be created in order to communicate with the FTP
  136. server.
  137. Example usage:
  138. pure-certd --run /opt/pure-ftpd/bin/certificate-handler.sh \
  139. --socket /var/run/ftpd-certs.sock
  140. The command can access the SNI name in an environment variable named
  141. CERTD_SNI_NAME. If this is a shell script, make sure that the file is
  142. executable.
  143. The command should print the following lines to the standard output:
  144. action:xxx
  145. cert_file:yyy (optional)
  146. key_file:zzz (optional)
  147. end
  148. With xxx being one of:
  149. - deny: access is denied
  150. - default: the default certificate will be used
  151. - strict: the certificate whose path is indicated in "cert_path" will be used.
  152. If absent or invalid, access will be denied.
  153. - fallback: the certificate whose path is indicated in "cert_path" will be used.
  154. If absent or invalid, the default certificate will be used instead.
  155. yyy is the absolute path on the filesystem where the certificate is located.
  156. It can be a certificate+key bundle.
  157. zzz is optional and is the path to the certificate secret key, if it is not
  158. bundled into the PEM file.
  159. If the action is "deny" or "default", "cert_file" and "key_file" do not have
  160. to be provided.
  161. Here is a trivial example script logging the SNI name, and returning a fixed
  162. certificate path:
  163. #! /bin/sh
  164. echo 'action:strict'
  165. echo 'key_file:/etc/pure-ftpd/special.pem'
  166. echo 'done'
  167. Once pure-certd is running, the FTP server must be configured to use it.
  168. This is achieved by enabling the "ExtCert" feature in the configuration file:
  169. ExtCert /var/run/ftpd-certs.sock
  170. The path to the socket must match the one created by pure-certd.
  171. ------------------------ COMPATIBLE CLIENTS ------------------------
  172. Pure-FTPd was reported to be fully compatible with the following clients with
  173. the TLS encryption layer turned on :
  174. * Transmit (OSX)
  175. URL: https://panic.com/transmit/
  176. TLS works out of the box, both in implicit and explicit modes.
  177. * CoreFTP Lite (Windows)
  178. URL: http://www.coreftp.com/
  179. TLS perfectly works when "AUTH TLS" is enabled. CoreFTP Lite has some
  180. neat features like IPv6 support, remote file searching, .htaccess editing,
  181. queueing, bandwidth control, etc.
  182. CoreFTP Lite is free both for personal and business use.
  183. * SmartFTP (Windows)
  184. URL: https://www.smartftp.com/
  185. An excellent client with IPv6 support, port range limitation and other
  186. useful features (!= bloat) . And it's free for personal, educational and non-
  187. commercial use. And it detects Pure-FTPd :)
  188. TLS perfectly works when the "FTP over SSL (explicit)" protocol is
  189. selected and when the data connection mode (Tools->Settings->SSL) is set to
  190. "clear data connection" while the AUTH mode (also in Tools->Settings->SSL) is
  191. set to "TLS".
  192. * FlashFXP (Windows)
  193. URL: https://www.flashfxp.com/
  194. TLS works. In the "Quick connect" dialog box, pick the "SSL" tab and :
  195. - enable Auth TLS
  196. - disable Secure File Listing
  197. - disable Secure File Transfers
  198. * SDI FTP (Windows)
  199. URL: https://www.sdisw.com/
  200. TLS works. In the "Connection" tab, just pick "SSL Support: TLSv1".
  201. * LFTP (Unix, MacOS X)
  202. URL: https://lftp.yar.ru/
  203. TLS is automatically detected and works out of the box.
  204. * RBrowser (MacOS X)
  205. URL: http://www.rbrowser.com/
  206. A cute graphical client for MacOS that was reported to work by Jason Rust
  207. and Robert Vasvari.
  208. * Cyberduck (OSX)
  209. https://cyberduck.ch/
  210. TLS works out of the box.
  211. * WinSCP (Windows)
  212. https://winscp.net/eng/index.php
  213. WinSCP should be configured with "File protocol" set to "FTP" with
  214. "TLS Explicit encryption".