-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathproftpd.sh
131 lines (106 loc) · 4.01 KB
/
proftpd.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
# Check if user is root
if [ $(id -u) != "0" ]; then
printf "Error: You must be root to run this script!\n"
exit 1
fi
clear
printf "=========================================================================\n"
printf "Proftpd for ubuntu \n"
printf "=========================================================================\n"
printf "\n"
printf "\n"
printf "Usage: ./proftpd.sh \n"
printf "=========================================================================\n"
cur_dir=$(pwd)
get_char()
{
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
echo ""
echo "Press any key to start install ProFTPd..."
char=`get_char`
echo "Install building packages..."
cat /etc/issue | grep -Eqi '(Debian|Ubuntu)' && apt-get update;apt-get install build-essential gcc g++ make -y || yum -y install make gcc gcc-c++ gcc-g77
tar zxf proftpd-1.3.4b.tar.gz
cd proftpd-1.3.4b
./configure --prefix=/usr/local/proftpd
make && make install
cd ../
ln -s /usr/local/proftpd/sbin/proftpd /usr/local/bin/
ln -s /usr/local/proftpd/bin/ftpasswd /usr/local/bin/
mkdir /usr/local/proftpd/var/log/
mkdir /usr/local/proftpd/etc/vhost/
cat >/usr/local/proftpd/etc/proftpd.conf<<EOF
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use. It establishes a single server
# and a single anonymous login. It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.
ServerName "ProFTPD FTP Server"
ServerType standalone
DefaultServer on
# Port 21 is the standard FTP port.
Port 21
# Don't use IPv6 support by default.
UseIPv6 off
# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask 022
# To prevent DoS attacks, set the maximum number of child processes
# to 30. If you need to allow more than 30 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances 30
# Set the user and group under which the server will run.
User nobody
Group nogroup
PassivePorts 20000 30000
# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~
AllowOverwrite on
AllowRetrieveRestart on
AllowStoreRestart on
UseReverseDNS off
IdentLookups off
#DisplayLogin welcome.msg
ServerIdent off
RequireValidShell off
AuthUserFile /usr/local/proftpd/etc/ftpd.passwd
AuthOrder mod_auth_file.c mod_auth_unix.c
# Normally, we want files to be overwriteable.
AllowOverwrite on
# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
DenyAll
</Limit>
SystemLog /usr/local/proftpd/var/log/proftpd.log
Include /usr/local/proftpd/etc/vhost/*.conf
EOF
cp init.d.proftpd /etc/init.d/proftpd
chmod +x /etc/init.d/proftpd
cat /etc/issue | grep -Eqi '(Debian|Ubuntu)' && update-rc.d -f proftpd defaults;ln -s /usr/sbin/nologin /sbin/nologin || chkconfig --level 345 proftpd on
if [ -s /sbin/iptables ]; then
/sbin/iptables -I INPUT -p tcp --dport 21 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 20 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 20000:30000 -j ACCEPT
/sbin/iptables-save
fi
clear
printf "=======================================================================\n"
printf "Starting proftpd...\n"
/etc/init.d/proftpd start
printf "=======================================================================\n"
printf "Install ProFTPd completed,enjoy it!\n"
printf "=======================================================================\n"
printf "=======================================================================\n"