奇怪的svm脚本之一
lvcreate -L 50G -n /dev/vg0/home
有很久没用vsftpd了, 最近做自动备份需要用到ftp服务器, 思来想去也只有vsftp简单粗暴快捷了.
function setftpuser() { setpassword=`openssl rand -base64 12|tr -dc _A-Z-a-z-0-9`; adduser $1 echo $1 >> /etc/vsftpd/chroot_list chmod 750 /home/$1 echo $1:$setpassword|chpasswd echo $1 $setpassword; echo $1 $setpassword > /root/vsftp.txt; } function vsftp-setup{ yum -y install vsftpd cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.default sed -i 's#anonymous_enable=YES#anonymous_enable=NO#g' /etc/vsftpd/vsftpd.conf sed -i 's#listen=NO#listen=YES#g' /etc/vsftpd/vsftpd.conf sed -i 's#listen_ipv6=YES#listen_ipv6=NO#g' /etc/vsftpd/vsftpd.conf sed -i 's/#chroot_/chroot_/g' /etc/vsftpd/vsftpd.conf systemctl enable vsftpd systemctl start vsftpd } vsftp-setup #安装vsftpd setftpuser 用户名 #添加用户
ssh jail环境没有弄, 后面有精力再弄上.
/ip firewall nat add chain=srcnat src-address=内网IP段/24 protocol=tcp action=masquerade add action=dst-nat chain=dstnat dst-address=公网IP dst-port=80,443,5900 protocol=tcp to-addresses=内网IP to-ports=0-65535 add action=dst-nat chain=dstnat dst-address=公网IP dst-port=623 protocol=udp to-addresses=内网IP to-ports=0-65535
怕忘记了,懒得到处找.
LVM在linux下灵活划分硬盘空间分区是非常好用的一个东西.
从centos5开始到现在还在用的centos7, 我一直都在和lvm做斗争.
问题其实也简单, 无非就是lv分区导致丢失: 分区的md编号错乱丢失lv, lvremove恢复后丢失lv, 以及还有许多已经忘记的原因.
上月由于机柜搬迁数据中心的问题, 一些宿主服务器子系统较多关机时间太长, 在半路进行了强制关机.
然而在恢复完后就发现一些子系统没有恢复, 由于标签显示是自用的节点又暂时没有时间就延后处理了.
今天清点后发现全是自用的节点, 好在都是非一线重要的东西.
7月底一台快7年的E3 4x1T RAID10的服务器硬盘挂掉导致whmcs数据丢失了一部分重要的数据,
又因为之前迁移进来后没有做定时数据备份, 好在抢救到的数据能维持正常运行, 覆盖早先的备份后一切正常,
此事算妥善处理完成了.
丢数据的事其实已经亲身遇上过很多次了, 硬盘坏掉和LVM丢分区的事每年都有遇上, 即使有RAID也会翻车的可能.
从第一次在webnx的RAID10挂掉, 到LVM串联硬盘分区, 再到rm -rf 数据库, 以及这次又是RAID的挂掉.
数据备份不能马虎, 一定要做, 且异地备份 本地备份 差异备份 同步备份 都要做上, 数据越重要就越需要做备份.
有2次丢掉财务数据库经验的我总结的经验是, 不是每次都那么幸运可以靠手动修复数据.
有时候没了就是没了, 说啥都没有用.
export LC_ALL="en_US.UTF-8" export LC_CTYPE="en_US.UTF-8" yum install -y git cd /opt git clone https://github.com/certbot/certbot.git cd certbot && ./certbot-auto /opt/certbot/certbot-auto certonly --manual --preferred-challenges dns -d *.域名.后缀
--preferred-challenges dns的参数会要求建立一个_acme-challenge.的txt dns指向记录验证域名.
./certbot-auto certificates
ssh-keygen -f .ssh/id_rsa.pub -e -m pem | grep -v '\-\-\-\-' | base64 -d | xxd -p #转换已有的rsa key
####交换机配置 rsa peer-public-key 1 public-key-code begin #此处是转换后的key数据 public-key-code end peer-public-key end # user-interface vty 0 4 authentication-mode aaa user privilege level 15 protocol inbound ssh # aaa local-user 用户名 password cipher 密码 privilege level 15 #local-user netadmin privilege level 15 local-user 用户名 service-type stelnet local-user 用户名 service-type ssh # stelnet server enable ssh user 用户名 authentication-type rsa ssh user 用户名 assign rsa-key 1 ssh user 用户名 service-type stelnet
user-interface vty 0 4 authentication-mode aaa protocol inbound ssh # aaa local-user 用户名 password cipher 密码 privilege level 15 local-user 用户名 service-type stelnet local-user 用户名 service-type ssh # stelnet server enable ssh user 用户名 authentication-type password ssh user 用户名 service-type stelnet
The following procedure works for Ubuntu 18.04 (Bionic Beaver)
# apt-get update # apt-get install ifupdown
source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback allow-hotplug enp0s3 auto enp0s3 iface enp0s3 inet static address 192.168.1.133 netmask 255.255.255.0 broadcast 192.168.1.255 gateway 192.168.1.1 # Only relevant if you make use of RESOLVCONF(8) # or similar... dns-nameservers 1.1.1.1 1.0.0.1
# ifdown --force enp0s3 lo && ifup -a # systemctl unmask networking # systemctl enable networking # systemctl restart networking
# systemctl stop systemd-networkd.socket systemd-networkd \ networkd-dispatcher systemd-networkd-wait-online # systemctl disable systemd-networkd.socket systemd-networkd \ networkd-dispatcher systemd-networkd-wait-online # systemctl mask systemd-networkd.socket systemd-networkd \ networkd-dispatcher systemd-networkd-wait-online # apt-get --assume-yes purge nplan netplan.io
Then, you're done.
Note: You MUST, of course, adapt the values according to your system (network, interface name...).
在http字段下加入一个map做匹配引导
map $http_user_agent $limit_bots { default 0; ~*(baiduspider|google|soso|bing|yandex|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler) 1; ~*(AltaVista|Googlebot|Slurp|BlackWidow|Bot|ChinaClaw|Custo|DISCo|Download|Demon|eCatch|EirGrabber|EmailSiphon|EmailWolf|SuperHTTP|Surfbot|WebWhacker) 1; ~*(Express|WebPictures|ExtractorPro|EyeNetIE|FlashGet|GetRight|GetWeb!|Go!Zilla|Go-Ahead-Got-It|GrabNet|Grafula|HMView|Go!Zilla|Go-Ahead-Got-It) 1; ~*(rafula|HMView|HTTrack|Stripper|Sucker|Indy|InterGET|Ninja|JetCar|Spider|larbin|LeechFTP|Downloader|tool|Navroad|NearSite|NetAnts|tAkeOut|WWWOFFLE) 1; ~*(GrabNet|NetSpider|Vampire|NetZIP|Octopus|Offline|PageGrabber|Foto|pavuk|pcBrowser|RealDownload|ReGet|SiteSnagger|SmartDownload|SuperBot|WebSpider) 1; ~*(Teleport|VoidEYE|Collector|WebAuto|WebCopier|WebFetch|WebGo|WebLeacher|WebReaper|WebSauger|eXtractor|Quester|WebStripper|WebZIP|Wget|Widow|Zeus) 1; ~*(Twengabot|htmlparser|libwww|Python|perl|urllib|scan|Curl|email|PycURL|Pyth|PyQ|WebCollector|WebCopy|webcraw) 1; }
再到server字段或者是location字段下加入if判断
if ($limit_bots = 1) { return 403; }
增加密码
openssl rsa -aes256 -in your.key -out your.encrypted.key
移除密码
openssl rsa -in your.key -out your.open.key
id_rsa文件需要400的权限, 否则不能使用.
原文引用自https://stackoverflow.com/questions/42863913/key-load-public-invalid-format
for I in `echo dmesg lastlog messages secure tallylog wtmp btmp maillog spooler yum.log`; do echo > /var/log/$I; done history -c
需要安装一个openresty或者nginx, 版本大于1.15.10
编译安装参考http://www.kvm.la/1043.html , openresty二进制包版本较低没有更新, 建议编译安装一份.
首先把IPMI的IP丢进一个ip.list的文件里面, 一行一个IP.
#/bin/bash i=1000 #vnc start port b=2000 # hextoip() { hex=$1; printf "%d." 0x${hex:0:2}; printf "%d." 0x${hex:2:2}; printf "%d." 0x${hex:4:2}; printf "%d" 0x${hex:6:2}; } #gethostip -x 10.0.12.1 stream_route_map=/etc/nginx/stream.route.map.conf http_route_map=/etc/nginx/http.route.map.conf echo " default 0;" > $stream_route_map echo " default 0;" > $http_route_map for IP in `cat /root/ipmi/ip.list | uniq -c |awk '{ print $2 }'`; do i=`expr $i + 1` ; b=`expr $b + 1` ; HEXIP=`gethostip -x $IP | tr 'A-Z' 'a-z'` ; echo " ~*($IP|$i|$b|$HEXIP)$ IP<$IP>|VNC<$i>|BMC<$b>|HEX<$HEXIP>;" >>$http_route_map; echo " ~*($b|$i)$ $IP;" >> $stream_route_map done nginx -s reload
linux kickstart文件里rootpw密码可以使用明文,也可以使用加密过的值,这里主要介绍下三种加密方法:md5、sha256、sha512
使用明文的方法
rootpw "password"
使用加密的方法
rootpw --iscrypted password_hashauthconfig --enableshadow --enablemd5 (--passalgo=sha256 or --passalgo=sha512)
使用openssl passwd命令:
# openssl passwd -1 "password"$1$uMOl6YMI$7AAO8YG7l37ipRXCmmame.
使用grub-crypt命令,会提示输出密码:
# grub-crypt --md5Password:Retype password:$1$Y9TR8PpY$qm1VzsjKzbXtYInyAQLG70
使用python,同样也会提示输出密码:
# echo 'import crypt,getpass; print crypt.crypt(getpass.getpass(), "$1$8_CHARACTER_SALT_HERE")' | python -Password:$1$8_CHARAC$GVWpvO3Hu009C37IYF41L0
只负责记录, 升级出了问题责任自负.
yum -y install epel-release yum-utils rpmconf dnf yum remove # # package-cleanup --leaves # package-cleanup --orphans # dnf -y remove yum yum-metadata-parser libsysfs dnf upgrade -y dnf upgrade -y http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-release-8.1-1.1911.0.8.el8.x86_64.rpm,centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm,centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm} dnf upgrade -y epel-release dnf clean all rpm -e `rpm -q kernel` rpm -e --nodeps sysvinit-tools dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync dnf -y install kernel-core dnf -y groupupdate Core "Minimal Install" cat /etc/redhat-release
centos8的三个包centos-release centos-gpg-keys centos-repos版本会有变动, 操作的时候需要注意选择更新.
也可以不用http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/ ,选用centos vault的库.
wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-install-shell/master/frps/install-frps.sh -O ./install-frps.sh chmod 700 ./install-frps.sh ./install-frps.sh install
dd if=/dev/zero of=test bs=64k count=4k oflag=dsync
curl -Ss http://86.re/bench.sh |bash
curl -fsL https://ilemonra.in/LemonBenchIntl | bash -s fast curl -fsL https://github.com/LemonBench/LemonBench/raw/master/LemonBench.sh | bash -s fast
https://www.91yuntest.com/
wget -N --no-check-certificate https://raw.githubusercontent.com/91yun/91yuntest/master/test.sh && bash test.sh -i "io,bandwidth,chinabw,download,traceroute,backtraceroute,allping,gotoping,benchtest" -u
wget -qO- --no-check-certificate https://raw.githubusercontent.com/oooldking/script/master/superbench.sh | bash
wget https://raw.github.com/sivel/speedtest-cli/master/speedtest.py -O /usr/local/bin/speedtest chmod a+rx /usr/local/bin/speedtest speedtest
wget http://down.eeqiu.net/besttrace4linux.zip unzip besttrace4linux.zip chmod +x besttrace ./besttrace -q 1 gd.189.cn