Typo
[linux_from_scratch_hints.git] / OLD / ftp.txt
blobcdb24db56c59e9c51438f05e8ca20c27569a6c93
1 TITLE:          proftpd server, lukemftp client and wget
2 LFS VERSION:    3.0-pre3
3 AUTHOR:         Richard Lightman <richard@reika.demon.co.uk>
5 SYNOPSIS:
6         proftpd is an ftp server designed with security in mind. I have heard nasty things about the (lack of) security in wu-ftp. There are about as many ftp clients as there are window manglers. I have found lukemftp to be reliable, and it prvides completion of file names. The one thing lukemftp does not do is continue where it left off if a download fails. For large downloads, I recommend wget.
8 HINT:
9 CHANGES:
10         lukemftp does not require readline
11         Major overhaul based on feedback from Joao Clemente
14 Why these packages
15 ==================
17 publicfile
19 I now use publicfile instead of proftpd. FTP passwords are stored and sent
20 over the net in plain text, so people will be able to sniff passwords off
21 any network the carries them. For this reason sensible people do not allow
22 the ftp daemon to add/remove/change files on the server. publicfile is not
23 even capable of this, and so is immune to configuration errors that would
24 allow it. (You can still accidently allow people to download files you would
25 rather have kept to yourself.)
27 I have not included documentation on how to install publifile because the
28 website is so good.
31 proftpd
33 I picked this one because it is well maintained and has been built with
34 careful consideration for security. ProFTPD powers many well-known,
35 high-volume anonymous FTP sites, including debian.org, kernel.org,
36 redhat.com and sourceforge.net. If you need to have clients add /
37 remove / modify files on the server, then publicfile is will not
38 do that, use openssh as well. It is possible to get proftpd to work
39 with openssh. Take a look at the documentation on proftpd's web page,
40 and when you have it working, update this hint.
43 lukemftp
45 There are dozens of ftp clients. Some of them even work. I dumped
46 two before settling on lukemftp. It has behaved perfectly, has
47 good command line editing with filename completion, and is a port
48 of the NetBSD ftp client. BSD has an exellent reputation for high
49 quality secure software.
52 wget
54 I am too lazy to do things myself, and write scripts to get the
55 computer to do things for me (It only takes twice as long ;-)
56 wget is is good for scripts, and for the actual download. I use
57 lukemftp to find out what I want, then have wget fetch it. My
58 ISP likes to break the connection when I have downloaded 90%
59 of something big, like X. I do not care because the -c option
60 tells wget to continue where it left off.
64 Downloads
65 =========
67 A read-only ftp server:
68 http://cr.yp.to/publicfile.html
70 Full ftp server:
71 ftp://ftp.proftpd.org/distrib/proftpd-1.2.1.tar.bz2
73 Documentation is now included with the sources, but there is more
74 at the web site (NAT and SSH HOWTO's).
75 http://www.proftpd.org/
77 ftp client:
78 ftp://ftp.netbsd.org/pub/NetBSD/misc/lukemftp/lukemftp-1.5.tar.gz
80 Automated ftp client that can continue failed downloads:
81 ftp://ftp.gnu.org/gnu/wget/wget-1.7.tar.gz
85 Installing proftp
86 =================
88 Unpack the source, and change to its directory. If you use PAM, read
89 README.PAM, and when you have it working, update this hint. If you use
90 postgresql or mysql, read README.mod_sql and when you have it working,
91 update this hint.
93 If you like installing as root, miss out the the lines starting with #
95 install_user=$(id -nu) install_group=$(id -ng) \
96   ./configure --prefix=\${DESTDIR}/usr --enable-shadow\
97         --sysconfdir=\${DESTDIR}/etc --with-modules=mod_linuxprivs\
98      --localstatedir=\${DESTDIR}/var
99   mv config.h config.h~
100   sed 's@proftpd.pid@run/proftpd.pid@' >config.h config.h~
101   make
102   #mkdir -p ~/proftpd
103   #make DESTDIR=~/proftpd install # instead of the next line:
104   make DESTDIR= install
105   #cd ~/proftpd
106   ## Take a look around to see if you like it, and make any
107   ## corrections, eg: mkdir usr/share && mv usr/man usr/share
108   #su
109   #chown -R root.root *
110   #cp -a * /
112 HTML documentation is now included with the sources. You may wish
113 to put the following in something like /usr/share/doc/proftpd
114   doc/FAQ-config.html
115   doc/Configuration.html
117 I keep a local web page with links to the htlm docs that come
118 with each package. If things are going really badly I even read
119 them. These docs make configuring proftpd far to easy.
122 configuring proftpd
123 ===================
125 Take a look through /etc/proftpd.conf and fiddle with any settings
126 you do not like. Make any users or groups mentioned in this file.
127 If you did not change anything they are: ftp.ftp and nobody.nogroup
128 The third field of /etc/group or /etc/password contains the group
129 or user id.
131 $ cat /etc/group
132 root:x:0:
133 bin:x:1:
134 sys:x:2:
135 kmem:x:3:
136 tty:x:4:
137 uucp:x:5:
138 daemon:x:6:
139 floppy:x:7:
140 disk:x:8:
141 users:x:9:
142 nofiles:x:10:
143 $ cat /etc/passwd
144 root:x:0:0:root:/root:/bin/bash
145 richard:x:1000:9::/home/richard:/bin/bash
147 On my system the first available system group id's are 11 & 12.
148 The first available system user id's are 1 & 2.
150 groupadd -g 11  ftp
151 useradd -u 1 -g ftp -s /bin/sh -m ftp
152 groupadd -g 12  nogroup
153 useradd -u 2 -g nogroup -d /home nobody
155 Make ftp's home directory (/home/ftp) put some files in there, and make
156 them readable by user ftp. If you think that anonymous users should be
157 able to modify these files, make them writable by ftp, but get you head
158 examined first.
161 Starting proftpd
162 ================
164 You could start proftd from inetd, by removing any existing ftp
165 server from /etc/inetd.conf, and adding:
166 ftp stream tcp nowait root      /usr/sbin/proftpd proftpd
168 You can improve security a little with tcpwrappers:
169 ftp stream tcp nowait root      /usr/sbin/tcpd /usr/sbin/proftpd
171 You could improve security a bit more with xinetd. You could
172 do a really thorough job with ucspi-tcp and daemontools, but
173 then you should be using publicfile/openssh instead of proftpd.
174 For more information, take a look at:
176 http://cr.yp.to/daemontools.html
177 http://cr.yp.to/ucspi-tcp.html
179 If you use any of inetd, xinetd or tcpserver (ucspi-tcp), remember
180 to change the ServerType to inetd in /etc/proftpd.conf
181 This would be a good place to add some instructions for installing
182 inetd, but its getting late and I want to take a break.
184 If you are not using inetd/xinetd/tcpserver, you will need a boot
185 script for proftpd in /etc/init.d:
187 #!/bin/bash
188 #/etc/init.d/proftpd
190 source /etc/init.d/functions
192 case "$1" in
193   start)
194     echo -n "Summoning Pro FTP daemon..."
195     loadproc /usr/sbin/proftpd
196     print_status
197     ;;
199   stop)
200     echo -n "Exorcising Pro FTP daemon..."
201     killproc /usr/sbin/proftpd
202     print_status
203     ;;
205   reload)
206     echo -n "Reloading Pro FTP daemon..."
207     reloadproc /usr/sbin/proftpd -HUP
208     ;;
210   restart)
211     $0 stop
212     sleep 1
213     $0 start
214     ;;
216   status)
217     statusproc /usr/sbin/proftpd
218     ;;
220   *)
221     echo "Usage: $0 {start|stop|restart|reload|status}"
222     ;;
224 esac
228 Enable proftpd on future reboots, and start it now:
230 chmod 754 /etc/init.d/proftpd
231 ln -s  ../init.d/proftpd /etc/rc0.d/K400proftpd
232 ln -s  ../init.d/proftpd /etc/rc1.d/K400proftpd
233 ln -s  ../init.d/proftpd /etc/rc2.d/K400proftpd
234 ln -s  ../init.d/proftpd /etc/rc3.d/S600proftpd
235 ln -s  ../init.d/proftpd /etc/rc4.d/S600proftpd
236 ln -s  ../init.d/proftpd /etc/rc5.d/S600proftpd
237 ln -s  ../init.d/proftpd /etc/rc6.d/K400proftpd
238 /etc/init.d/proftpd start
240 Try out your new ftp server:
241 ftp 127.0.0.1
243 If it does not work, no matter how much you shout at it, threaten it,
244 hit the computer or mallign the authors, and all else has failed, try
245 reading the FAQ in the sources: doc/FAQ-config.html
249 lukemftp
250 ========
252 This one will install with configure/make/make install, but
253 messes around with a pre-formatted man page (a common BSDism).
254 Prefix is supported properly, so non-root installs do not
255 require extra fiddling. If you like to install as root, miss
256 out the lines that start with #.
258 ../configure --prefix=/usr 
259 make
260 #mkdir -p ~/lukemftp/usr/share/man/man1
261 #make prefix=~/lukemftp install # And miss out the next line
262 make install
263 # cp src/ftp.1 ~/lukemftp/usr/share/man/man1/ # And skip the next line
264 cp   src/ftp.1           /usr/share/man/man1/
265 #cd ~/lukemftp
266 ## Take a look around to see if you like it, and make any
267 ## corrections, eg: rm -r usr/man
269 #chown -R root.root *
270 #cp -a * /
273 Many ftp sites want you to use you e-mail address as a password for
274 anonymous access. If you are too lazy to type it, try:
276 echo 'default login anonymous password user@site' >~/.netrc
277 chmod 600 ~/.netrc
279 You can add all the passwords to your ftp sites to .netrc and wget
280 will use them too. This is not a sensible thing to do. The passwords
281 are stored in plain text, and cross the internet in plain text, where
282 any competent cracker can collect them. For more information on .netrc,
283 read "man ftp". If you need password controlled access to files, you
284 should be using openssh remember their is no point in securing read
285 access when ftp transfers the file over the internet without
286 encryption.
290 installing wget
291 ===============
293 This one will install with the standard configure/make/make install.
294 Apart from one glitch with wgetrc it supports DESTDIR properly!
296 Unpack the source, and change to its directory. If you have the socks
297 library, you could configure --with-socks. If you have openssl, you
298 could configure --with-ssl=SSL_ROOT. If you like to install as root,
299 miss out the lines starting with #
301 ./configure --prefix=/usr --sysconfdir=/etc\
302 make
303 #mkdir -p ~/wget/etc
304 #cp doc/sample.wgetrc ~/wget/etc/wgetrc
305 #make DESTDIR=~/wget install # And skip the next line
306 make install
307 #cd ~/wget
308 ## Take a look around to see if you like it, and make any
309 ## corrections, eg: mv usr/man usr/info usr/share
311 #chown -R root.root *
312 #cp -a * /
313 #install-info /usr/share/info/wget.info /usr/share/info/dir