shell实现jumpserver

#!/usr/bin/bash

#这个是linux的捕捉信息,这句话的意思是有这几个捕捉信号了就什么都不做
trap "" HUP INT

# host server
master=172.20.0.21
node01=172.20.0.7
node02=172.20.0.13
node03=172.20.0.8
node04=172.20.0.15
node05=172.20.0.16
node06=172.20.0.14
ceph01=172.20.0.5
ceph02=172.20.0.27
ceph03=172.20.0.6
ceph04=172.20.0.3
ceph05=172.20.0.4

info(){
cat <<-EOF

                        Welcome to jumpserver
                +---------------------------------------+
                |         0) k8s-master                 |
                |         1) k8s-node01                 |
                |         2) k8s-node02                 |
                |         3) k8s-node03                 |
                |         4) k8s-node04                 |
                |         5) k8s-node05                 |
                |         6) k8s-node06                 |
                |         7) storage-ceph01             |
                |         8) storage-ceph02             |
                |         9) storage-ceph03             |
                |         10) storage-ceph04            |
                |         11) storage-ceph05            |
                |         h) jumpserver info            |
                +---------------------------------------+

EOF
}

info

while true
do
  read -p "Please enter the number of the login host: " num

  case "$num" in
    0)
      ssh root@$master
      clear && info
      ;;

    1)
      ssh root@$node01
      clear && info
      ;;
    
    2)
      ssh root@$node02
      clear && info
      ;;
    
    3)
      ssh root@$node03
      clear && info
      ;;
    
    4)
      ssh root@$node04
      clear && info
      ;;
    
    5)
      ssh root@$node05
      clear && info
      ;;
    
    6)
      ssh root@$node06
      clear && info
      ;;
    
    7)
      ssh ceph@$ceph01
      clear && info
      ;;
    
    8)
      ssh ceph@$ceph02
      clear && info
      ;;
    
    9)
      ssh ceph@$ceph03
      clear && info
      ;;
    
    10)
      ssh ceph@$ceph04
      clear && info
      ;;
    
    11)
      ssh ceph@$ceph05
      clear && info
      ;;

    h)
      clear && info
      ;;

    exec)
      exit
      ;;

    *)
      echo -e "\033[31m[ERROR]\033[0m The input does not match, please re-enter...\n"

  esac

done
上一篇:Linux查看日志常用命令


下一篇:Hadoop-HA模式的搭建(手把手教,超细)