欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

杂乱笔记

程序员文章站 2022-05-31 20:00:16
...

公钥批量发送

#!/bin/bash
#免交互分发公钥
for ip in 7 8 31 41 51
do
sshpass -p 1 ssh-copy-id  -o StrictHostKeyChecking=no "[email protected]$ip"
done

rsync服务端


uid = www
gid = www
port = 873
fake super = yes
use chroot = no
max connections = 200
timeout = 600
ignore errors
read only = false
list = yes
auth users = rsync_backup
secrets file = /etc/rsync.passwd
log file = /var/log/rsyncd.log
######################################
[data]
path = /data

跳板机

配置在环境变量 /etc/bashrc

#!/bin/bash
#jumpserver
lb01=10.0.0.5
lb02=10.0.0.6
web01=10.0.0.7
web02=10.0.0.8
web03=10.0.0.9
nfs=10.0.0.31
backup=10.0.0.41
db01=10.0.0.51
m01=10.0.0.61
zabbix=10.0.0.71

menu(){
        cat <<-EOF
        +-------------------------+
        |     1) lb01             |
        |     2) lb02             |
        |     3) web01            |
        |     4) web02            |
        |     5) web03            |
        |     6) nfs              |
        |     7) backup           |
        |     8) db01             |
        |     9) m01              |
        |     10) zabbix          |
        |     h) help             |
        +-------------------------+
EOF
}
#菜单函数
menu

#连接函数
connect(){
  ping -c 1 -w 1 $1 &>/dev/null
  if [ $? -eq 0 ];then
    ssh [email protected]$1
  else
    echo -e "\033[5;4;40;31m 别连了,我的哥,$2:$1机器都没开!!!\033[0m"
  fi
}

#控制不让输入ctrl+c,z
trap "" HUP INT TSTP
while true
do
    read -p "请输入要连接的主机编号:" num
    case $num in
            1|lb01)
              connect $lb01 lb01
                    ;;
            2|lb02)
              connect $lb02 lb02
                    ;;
            3|web01)
              connect $web01 web01
                    ;;
            4|web02)
              connect $web02 web02
                    ;;
            5|web03)
                  connect $web03 web03
                    ;;
            6|nfs)
              connect $nfs nfs
                    ;;
            7|backup)
                  connect $backup backup
                    ;;
            8|db01)
                   connect $db01 db01
                    ;;
            9|m01)
                    connect $m01 m01
                    ;;
            10|zabbix)
                    connect $zabbix zabbix
                    ;;
            h|help)
                    clear
                    menu
                    ;;
            close)
                    break
                    ;;
    esac
done

数据库远程授权

grant all on wordpress.* to [email protected]'172.16.1.%' identified by '123456';##设置远程链接用户和权限 

关联php

location ~ \.php$ {
                root /code/wordpress;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

相关标签: 架构