1 Star 0 Fork 0

Santo_小窝/login-server

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
so.sh 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
antos 提交于 2018-10-15 19:28 . init
#!/bin/bash
direc=`dirname $0`
function color(){
blue="\033[0;36m"
red="\033[0;31m"
green="\033[0;32m"
close="\033[m"
case $1 in
blue)
echo -e "$blue $2 $close"
;;
red)AA
echo -e "$red $2 $close"
;;
green)
echo -e "$green $2 $close"
;;
*)
echo "Input color error!!"
;;
esac
}
function copyright(){
echo "#####################"
color blue " SSH Login Platform "
echo "#####################"
echo
}
function underline(){
echo "-----------------------------------------"
}
function main(){
while [ True ];do
echo "序号 | 主机 | 说明"
underline
awk 'BEGIN {FS=":"} {printf("\033[0;31m% 3s \033[m | %15s | %s\n",$1,$2,$6)}' $direc/password.lst
underline
read -p '[*] 选择主机: ' number
pw="$direc/password.lst"
echo $pw
ipaddr=$(awk -v num=$number 'BEGIN {FS=":"} {if($1 == num) {print $2}}' $pw)
port=$(awk -v num=$number 'BEGIN {FS=":"} {if($1 == num) {print $3}}' $pw)
username=$(awk -v num=$number 'BEGIN {FS=":"} {if($1 == num) {print $4}}' $pw)
passwd=$(awk -v num=$number 'BEGIN {FS=":"} {if($1 == num) {print $5}}' $pw)
case $number in
[0-9]|[0-9][0-9]|[0-9][0-9][0-9])
myFile="${direc}/keys/${passwd}.pem"
if [ ! -f $myFile ]; then
expect -f $direc/ssh_login.exp $ipaddr $username $passwd $port
else
ssh -i ${direc}/keys/${passwd}.pem $username@$ipaddr -p $port
echo "ssh -i ${direc}/${passwd}.pem $username@$ipaddr -p $port"
fi
;;
"q"|"quit")
exit
;;
*)
echo "Input error!!"
;;
esac
done
}
copyright
main
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/fav.ren/login-server.git
git@gitee.com:fav.ren/login-server.git
fav.ren
login-server
login-server
master

搜索帮助