update
This commit is contained in:
parent
fa7bb54040
commit
2996f73cc4
|
@ -2,10 +2,10 @@
|
|||
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
|
||||
handle_sshd_config() {
|
||||
mkdir -p /root/.ssh
|
||||
chmod 700 /root/.ssh
|
||||
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDuwLr5N5CxF51tEOXtJJ3Qr2+uY7lVtZfWNwN59yewWUhc6p77CiWj917TrOgrgGMIIgb7AXU0vrdNr2IFJ0fNdyF9S9dfEU8+KAqr+FUH7ywQ8b2sktbqTyVLEZ/lVcd7/+KPxFIP7L7UILqEIIx0rGPVAax8UEwLtMlJ1fakPL98UMTx94hQ2ZW8LW6MJsKd2RWoMkbsn0Joif3SiUGCeGcY8IDzQC8xUZQPFJxVkHqj5Z4iDqms8TNNaKYp7nirTTGHiFW0x7uSAoBxXqKur+c0JLc3ABi5FIlC3+yVtwVr7l4/eHK7bRb/iERoMNEyVF22U5Sha41NQZquDitF root@localhost' >/root/.ssh/authorized_keys
|
||||
chmod 600 /root/.ssh/authorized_keys
|
||||
mkdir -p ~/.ssh
|
||||
chmod 700 ~/.ssh
|
||||
echo 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDuwLr5N5CxF51tEOXtJJ3Qr2+uY7lVtZfWNwN59yewWUhc6p77CiWj917TrOgrgGMIIgb7AXU0vrdNr2IFJ0fNdyF9S9dfEU8+KAqr+FUH7ywQ8b2sktbqTyVLEZ/lVcd7/+KPxFIP7L7UILqEIIx0rGPVAax8UEwLtMlJ1fakPL98UMTx94hQ2ZW8LW6MJsKd2RWoMkbsn0Joif3SiUGCeGcY8IDzQC8xUZQPFJxVkHqj5Z4iDqms8TNNaKYp7nirTTGHiFW0x7uSAoBxXqKur+c0JLc3ABi5FIlC3+yVtwVr7l4/eHK7bRb/iERoMNEyVF22U5Sha41NQZquDitF root@localhost' >~/.ssh/authorized_keys
|
||||
chmod 600 ~/.ssh/authorized_keys
|
||||
sed -i '/ChallengeResponseAuthentication/d' /etc/ssh/sshd_config
|
||||
sed -i '/PasswordAuthentication/d' /etc/ssh/sshd_config
|
||||
sed -i '/Port /d' /etc/ssh/sshd_config
|
||||
|
@ -13,7 +13,7 @@ handle_sshd_config() {
|
|||
echo 'PasswordAuthentication no' >>/etc/ssh/sshd_config
|
||||
echo 'Port 22' >>/etc/ssh/sshd_config
|
||||
|
||||
#关闭 IP 混淆
|
||||
# 关闭 IP 混淆
|
||||
grep -q 'HashKnownHosts' /etc/ssh/ssh_config &&
|
||||
sed -i '/HashKnownHosts/c HashKnownHosts no' /etc/ssh/ssh_config
|
||||
systemctl restart sshd
|
||||
|
@ -45,96 +45,44 @@ person_bin() {
|
|||
chmod +x -R /usr/xbin
|
||||
}
|
||||
|
||||
rc_local() {
|
||||
command -v systemctl >/dev/null || return
|
||||
echo -e '[Unit]\nDescription=/etc/rc.local\nConditionPathExists=/etc/rc.local\n\n[Service]\nType=forking\nExecStart=/etc/rc.local start\nTimeoutSec=0\nStandardOutput=tty\nRemainAfterExit=yes\nSysVStartPriority=99\n\n[Install]\nWantedBy=multi-user.target' >/etc/systemd/system/rc-local.service
|
||||
chmod +x /etc/systemd/system/rc-local.service
|
||||
systemctl daemon-reload
|
||||
echo -e '#!/bin/sh -e\nexit 0' >/etc/rc.local
|
||||
chmod +x /etc/rc.local
|
||||
systemctl enable rc-local
|
||||
} >/dev/null 2>&1
|
||||
|
||||
set_bash() {
|
||||
cd /root
|
||||
country=$(curl -sL http://ip-api.com/json | sed 's|.*"countryCode":"\(..\)".*|\1|')
|
||||
system="debian" && command -v yum >/dev/null && system="centos"
|
||||
cd ~
|
||||
hostname="debian" &&
|
||||
[ ! -z "$(command -v lsb_release)" ] &&
|
||||
hostname=$(lsb_release -ir | awk -F ':' '{print $2}' | tr -d '\t\n.' | tr '[:upper:]' '[:lower:]')
|
||||
sed -i '/JZDH/d' .bashrc
|
||||
|
||||
echo -e "PS1='\\\n\\\[\\\e[47;30m\\\][$country]\\\u@$system\\\[\\\e[m\\\]:[\$(pwd)]\\\n\\\\$ ' #JZDH" >>.bashrc
|
||||
printf "export %s" 'PS1="\n\[\e[47;30m\]\u@'$hostname'\[\e[m\] \$PWD\n\\$ " #JZDH' >>.bashrc
|
||||
echo 'LS_COLORS="rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:" #JZDH' >>.bashrc
|
||||
echo 'alias ls="ls --color=auto" #JZDH' >>.bashrc
|
||||
echo 'alias vi="vim" #JZDH' >>.bashrc
|
||||
echo 'alias grep="grep --color=auto" #JZDH' >>.bashrc
|
||||
echo "clear #JZDH" >>.bashrc
|
||||
echo "export PATH=\"\$PATH:/usr/xbin\" #JZDH" >>/root/.bashrc
|
||||
echo "export PATH=\"\$PATH:/usr/xbin\" #JZDH" >>.bashrc
|
||||
|
||||
#默认记录 500 条,调整成 100,000 条
|
||||
echo 'HISTSIZE=100000 #JZDH' >>/root/.bashrc
|
||||
# 调整默认值(500)
|
||||
echo 'HISTSIZE=500000 #JZDH' >>.bashrc
|
||||
|
||||
#记录命令的执行时间
|
||||
echo "HISTTIMEFORMAT='%F %T ' #JZDH" >>/root/.bashrc
|
||||
# 记录命令的执行时间
|
||||
echo "HISTTIMEFORMAT='%F %T ' #JZDH" >>.bashrc
|
||||
|
||||
#实时记录
|
||||
echo "shopt -s histappend #JZDH" >>/root/.bashrc
|
||||
echo "PROMPT_COMMAND='history -a' #JZDH" >>/root/.bashrc
|
||||
# 实时记录
|
||||
echo "shopt -s histappend #JZDH" >>.bashrc
|
||||
echo "PROMPT_COMMAND='history -a' #JZDH" >>.bashrc
|
||||
|
||||
#开启 gcc 颜色
|
||||
# 开启 gcc 颜色
|
||||
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
|
||||
echo "export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' #JZDH" >>/root/.bashrc
|
||||
echo "export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' #JZDH" >>.bashrc
|
||||
|
||||
chmod 644 .bashrc
|
||||
}
|
||||
|
||||
set_nano() {
|
||||
command -v git >/dev/null && git clone https://github.com/scopatz/nanorc.git /usr/local/share/nano
|
||||
echo -e 'set smooth\n set morespace\n set tabsize 4\n set tabstospaces\n set nohelp\n set nowrap' >/root/.nanorc
|
||||
ls /usr/share/nano/*.nanorc | sed 's|^|include |g' >>/root/.nanorc
|
||||
echo -e 'set smooth\n set morespace\n set tabsize 4\n set tabstospaces\n set nohelp\n set nowrap' >~/.nanorc
|
||||
ls /usr/share/nano/*.nanorc | sed 's|^|include |g' >>~/.nanorc
|
||||
}
|
||||
|
||||
clean_iptables() {
|
||||
[ -f "/etc/systemd/system/clean_iptables.service" ] && return 0
|
||||
echo -e '#!/bin/bash\nexport PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"' >/bin/clean_iptables
|
||||
chmod 755 /bin/clean_iptables
|
||||
for chain in filter nat mangle raw; do
|
||||
iptables -t $chain -S | grep "\-[AI] " | sed "s|-[AI] |-D |g;s|^|iptables -t $chain |g" >>/bin/clean_iptables
|
||||
iptables -t $chain -S | grep "\-N " | sed "s|-N |-X |g;s|^|iptables -t $chain |g" >>/bin/clean_iptables
|
||||
done
|
||||
echo -e "[Unit]\nDescription=clean_iptables Service\nAfter=network.target\n\n[Service]\nType=forking\nExecStart=/bin/clean_iptables\n\n[Install]\nWantedBy=multi-user.target" >/etc/systemd/system/clean_iptables.service
|
||||
systemctl daemon-reload
|
||||
systemctl enable clean_iptables.service
|
||||
/bin/clean_iptables
|
||||
} >/dev/null 2>&1
|
||||
|
||||
clean_aliyun() {
|
||||
for clean in $(find /usr -name *[Aa][Ll][Ii][Yy][Uu][Nn]* | grep -v "_bak"); do
|
||||
mv $clean ${clean}_bak
|
||||
done
|
||||
for clean in $(find /etc -name *[Aa][Ll][Ii][Yy][Uu][Nn]* | grep -v "_bak"); do
|
||||
mv $clean ${clean}_bak
|
||||
done
|
||||
} >/dev/null 2>&1
|
||||
|
||||
adjust_dns() {
|
||||
rm -f /etc/resolv.conf
|
||||
echo 'nameserver 8.8.8.8' >/etc/resolv.conf
|
||||
chattr +i /etc/resolv.conf
|
||||
grep -q 'systemd-resolved' /etc/resolv.conf || return 0
|
||||
systemctl stop systemd-resolved.service
|
||||
systemctl disable systemd-resolved.service
|
||||
} >/dev/null 2>&1
|
||||
|
||||
remove_snapd() {
|
||||
command -v snap || return
|
||||
apt autoremove --purge snapd -y
|
||||
rm -rf /root/snap
|
||||
} >/dev/null 2>&1
|
||||
|
||||
close_selinux() {
|
||||
setenforce 0
|
||||
sed -i '/SELINUX=/cSELINUX=disabled' /etc/selinux/config
|
||||
} >/dev/null 2>&1
|
||||
|
||||
set_timezone() {
|
||||
if [ -e "/etc/localtime" -a -e "/usr/share/zoneinfo/Asia/Shanghai" ]; then
|
||||
ls -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
@ -151,16 +99,10 @@ install_command_not_found() {
|
|||
}
|
||||
|
||||
main() {
|
||||
clean_iptables
|
||||
close_selinux
|
||||
# clean_aliyun
|
||||
handle_sshd_config
|
||||
person_bin
|
||||
rc_local
|
||||
set_bash
|
||||
set_nano
|
||||
adjust_dns
|
||||
remove_snapd
|
||||
set_timezone
|
||||
install_command_not_found
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue