| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 | 
							- #!/bin/bash
 
- apt-get install -y openssl net-tools dnsutils nload curl lsof
 
- # root
 
- sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config;
 
- sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
 
- # limits
 
- if [ -f /etc/security/limits.conf ]; then
 
-   LIMIT='262144'
 
-   sed -i '/^\(\*\|root\)[[:space:]]*\(hard\|soft\)[[:space:]]*\(nofile\|memlock\)/d' /etc/security/limits.conf
 
-   echo -ne "*\thard\tmemlock\t${LIMIT}\n*\tsoft\tmemlock\t${LIMIT}\nroot\thard\tmemlock\t${LIMIT}\nroot\tsoft\tmemlock\t${LIMIT}\n*\thard\tnofile\t${LIMIT}\n*\tsoft\tnofile\t${LIMIT}\nroot\thard\tnofile\t${LIMIT}\nroot\tsoft\tnofile\t${LIMIT}\n\n" >>/etc/security/limits.conf
 
- fi
 
- if [ -f /etc/systemd/system.conf ]; then
 
-   sed -i 's/#\?DefaultLimitNOFILE=.*/DefaultLimitNOFILE=262144/' /etc/systemd/system.conf
 
- fi
 
- # timezone
 
- ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" >/etc/timezone
 
- # systemd-journald
 
- sed -i 's/^#\?Storage=.*/Storage=volatile/' /etc/systemd/journald.conf
 
- sed -i 's/^#\?SystemMaxUse=.*/SystemMaxUse=8M/' /etc/systemd/journald.conf
 
- sed -i 's/^#\?RuntimeMaxUse=.*/RuntimeMaxUse=8M/' /etc/systemd/journald.conf
 
- systemctl restart systemd-journald
 
- # ssh
 
- [ -d ~/.ssh ] || mkdir -p ~/.ssh
 
- echo -ne "# chmod 600 ~/.ssh/id_rsa\n\nHost *\n  StrictHostKeyChecking no\n  UserKnownHostsFile /dev/null\n  IdentityFile ~/.ssh/id_rsa\n" > ~/.ssh/config
 
- # nload
 
- echo -ne 'DataFormat="Human Readable (Byte)"\nTrafficFormat="Human Readable (Byte)"\n' >/etc/nload.conf
 
- # sysctl
 
- cat >/etc/sysctl.conf<<EOF
 
- # This line below add by user.
 
- fs.file-max = 104857600
 
- fs.nr_open = 1048576
 
- vm.overcommit_memory = 1
 
- net.core.somaxconn = 65535
 
- net.core.optmem_max = 262144
 
- net.core.rmem_max = 8388608
 
- net.core.wmem_max = 8388608
 
- net.core.rmem_default = 262144
 
- net.core.wmem_default = 262144
 
- net.core.netdev_max_backlog = 65536
 
- net.ipv4.tcp_mem = 4096 262144 8388608
 
- net.ipv4.tcp_rmem = 4096 262144 8388608
 
- net.ipv4.tcp_wmem = 4096 262144 8388608
 
- net.ipv4.tcp_syncookies = 1
 
- net.ipv4.tcp_syn_retries = 3
 
- net.ipv4.tcp_synack_retries = 2
 
- net.ipv4.tcp_max_syn_backlog = 65535
 
- net.ipv4.tcp_fin_timeout = 16
 
- net.ipv4.tcp_keepalive_intvl = 32
 
- net.ipv4.tcp_keepalive_probes = 3
 
- net.ipv4.tcp_keepalive_time = 900
 
- net.ipv4.tcp_retries1 = 3
 
- net.ipv4.tcp_retries2 = 8
 
- net.ipv4.tcp_no_metrics_save = 1
 
- net.ipv4.tcp_timestamps = 1
 
- net.ipv4.tcp_slow_start_after_idle = 0
 
- net.ipv4.ip_forward = 1
 
- net.core.default_qdisc = fq
 
- net.ipv4.tcp_congestion_control = bbr
 
- net.ipv4.icmp_echo_ignore_all = 1
 
- net.ipv6.conf.all.disable_ipv6 = 1
 
- net.ipv4.tcp_fastopen = 0
 
- net.ipv4.tcp_fack = 1
 
- net.ipv4.tcp_sack = 1
 
- net.ipv4.tcp_dsack = 1
 
- net.ipv4.tcp_ecn = 0
 
- net.ipv4.tcp_ecn_fallback = 1
 
- EOF
 
- sysctl -p
 
 
  |