#停止防火墙 ufw disable systemctl disable --now apparmor #增强历史命令 echo 'UserIP=$(who -u am i | cut -d"(" -f 2 | sed -e "s/[()]//g")' | sudo tee -a /etc/profile echo 'export HISTTIMEFORMAT="[%F %T] [${UserIP}] "' | sudo tee -a /etc/profile #echo 'TMOUT=1800'|sudo tee -a /etc/profile #配置apt源和工具 timedatectl set-timezone Asia/Shanghai ##参考 https://developer.aliyun.com/mirror/ubuntu?spm=a2c6h.13651102.0.0.3e221b11FvzMGy sudo apt install zip unzip telnet wget lrzsz ntpdate net-tools chrony bash-completion tree -y sudo add-apt-repository universe sudo add-apt-repository multiverse sudo apt update sudo apt install apt-transport-https ca-certificates curl software-properties-common curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list #时间同步 systemctl enable chronyd sed -i '/^server/s/^/#/g' /etc/chrony.conf sed -i '/Please consider/a\server ntp.aliyun.com iburst\nserver ntp1.aliyun.com iburst\nserver ntp2.aliyun.com iburst\nserver ntp3.aliyun.com iburst' /etc/chrony.conf systemctl restart chronyd chronyc sources -v chronyc tracking hwclock -w #配置ssh sed -i '/AddressFamily/iPort 22' /etc/ssh/sshd_config sed -i '/AddressFamily/iPort 5837' /etc/ssh/sshd_config systemctl restart sshd #创建用户 sed -i '/Same thing without/{n;d}' /etc/sudoers sed -i '/Same thing without/a\ %wheel ALL=(ALL) NOPASSWD: ALL' /etc/sudoers sed -i '/Allows people in group/{n;d}' /etc/sudoers sed -i '/Allows people in group/a# %wheel ALL=(ALL) ALL' /etc/sudoers useradd yunwei -G wheel #echo 'honojn0#UrpQ!UHj'|passwd --stdin root echo 'Cptbtptp999gml'|passwd --stdin root echo 'O2gff2KST@!mNTm$'|passwd --stdin yunwei #私钥服务器192.168.3.1 root mkdir -p /root/.ssh echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCXEni+ljY1ve8vG4pQN8sqUz9Bn75MJQTrPlbj6m0m/hwtg50IAO8L2aUKaih9kDgdBD8F0kUPOnqe915N5w/QJXU71GF5M8ds7JGWh3alLssmdEvHyji2E8K+4LlDCIAvPNImCQ4syH3tny8l7sdIOtCxcvgXG60CEmVAmMCqWwkxTPUW0Xk3oa4Roz2BIXW/fcAY1tE+3TJlTAUK3yD9wbBAOHjZD1gqKNXLxHIUhEl6jtSfCQbXOt5kC8Xasa8o0qmRFIWo377jT/5/clHkYikbKb4ae3uXW3Fl83PviDV+/dAouS/8IrqCxLcjFxeVPwh8hwjUjMpCguMV8s3hLktp51wJZd1Rj3s1P5KJC4IOH3IiYeau6ZFEfqn529y+POQelLRcY+RXzd/yl14e3tKf1Crbhpqh2Y+wqHQhKaFWztGY0lLXY7ZDjsdHiRRI0jOaxv6gTg8UhCvFAs12dUn2D+RXOGO5rrnob6rejXmKA1B39ed7EG9CTbtVm5MNBs9NLJGvrXvcevnX/N9MjZn1RRFB/e+WU+cIihPR4M19qoL8owjFIxojyYLVxJKcwfQ3cdkGJA3wgrFXiaEgWdTyGfRridF9LjaA/IFMWCW3XB8vsooNBhdklAP+galAos9zMfYk0AFctsactQ/j3e9Cy/9ncogbrB8XMhA9sQ== root@jump' >>/root/.ssh/authorized_keys #安装监控客户端 ###d0-test curl https://zhengyu1992.cn/file/exporter/script-exporter/script-exporter-install.sh|bash curl https://zhengyu1992.cn/file/exporter/node_exporter/node_exporter-install.sh|bash curl https://zhengyu1992.cn/file/deploy/monitoring/consul/d0-script-exporter-res.sh|bash curl https://zhengyu1992.cn/file/deploy/monitoring/consul/d0-node-exporter-res.sh|bash ###d1-prod curl https://zhengyu1992.cn/file/exporter/script-exporter/script-exporter-install.sh|bash curl https://zhengyu1992.cn/file/exporter/node_exporter/node_exporter-install.sh|bash curl https://zhengyu1992.cn/file/deploy/monitoring/consul/d1-script-exporter-res.sh|bash curl https://zhengyu1992.cn/file/deploy/monitoring/consul/d1-node-exporter-res.sh|bash ##数据库 curl https://zhengyu1992.cn/file/exporter/script-exporter/script-exporter-install.sh|bash curl https://zhengyu1992.cn/file/exporter/node_exporter/node_exporter-install.sh|bash curl https://zhengyu1992.cn/file/install/dbinstall.sh|bash -s 数据库用途(支持中文)