shell堡垒机

配置

普通用户配置

useradd ops

su - ops

vim .bashrc 

/usr/bin/conn

 

root用户配置

.bashrc 

/sbin/super

 

连接脚本:

[root@h020 ~]# cat /usr/bin/conn
#!/bin/bash
echo "Please enter the root password to get administrator privileges"
for i in {two,one,0}
do
su - root && i=hehe
if [ $i == hehe ];then
exit
fi
if [ $i != 0 ];then
echo "please input root passwd,now You heve $i chance"
fi
done
exit

跳板机脚本:

[root@h020 ~]# cat /sbin/super
#!/bin/bash

echo -e "\e[31m \t\t welcome to use bingge jumpserver"
echo -e "\e[32m \t\t ......"
echo -e "##############Pleaes choose you want to connect server######################:
# 1:192.168.15.164(gitlab) #
# 2:192.168.15.165(jenkins) #
# 3:192.168.15.169(ansible) #
# q:use local server #
############################################################################
"'\033[37m\033[0m'


echo -e "Please input num:"
while [ True ];
do
read -p "" num
case "$num" in
1) ssh 192.168.15.164 && echo "pleaes choose you want to connect server" ;;
2) ssh 192.168.15.165 && echo "pleaes choose you want to connect server" ;;
3) ssh 192.168.15.169 && echo "pleaes choose you want to connect server" ;;
q) exit ;;
*) echo "input error please input again" ;;

esac

done

 

posted @ 2020-06-09 18:40  GaoYanbing  阅读(279)  评论(0编辑  收藏  举报