Skip to content

Instantly share code, notes, and snippets.

@olmosleo
Last active March 28, 2017 19:13
Show Gist options
  • Save olmosleo/5df53b49eb620133f5d7993d9f357010 to your computer and use it in GitHub Desktop.
Save olmosleo/5df53b49eb620133f5d7993d9f357010 to your computer and use it in GitHub Desktop.
Install vsFTPd on CentOS 7 (FTP Server)
#!/bin/bash
sudo yum update -y
sudo yum install -y vim nano telnet screen nmap openssh-clients wget rsync git net-tools unzip traceroute
sudo yum -y install vsftpd
VSFTP_CONF="/etc/vsftpd/vsftpd.conf";
sudo cp $VSFTP_CONF $VSFTP_CONF.".RESPALDO";
echo "# vsFTPD Auto-Config Script" > $VSFTP_CONF;
echo "anonymous_enable=NO" >> $VSFTP_CONF;
echo "local_enable=YES" >> $VSFTP_CONF;
echo "write_enable=YES" >> $VSFTP_CONF;
echo "local_umask=022" >> $VSFTP_CONF;
echo "dirmessage_enable=YES" >> $VSFTP_CONF;
echo "ftpd_banner='Direccion del Trabajo - FTP Server (ex-melinka).'" >> $VSFTP_CONF;
echo "xferlog_enable=YES" >> $VSFTP_CONF;
echo "connect_from_port_20=YES" >> $VSFTP_CONF;
echo "xferlog_std_format=YES" >> $VSFTP_CONF;
echo "xferlog_file=/var/log/vsftpd.log" >> $VSFTP_CONF;
echo "xferlog_std_format=YES" >> $VSFTP_CONF;
echo "chroot_local_user=YES" >> $VSFTP_CONF;
echo "listen=YES" >> $VSFTP_CONF; # For used IPV4
echo "listen_ipv6=NO" >> $VSFTP_CONF; # For used IPV6
echo "pam_service_name=vsftpd" >> $VSFTP_CONF;
echo "userlist_enable=YES" >> $VSFTP_CONF;
echo "tcp_wrappers=YES" >> $VSFTP_CONF;
echo "syslog_enable=YES" >> $VSFTP_CONF;
# echo "allow_writeable_chroot=YES" >> $VSFTP_CONF; # Problem with (CentOS 6) when you start the services.
echo "pasv_enable=Yes" >> $VSFTP_CONF;
echo "pasv_min_port=40000" >> $VSFTP_CONF;
echo "pasv_max_port=40100" >> $VSFTP_CONF;
# Restart the services (CentOS 7)
#systemctl restart vsftpd
# Enable the services (CentOS 7)
#systemctl enable vsftpd
chkconfig vsftpd on
service vsftpd restart
# add polity accept in the firewall (CentOS 7)
#firewall-cmd --permanent --add-port=21/tcp
#firewall-cmd --permanent --add-service=ftp
#firewall-cmd --reload
# if u used SELINUX
#setsebool -P ftp_home_dir on
# add polity accept in the firewall IPTABLES (CentOS 6)
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -p tcp --dport 21 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -p tcp --dport 20 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -m state --state NEW -m tcp -p tcp --dport 20 -j ACCEPT" >> /etc/sysconfig/iptables
#echo "-A INPUT -p tcp --dport 64000:65535 -j ACCEPT" >> /etc/sysconfig/iptables
echo "-A INPUT -p tcp --dport 40000:40100 -j ACCEPT" >> /etc/sysconfig/iptables
# CentOS 6 - We need to add this rule to work the FTP services on CentOS version 6.
echo "iptables -I INPUT -p tcp --dport 21 -j ACCEPT" >> /etc/rc.d/rc.local
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment