-
-
Notifications
You must be signed in to change notification settings - Fork 183
/
README.TLS
312 lines (213 loc) · 10.7 KB
/
README.TLS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
------------------------ TLS SUPPORT ------------------------
Pure-FTPd supports encryption of the control and data channels using
TLS security mechanisms.
When this extra security layer is enabled, login and passwords are no more
sent as cleartext. Neither are other commands sent by your client nor replies
made by the server.
------------------------ COMPILATION ------------------------
To support TLS, the OpenSSL library must already be installed on your
system. This is a common requirement so your operating system probably
already ships with it.
Pure-FTPd also has to be configured with the --with-tls switch before
compilation :
./configure --with-tls ...
make install-strip
If something goes wrong, try to bring your OpenSSL library up-to-date.
------------------------ CERTIFICATES ------------------------
TLS connections require certificates, as well as their key.
Both can be bundled into a single file. If you have both a `.pem` file
and a `.key` file, just concatenate the content of the `.key` file to
the `.pem` file.
By default, Pure-FTPd will look for a cert+key bundle in the
/etc/ssl/private/pure-ftpd.pem file.
The location can be changed at compile-time with the --with-certfile
and --with-keyfile options passed to ./configure.
It can also be changed at runtime, with the CertFile option in the
configuration file:
CertFile /etc/ssl/private/pure-ftpd.pem
or
CertFileAndKey /etc/pure-ftpd.pem /etc/pure-ftpd.key
The former is for a bundle, the later loads two files.
If you already have a certificate for another service on the same host
(commonly for HTTPS), you can use it as well with Pure-FTPd and other
TLS-enabled services.
Both RSA and ECDSA signatures are supported, but not simultaneously.
For testing purposes, a self-signed certificate can be created as follows:
mkdir -p /etc/ssl/private
openssl req -x509 -nodes -newkey rsa:2048 -sha256 -keyout \
/etc/ssl/private/pure-ftpd.pem \
-out /etc/ssl/private/pure-ftpd.pem
chmod 600 /etc/ssl/private/*.pem
In this example, 2048 is the number of bits used for the RSA key.
Here's what the /etc/ssl/private/pure-ftpd.pem should look like :
-----BEGIN PRIVATE KEY-----
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDV8A/fexof9ttn
uqpwCxXN3C019v40ByGqlfmg8SbTnkjtyt5FLw3ICoxBbQtQ65aYSAv5KtiGQbuc
BZC+FGbR3rIokvHnbhsdLvIvWym+W+VR6U2P8VnbHWd3iSe0xMeTwGJgP9TC8r+c
KfLX9a8EkTKL2iAVRhXuu/it7/A3T2rEomBRWGpmbE+AT69vP2T5ruQ9D7w21GcG
S6ylqlfhRBy61ct3WI1jVR2W5BOXfE8LxgGuJYt0XY+dTrluqen9li8w5ju+3tlA
9PsIl4ckjmYBZm1E7LqoSYDbIh/8D4kUQFLFm6xf27cUOEg3uYAJo5x3SfYlKsSm
6PKzhzDIKcJ1896XG2AHOdIby9VoL8mZwjuMkmmrl1yro++g4XNnMIaTkajPgFzr
NxQ195lXAgMBAADCggEBAMoqmCVc5Dwuf/mO+T72Cr3FgefMJz4tOxBDt2jyWfmC
S3KC0fZY19IgvZeaHyZx6pavBrmIVqLQfSScUcJ97wgGRR94dSZ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ttjrt4kNGaFc
BlhkOrwnAhqbm5N3VQCB63CRpuuCVmYz
-----END CERTIFICATE-----
If you need client certificate verification, prefix the list of
ciphers (-J/--tlsciphersuite) with -C:
pure-ftpd --tlsciphersuite=-C:HIGH -Y2 ...
If you want to do certificate-based client authentication, their
public key must be included in the pure-ftpd.pem file.
If multiple domains are used on the same server, each with its
own certificate, Pure-FTPd supports SNI and custom certificate
handlers (see down below).
------------------------ ACCEPTING TLS SESSIONS ------------------------
Once the certificate has been installed, you need to start a TLS-enabled
pure-ftpd daemon with the -Y (or --tls=) switch. Example :
/usr/local/sbin/pure-ftpd --tls=1 &
- With "--tls=0", support for TLS is disabled. This is the default.
- With "--tls=1", clients can connect either the traditional way or through an
TLS layer. This is probably the setting you need if you want to enable
TLS without having too many angry customers.
- With "--tls=2", cleartext sessions are refused and only TLS compatible
clients are accepted.
- With "--tls=3", cleartext sessions are refused and only TLS compatible
clients are accepted. Clear data connections are also refused, so private
data connections are enforced. This is an extreme setting.
When TLS has been successfully negotiated for a connection, you'll see
something similar to this in log files :
<<
TLS: Enabled TLSv1/SSLv3 with ECDHE-ECDSA-AES128-GCM-SHA256, 128 secret bits cipher
>>
------------------------ CUSTOM CERTIFICATE HANDLERS ------------------------
If multiple domains are used to access the server, each with their own
certificate, Pure-FTPd supports the SNI (Server Name Indication) extension, as
well as a flexible mechanism to map names to certificates.
The pure-certd daemon needs to be started along with the FTP server.
pure-certd listens to certificate requests, runs arbitrary commands written in
any programming language, provides them the client SNI name, and returns what
action has to be taken, and/or where the certificate to use is located.
pure-certd command-line options follow:
-B --daemonize
-g --gid <opt>
-h --help
-p --pidfile <opt>
-r --run <opt>
-s --socket <opt>
-u --uid <opt>
The mandatory ones are --run and --socket. The former indicates what command
to run in order to return actions and certificates, the later is a path to the
local UNIX socket that will be created in order to communicate with the FTP
server.
Example usage:
pure-certd --run /opt/pure-ftpd/bin/certificate-handler.sh \
--socket /var/run/ftpd-certs.sock
The command can access the SNI name in an environment variable named
CERTD_SNI_NAME. If this is a shell script, make sure that the file is
executable.
The command should print the following lines to the standard output:
action:xxx
cert_file:yyy (optional)
key_file:zzz (optional)
end
With xxx being one of:
- deny: access is denied
- default: the default certificate will be used
- strict: the certificate whose path is indicated in "cert_path" will be used.
If absent or invalid, access will be denied.
- fallback: the certificate whose path is indicated in "cert_path" will be used.
If absent or invalid, the default certificate will be used instead.
yyy is the absolute path on the filesystem where the certificate is located.
It can be a certificate+key bundle.
zzz is optional and is the path to the certificate secret key, if it is not
bundled into the PEM file.
If the action is "deny" or "default", "cert_file" and "key_file" do not have
to be provided.
Here is a trivial example script logging the SNI name, and returning a fixed
certificate path:
#! /bin/sh
echo 'action:strict'
echo 'key_file:/etc/pure-ftpd/special.pem'
echo 'done'
Once pure-certd is running, the FTP server must be configured to use it.
This is achieved by enabling the "ExtCert" feature in the configuration file:
ExtCert /var/run/ftpd-certs.sock
The path to the socket must match the one created by pure-certd.
------------------------ COMPATIBLE CLIENTS ------------------------
Pure-FTPd was reported to be fully compatible with the following clients with
the TLS encryption layer turned on :
* Transmit (OSX)
URL: https://panic.com/transmit/
TLS works out of the box, both in implicit and explicit modes.
* CoreFTP Lite (Windows)
URL: http://www.coreftp.com/
TLS perfectly works when "AUTH TLS" is enabled. CoreFTP Lite has some
neat features like IPv6 support, remote file searching, .htaccess editing,
queueing, bandwidth control, etc.
CoreFTP Lite is free both for personal and business use.
* SmartFTP (Windows)
URL: https://www.smartftp.com/
An excellent client with IPv6 support, port range limitation and other
useful features (!= bloat) . And it's free for personal, educational and non-
commercial use. And it detects Pure-FTPd :)
TLS perfectly works when the "FTP over SSL (explicit)" protocol is
selected and when the data connection mode (Tools->Settings->SSL) is set to
"clear data connection" while the AUTH mode (also in Tools->Settings->SSL) is
set to "TLS".
* FlashFXP (Windows)
URL: https://www.flashfxp.com/
TLS works. In the "Quick connect" dialog box, pick the "SSL" tab and :
- enable Auth TLS
- disable Secure File Listing
- disable Secure File Transfers
* SDI FTP (Windows)
URL: https://www.sdisw.com/
TLS works. In the "Connection" tab, just pick "SSL Support: TLSv1".
* LFTP (Unix, MacOS X)
URL: https://lftp.yar.ru/
TLS is automatically detected and works out of the box.
* RBrowser (MacOS X)
URL: http://www.rbrowser.com/
A cute graphical client for MacOS that was reported to work by Jason Rust
and Robert Vasvari.
* Cyberduck (OSX)
https://cyberduck.ch/
TLS works out of the box.
* WinSCP (Windows)
https://winscp.net/eng/index.php
WinSCP should be configured with "File protocol" set to "FTP" with
"TLS Explicit encryption".