Custom Search

Configure ftp server on Ubuntu

After finished the Pure-ftpd installation, you can configure the Pure-ftpd startup file in /etc/default/pureftpd-common. You can change pure-ftpd from a standalone server into the inetd master server if you want. Just change from the default standalone to inetd. In the second part of the configuration file, you can configure ftp server to restricted the contents to one directory or complete file system of your server. If you choose VIRTUALCHROOT=true, then user can only see their home directories.



You can also set some options in a script such as email administrator. Then, provide the path in the UPLOADSCRIPT in the next section of this configuration file. The pure-uploadscript will run this script after a file has been uploaded. You can set a UID and GID to switch user id and group id when running this script.



Use vim editor to configure the pureftpd-common file.


luzar@ubuntu:~$ sudo vim pure-ftpd-common
[sudo] password for luzar:

Here is the default /etc/default/pureftpd-common file opened with vim editor:



# Configuration for pure-ftpd
# (this file is sourced by /bin/sh, edit accordingly)
# STANDALONE_OR_INETD
# valid values are "standalone" and "inetd".
# Any change here overrides the setting in debconf.
STANDALONE_OR_INETD=standalone
# VIRTUALCHROOT:
# whether to use binary with virtualchroot support
# valid values are "true" or "false"
# Any change here overrides the setting in debconf.
VIRTUALCHROOT=false
# UPLOADSCRIPT: if this is set and the daemon is run in standalone mode,
# pure-uploadscript will also be run to spawn the program given below
# for handling uploads. see /usr/share/doc/pure-ftpd/README.gz or
# pure-uploadscript(8)
# example: UPLOADSCRIPT=/usr/local/sbin/uploadhandler.pl
UPLOADSCRIPT=
# if set, pure-uploadscript will spawn $UPLOADSCRIPT running as the
# given uid and gid
UPLOADUID=
UPLOADGID=

The next step is you need to configure other ftp server requirement such as the authentication, log directory, allow anonymous, etc. Pure-ftpd has put all configuration into different files in the /etc/pure-ftpd/conf directory. So change into /etc/pure-ftpd/conf directory with cd command:



luzar@ubuntu:/etc/default$ cd /etc/pure-ftpd/conf
luzar@ubuntu:/etc/pure-ftpd/conf$ ls -l
total 24-rw-r--r-- 1 root root 36 2008-01-24 09:30
AltLog-rw-r--r-- 1 root root 5 2008-01-24 09:30
MinUID-rw-r--r-- 1 root root 4 2008-01-24 09:30
NoAnonymous-rw-r--r-- 1 root root 4 2008-01-24 09:30
PAMAuthentication-rw-r--r-- 1 root root 28 2008-01-24 09:30
PureDB-rw-r--r-- 1 root root 3 2008-01-24 09:30
UnixAuthenticationluzar@ubuntu:/etc/pure-ftpd/conf$

Use your favorite text editor to edit the files. Here are the description and the default configuration value of the files above:



AltLog - path to the pure-ftpd logs directory.



MinUID - Indicates the minimal user ID used by pure-ftpd.



NoAnonymous - Specifies if anonymous users are accepted.



PAMAuthentication - Indicate if PAM authentication is used.



PureDB - An alternative to PAM-based authentication.



UnixAuthentication - Authentication based on /etc/passwd and /etc/shadow.



After finished these configurations, your ftp server is ready for action. Restart your ftp server for the configuration to take effect.



luzar@ubuntu:~$ sudo /etc/init.d/pure-ftpd restart
[sudo] password for luzar:
Restarting ftp server:
Running: /usr/sbin/pure-ftpd -l pam -E -u 1000 -O clf:
/var/log/pure-ftpd/transfer.log -B
luzar@ubuntu:~$

1 comment:

  1. It would ultra helpfull if you describe how to set up the pure-uploadscript to notify of upload by email.

    ReplyDelete

Please keep comment relevant and strictly no spam will be tolerated. Thank you.