How to create global FTP message/banner/greeting with Pure-FTPd on Ubuntu Linux

Written by - 0 comments

Published on - last updated on February 10th 2023 - Listed in Linux


pure-ftpd on Ubuntu (14.04 and later) doesn't use a single configuration file for the settings. Instead there is a wrapper script which reads each parameter from separate config files. This is somewhat documented. However I couldn't find any hint how to activate a global banner or login message to display when a FTP user logs in. Sure, there's the .banner file in the ftp user's home directory. The official doc says:


    ------------------------ DISPLAYING BANNERS ------------------------

If a '.banner' file is located in the 'ftp' user home directory (or in the
root directory of a virtual server, see below), it will be printed when the
client logs in. Put a nice ASCII-art logo with your name in that file.

This file shouldn't be larger than 4000 bytes, or it won't be displayed.

In each directory, you may also have a '.message' file. Its content will be
printed when a client enters the directory. Such a file can contain important
information ("Don't download version 1.7, it's broken!") .

But I want to do a general banner message for everyone and don't want to symlink a .banner every time a new FTP user is created.

There is the possibility however, to load a global banner with the -F flag. It's not called banner or message but Fortune Cookie File:

 A funny random message can be displayed in the initial login banner. The
random cookies are extracted from a text file, in the standard "fortune"
format. If you installed the "fortune" package, you should have a directory
(usually /usr/share/fortune) with binary files (xxxx.dat) and text files
(without the .dat extension) . To use Pure-FTPd cookies, just add the name
of a text file to the '-F' option. For instance:

/usr/local/sbin/pure-ftpd -F /usr/share/fortune/zippy

But how does one tell pure-ftpd to use this flag now? The answer is in the wrapper script (/usr/sbin/pure-ftpd-wrapper):

$ cat /usr/sbin/pure-ftpd-wrapper
[...]
my %conf = ('AllowAnonymousFXP' => ['-W'],
            'AllowDotFiles' => ['-z'],
[...]
            'FortunesFile' => ['-F %s', \&parse_filename],
            'FSCharset' => ['-8 %s', \&parse_string],
[...]
            );

As you can see, the wrapper script is already prepared for a separate config file called "FortunesFile". The correct file name must be used, or it won't work.

So I created this FortunesFile with the path to the file containing the actual banner message:

# echo "/etc/pure-ftpd/Banner.txt" > /etc/pure-ftpd/conf/FortunesFile

And in the banner file itself, I added the wanted general information:

$ cat /etc/pure-ftpd/Banner.txt
This FTP server is read only. And private, too.

Files older than 30 days will be automatically deleted!

********************************************

A restart of pure-ftpd confirmed that the -F flag was now being used:

# /etc/init.d/pure-ftpd restart
Restarting ftp server: Running: /usr/sbin/pure-ftpd -l puredb:/etc/pure-ftpd/pureftpd.pdb -l pam -A -O clf:/var/log/pure-ftpd/transfer.log -F /etc/pure-ftpd/Banner.txt -p 20000:20500 -u 1000 -8 UTF-8 -d -Y 1 -E -U 117:007 -B

And in an FTP client (here FileZilla), the banner message is now shown:

pure-ftpd banner


Add a comment

Show form to leave a comment

Comments (newest first)

No comments yet.

RSS feed

Blog Tags:

  AWS   Android   Ansible   Apache   Apple   Atlassian   BSD   Backup   Bash   Bluecoat   CMS   Chef   Cloud   Coding   Consul   Containers   CouchDB   DB   DNS   Database   Databases   Docker   ELK   Elasticsearch   Filebeat   FreeBSD   Galera   Git   GlusterFS   Grafana   Graphics   HAProxy   HTML   Hacks   Hardware   Icinga   Influx   Internet   Java   KVM   Kibana   Kodi   Kubernetes   LVM   LXC   Linux   Logstash   Mac   Macintosh   Mail   MariaDB   Minio   MongoDB   Monitoring   Multimedia   MySQL   NFS   Nagios   Network   Nginx   OSSEC   OTRS   Office   PGSQL   PHP   Perl   Personal   PostgreSQL   Postgres   PowerDNS   Proxmox   Proxy   Python   Rancher   Rant   Redis   Roundcube   SSL   Samba   Seafile   Security   Shell   SmartOS   Solaris   Surveillance   Systemd   TLS   Tomcat   Ubuntu   Unix   VMWare   VMware   Varnish   Virtualization   Windows   Wireless   Wordpress   Wyse   ZFS   Zoneminder