ssh-only.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. #!/bin/bash
  2. # Mod By TuanYz
  3. #
  4. # ==================================================
  5. GitUser=""
  6. #wget https://github.com/${GitUser}/
  7. # initializing var
  8. export DEBIAN_FRONTEND=noninteractive
  9. MYIP=$(wget -qO- ipinfo.io/ip);
  10. MYIP2="s/xxxxxxxxx/$MYIP/g";
  11. NET=$(ip -o $ANU -4 route show to default | awk '{print $5}');
  12. source /etc/os-release
  13. ver=$VERSION_ID
  14. #detail nama perusahaan
  15. country=ID
  16. state=Indonesia
  17. locality=Indonesia
  18. organization=REV
  19. organizationalunit=REV
  20. commonname=REV
  21. email=
  22. # simple password minimal
  23. wget -O /etc/pam.d/common-password "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/password"
  24. chmod +x /etc/pam.d/common-password
  25. # go to root
  26. cd
  27. # Edit file /etc/systemd/system/rc-local.service
  28. cat > /etc/systemd/system/rc-local.service <<-END
  29. [Unit]
  30. Description=/etc/rc.local
  31. ConditionPathExists=/etc/rc.local
  32. [Service]
  33. Type=forking
  34. ExecStart=/etc/rc.local start
  35. TimeoutSec=0
  36. StandardOutput=tty
  37. RemainAfterExit=yes
  38. SysVStartPriority=99
  39. [Install]
  40. WantedBy=multi-user.target
  41. END
  42. # nano /etc/rc.local
  43. cat > /etc/rc.local <<-END
  44. #!/bin/sh -e
  45. # rc.local
  46. # By default this script does nothing.
  47. exit 0
  48. END
  49. # Ubah izin akses
  50. chmod +x /etc/rc.local
  51. # enable rc local
  52. systemctl enable rc-local
  53. systemctl start rc-local.service
  54. # disable ipv6
  55. echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
  56. sed -i '$ i\echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6' /etc/rc.local
  57. # set repo
  58. sh -c 'echo "deb http://download.webmin.com/download/repository sarge contrib" > /etc/apt/sources.list.d/webmin.list'
  59. apt install gnupg gnupg1 gnupg2 -y
  60. wget http://www.webmin.com/jcameron-key.asc
  61. apt-key add jcameron-key.asc
  62. #update
  63. apt update -y
  64. apt upgrade -y
  65. apt dist-upgrade -y
  66. # install wget and curl
  67. apt -y install wget curl
  68. # set time GMT +7
  69. ln -fs /usr/share/zoneinfo/Asia/Jakarta /etc/localtime
  70. # set locale
  71. sed -i 's/AcceptEnv/#AcceptEnv/g' /etc/ssh/sshd_config
  72. # install
  73. apt-get --reinstall --fix-missing install -y bzip2 gzip coreutils wget screen rsyslog iftop htop net-tools zip unzip wget net-tools curl nano sed screen gnupg gnupg1 bc apt-transport-https build-essential dirmngr libxml-parser-perl neofetch git
  74. echo "clear" >> .profile
  75. echo "neofetch" >> .profile
  76. echo "echo Mod By TuanYz" >> .profile
  77. # install webserver
  78. apt -y install nginx
  79. cd
  80. rm /etc/nginx/sites-enabled/default
  81. rm /etc/nginx/sites-available/default
  82. wget -O /etc/nginx/nginx.conf "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/nginx.conf"
  83. mkdir -p /home/vps/public_html
  84. echo "<pre>Mod By TuanYz</pre>" > /home/vps/public_html/index.html
  85. wget -O /etc/nginx/conf.d/vps.conf "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/vps.conf"
  86. /etc/init.d/nginx restart
  87. # install badvpn
  88. cd
  89. wget -O /usr/bin/badvpn-udpgw "https://github.com/${GitUser}/test1/raw/main/badvpn-udpgw64"
  90. chmod +x /usr/bin/badvpn-udpgw
  91. sed -i '$ i\screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7100 --max-clients 500' /etc/rc.local
  92. sed -i '$ i\screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7200 --max-clients 500' /etc/rc.local
  93. sed -i '$ i\screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300 --max-clients 500' /etc/rc.local
  94. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7100 --max-clients 500
  95. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7200 --max-clients 500
  96. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300 --max-clients 500
  97. apt-get -y update
  98. # setting port ssh
  99. cd
  100. sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g'
  101. # /etc/ssh/sshd_config
  102. sed -i '/Port 22/a Port 500' /etc/ssh/sshd_config
  103. sed -i '/Port 22/a Port 40000' /etc/ssh/sshd_config
  104. sed -i '/Port 22/a Port 51443' /etc/ssh/sshd_config
  105. sed -i '/Port 22/a Port 58080' /etc/ssh/sshd_config
  106. sed -i '/Port 22/a Port 200' /etc/ssh/sshd_config
  107. sed -i 's/#Port 22/Port 22/g' /etc/ssh/sshd_config
  108. /etc/init.d/ssh restart
  109. echo "=== install Dropbear ==="
  110. # install dropbear
  111. apt-get -y install dropbear
  112. sed -i 's/NO_START=1/NO_START=0/g' /etc/default/dropbear
  113. sed -i 's/DROPBEAR_PORT=22/DROPBEAR_PORT=143/g' /etc/default/dropbear
  114. sed -i 's/DROPBEAR_EXTRA_ARGS=/DROPBEAR_EXTRA_ARGS="-66 -p 50000 -p 109 -p 77 "/g' /etc/default/dropbear
  115. echo "/bin/false" >> /etc/shells
  116. echo "/usr/sbin/nologin" >> /etc/shells
  117. /etc/init.d/ssh restart
  118. /etc/init.d/dropbear restart
  119. # install squid
  120. cd
  121. apt -y install squid3
  122. wget -O /etc/squid/squid.conf "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/squid3.conf"
  123. sed -i $MYIP2 /etc/squid/squid.conf
  124. # setting dan install vnstat debian 9 64bit
  125. apt-get -y install vnstat
  126. systemctl start vnstat
  127. systemctl enable vnstat
  128. chkconfig vnstat on
  129. chown -R vnstat:vnstat /var/lib/vnstat
  130. # install webmin
  131. apt install webmin -y
  132. sed -i 's/ssl=1/ssl=0/g' /etc/webmin/miniserv.conf
  133. /etc/init.d/webmin restart
  134. # install stunnel
  135. apt install stunnel4 -y
  136. cat > /etc/stunnel/stunnel.conf <<-END
  137. cert = /etc/stunnel/stunnel.pem
  138. client = no
  139. socket = a:SO_REUSEADDR=1
  140. socket = l:TCP_NODELAY=1
  141. socket = r:TCP_NODELAY=1
  142. [ssldropbear]
  143. accept = 444
  144. connect = 127.0.0.1:44
  145. [ssldropbear]
  146. accept = 777
  147. connect = 127.0.0.1:77
  148. [stunnelws]
  149. accept = 443
  150. connect = 700
  151. [openvpn]
  152. accept = 992
  153. connect = 127.0.0.1:1194
  154. END
  155. echo "================= membuat Sertifikat OpenSSL ======================"
  156. echo "========================================================="
  157. #membuat sertifikat
  158. cd /etc/stunnel/
  159. openssl genrsa -out key.pem 2048
  160. openssl req -new -x509 -key key.pem -out cert.pem -days 1095 \
  161. -subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname/emailAddress=$email"
  162. cat key.pem cert.pem >> /etc/stunnel/stunnel.pem
  163. cd
  164. # konfigurasi stunnel
  165. sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/stunnel4
  166. cd
  167. /etc/init.d/stunnel4 restart
  168. cd
  169. apt-get -y install sslh
  170. #configurasi sslh
  171. wget -O /etc/default/sslh "https://raw.githubusercontent.com/Alamyazid/Autoscript/sslh-conf"
  172. service sslh restart
  173. #OpenVPN
  174. wget https://raw.githubusercontent.com/Alamyazid/Autoscript/main/vpn.sh && chmod +x vpn.sh && ./vpn.sh
  175. # install fail2ban
  176. apt -y install fail2ban
  177. # Instal DDOS Flate
  178. if [ -d '/usr/local/ddos' ]; then
  179. echo; echo; echo "Please un-install the previous version first"
  180. exit 0
  181. else
  182. mkdir /usr/local/ddos
  183. fi
  184. clear
  185. echo; echo 'Installing DOS-Deflate 0.6'; echo
  186. echo; echo -n 'Downloading source files...'
  187. wget -q -O /usr/local/ddos/ddos.conf http://www.inetbase.com/scripts/ddos/ddos.conf
  188. echo -n '.'
  189. wget -q -O /usr/local/ddos/LICENSE http://www.inetbase.com/scripts/ddos/LICENSE
  190. echo -n '.'
  191. wget -q -O /usr/local/ddos/ignore.ip.list http://www.inetbase.com/scripts/ddos/ignore.ip.list
  192. echo -n '.'
  193. wget -q -O /usr/local/ddos/ddos.sh http://www.inetbase.com/scripts/ddos/ddos.sh
  194. chmod 0755 /usr/local/ddos/ddos.sh
  195. cp -s /usr/local/ddos/ddos.sh /usr/local/sbin/ddos
  196. echo '...done'
  197. echo; echo -n 'Creating cron to run script every minute.....(Default setting)'
  198. /usr/local/ddos/ddos.sh --cron > /dev/null 2>&1
  199. echo '.....done'
  200. echo; echo 'Installation has completed.'
  201. echo 'Config file is at /usr/local/ddos/ddos.conf'
  202. echo 'Please send in your comments and/or suggestions to zaf@vsnl.com'
  203. # xml parser
  204. cd
  205. apt install -y libxml-parser-perl
  206. # banner /etc/issue.net
  207. wget -O /etc/issue.net "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/bannerssh.conf"
  208. echo "Banner /etc/issue.net" >>/etc/ssh/sshd_config
  209. sed -i 's@DROPBEAR_BANNER=""@DROPBEAR_BANNER="/etc/issue.net"@g' /etc/default/dropbear
  210. #install bbr dan optimasi kernel
  211. wget https://raw.githubusercontent.com/Alamyazid/Autoscript/main/bbr.sh && chmod +x bbr.sh && ./bbr.sh
  212. wget https://raw.githubusercontent.com/Alamyazid/Autoscript/main/set-br.sh && chmod +x set-br.sh && ./set-br.sh
  213. # blockir torrent
  214. iptables -A FORWARD -m string --string "get_peers" --algo bm -j DROP
  215. iptables -A FORWARD -m string --string "announce_peer" --algo bm -j DROP
  216. iptables -A FORWARD -m string --string "find_node" --algo bm -j DROP
  217. iptables -A FORWARD -m string --algo bm --string "BitTorrent" -j DROP
  218. iptables -A FORWARD -m string --algo bm --string "BitTorrent protocol" -j DROP
  219. iptables -A FORWARD -m string --algo bm --string "peer_id=" -j DROP
  220. iptables -A FORWARD -m string --algo bm --string ".torrent" -j DROP
  221. iptables -A FORWARD -m string --algo bm --string "announce.php?passkey=" -j DROP
  222. iptables -A FORWARD -m string --algo bm --string "torrent" -j DROP
  223. iptables -A FORWARD -m string --algo bm --string "announce" -j DROP
  224. iptables -A FORWARD -m string --algo bm --string "info_hash" -j DROP
  225. iptables-save > /etc/iptables.up.rules
  226. iptables-restore -t < /etc/iptables.up.rules
  227. netfilter-persistent save
  228. netfilter-persistent reload
  229. # download script
  230. cd /usr/bin
  231. wget -O addhost "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/addhost.sh"
  232. wget -O about "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/about.sh"
  233. wget -O menu "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/menu1.sh"
  234. wget -O usernew "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/usernew.sh"
  235. wget -O trial "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/trial.sh"
  236. wget -O hapus "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/hapus.sh"
  237. wget -O member "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/member.sh"
  238. wget -o webmin "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/webmin.sh"
  239. wget -O delete "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/delete.sh"
  240. wget -O cek "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/cek.sh"
  241. wget -O restart "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/restart.sh"
  242. wget -O speedtest "https://github.com/Alamyazid/Autoscript/raw/main/speedtest_cli.py"
  243. wget -O info "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/info.sh"
  244. wget -O ram "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/ram.sh"
  245. wget -O renew "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/renew.sh"
  246. wget -O autokill "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/autokill.sh"
  247. wget -O ceklim "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/ceklim.sh"
  248. wget -O tendang "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/tendang.sh"
  249. wget -O clear-log "https://raw.githubusercontent.com/Alamyazid/Autoscript/main/clear-log.sh"
  250. echo "0 5 * * * root clear-log && reboot" >> /etc/crontab
  251. chmod +x addhost
  252. chmod +x menu
  253. chmod +x usernew
  254. chmod +x trial
  255. chmod +x hapus
  256. chmod +x member
  257. chmod +x delete
  258. chmod +x webmin
  259. chmod +x cek
  260. chmod +x restart
  261. chmod +x speedtest
  262. chmod +x info
  263. chmod +x about
  264. chmod +x autokill
  265. chmod +x tendang
  266. chmod +x ceklim
  267. chmod +x ram
  268. chmod +x renew
  269. chmod +x clear-log
  270. # remove unnecessary files
  271. apt -y autoclean
  272. apt -y remove --purge unscd
  273. apt-get -y --purge remove samba*;
  274. apt-get -y --purge remove apache2*;
  275. apt-get -y --purge remove bind9*;
  276. apt-get -y remove sendmail*
  277. apt -y autoremove
  278. # finishing
  279. cd
  280. chown -R www-data:www-data /home/vps/public_html
  281. /etc/init.d/nginx restart
  282. /etc/init.d/openvpn restart
  283. /etc/init.d/cron restart
  284. /etc/init.d/ssh restart
  285. /etc/init.d/dropbear restart
  286. /etc/init.d/fail2ban restart
  287. /etc/init.d/webmin restart
  288. /etc/init.d/stunnel4 restart
  289. /etc/init.d/vnstat restart
  290. /etc/init.d/squid restart
  291. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7100 --max-clients 500
  292. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7200 --max-clients 500
  293. screen -dmS badvpn badvpn-udpgw --listen-addr 127.0.0.1:7300 --max-clients 500
  294. history -c
  295. echo "unset HISTFILE" >> /etc/profile
  296. cd
  297. rm -f /root/ssh-vpn.sh
  298. # finihsing
  299. clear
  300. neofetch
  301. netstat -nutlp