shell 堡垒机 jumpserver

[root@h020 ~]# cat /bin/jumpserver
#!/bin/bash
#######################
#linux jump-server
########################
#忽略键盘输入的一些信号
#linux键盘信号详细请看:

trap "" HUP INT OUIT TSTP

#写一个函数,里面有我们需要打印的提示信息,方便调用
info() {
printf "e[32m
===========================
jump-server
1、192.168.15.164
2、192.168.15.165
3、192.168.15.169
h、help
q、quit
===========================
"
}
#函数结尾

#上来先清屏
clear
#死循环,先打印一次函数内容,然后让用户做出选择
while :
do
info
read -p "please choice jump-server number: " cho
#case从$cho中拿到值,进行筛选
case $cho in
1)
ssh 192.168.15.164
;;
2)
ssh 192.168.15.165
;;
3)
ssh 192.168.15.169
;;
q)
exit
;;
h)
clear
echo "Enter as follows the correct options"
;;
*)
clear
echo "please enter Correct Options"
;;
esac
done

原文地址:https://www.cnblogs.com/gaoyanbing/p/13079714.html