Setup secure ProFTPd
Fri, 06/12/2009 - 14:42 — sandipFtp can be secured using ftps to connect. Below outlines a configuration to support such a setup using TLS/SSL.
I usually use the epel repository to install proftpd:
yum --enablerepo=epel install proftpd
Configure for tls/ssl connection:
<IfModule mod_tls.c>
TLSEngine & nbsp; & nbsp; & nbsp; & nbsp; on
TLSRequired   ;   ;   ;   ; off
TLSRSACertificateFile & nbsp; & nbsp; /etc/pki/tls/proftpd/server.ce rt.pem
TLSRSACertificateKeyFile&nbs p; &nbs p; /etc/pki/tls/proftpd/server.ke y.pem
TLSVerifyClient & nbsp; & nbsp; & nbsp; off
TLSRenegotiate &n bsp; &n bsp; &n bsp; required off
TLSLog &nbs p; &nbs p; &nbs p; &nbs p; &nbs p; /var/log/proftpd/tls.log
</IfModule>
chroot and bindsocket to listen to single IP:
SocketBindTight & nbsp; & nbsp; & nbsp; on
DefaultRoot   ;   ;   ;   ; ~
Setup passive ftp ports:
</Global>
...
...
PassivePorts 50000 51000
</Global>
Create the certs:
mkdir -p /etc/pki/tls/proftpd
cd /etc/pki/tls/proftpd
openssl req -new -x509 -days 9999 -nodes -out server.cert.pem -keyout server.key.pem
Create /etc/pam.d/ftp so PAM can authenticate for proftpd:
#%PAM-1.0
auth required &nbs p; pam_unix.so & nbsp; nullok
account required &nbs p; pam_unix.so
session required &nbs p; pam_unix.so
Add "/bin/false" to "/etc/shells" file and use it as the shell type when creating new users:
useradd -s /bin/false <ftp_user>
- sandip's blog
- Login or register to post comments
Configure passive ports range for ProFTPd
Fri, 06/12/2009 - 14:23 — sandipUsually, if a client is behind firewall, they can only trasfer files via a passive ftp connection.
Edit /etc/proftpd.conf and specify the passive ports range. Place it in the 'Global' container:
</Global>
...
...
# Use the IANA registered ephemeral port range
PassivePorts 49152 65534
</Global>
Reference: proftpd.org
Load the ip_conntrack_ftp module and iptables rules, so the ports automatically open to the connected client:
# /sbin/modprobe ip_conntrack_ftp
# lsmod | grep conntrack_ftp
ip_conntrack_ftp 41489 0
ip_conntrack &nbs p; &nbs p; 91237 4 xt_state,xt_conntrack,ip_connt rack_ftp,ip_conntrack_irc
Add the below iptables rules:
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
If the server is beind NAT, ip_nat_ftp module also should be loaded:
# /sbin/modprobe ip_nat_ftp
Force ProFTPD to listen on only one IP
Sun, 02/24/2008 - 00:10 — sandipIt's not quite as clean as the socket binding under Apache but the principle works something like this.
-
In Standalone mode, to listen on the primary IP of a host use the SocketBindTight directive.
In "/etc/proftpd.conf":
SocketBindTight onTo listen on a interfaces which are not the primary host interface, use the SocketBindTight directive, place your server configuration in a
Port &n bsp; &n bsp; &n bsp; &n bsp; &n bsp; 0
SocketBindTight & nbsp; & nbsp; & nbsp; on
<VirtualHost xxx.xxx.xxx.xxx>
&nbs p; Port 21
&nbs p; DefaultRoot & nbsp; & nbsp; ~
&nbs p; AllowOverwrite &nbs p; &nbs p; on
&nbs p; Umask & nbsp; & nbsp; & nbsp; 002
</VirtualHost>
Analyzing proftpd xferlog file
Tue, 01/29/2008 - 10:59 — wizapRecently I've had to research on some missing files of a website.
When looking through the proftpd xferlog files, it was clear that the files were deleted by a user having ftp access.
The xferlog file is usually located at "/var/log/xferlog". However, since this was a plesk server, it was located at:
"/var/www/vhosts/{DOMAIN}/sta
A quick grep produced the files that were deleted out and could easily be recovered from a previous backup. Also, discovered the time and offending IP address of the person that did the deletes.
Full listing:
$ grep "_ d" /path/to/xferlog
Listing of just the deleted files:
$ awk '/_ d/ {print $9}' /path/to/xferlog
Below are some additional notes on xferlog anlysis: