xinyv
全部博文(41)
C_program(4)
防病毒网关(1)
command(7)
other(7)
services(3)
shell_script(4)
linux进程间通讯(1)
大型网站集群构建(10)
2014年(1)
2013年(2)
2012年(1)
2011年(2)
2010年(3)
2009年(1)
2008年(20)
2007年(11)
rabbitda
linux_ka
HonestQi
ghostwri
iamfy
guowanxi
mordorww
anony_li
icebluec
sga_sess
hehedada
chyyuu
分类: LINUX
2007-11-10 14:04:15
#!/bin/bash# User Function and Variables definition
# LOCALFILE="${HOME}/ssh-management" (all user)
LOCALFILE="/etc/ssh/ssh-management"[ -f /usr/bin/dialog ] || { echo "Not found dialog";exit 1; }[ -f $LOCALFILE ] || touch $LOCALFILE# User Program Mainfunction ADDSSH_HOST {clearecho -n "Pleast Input SSH Host IP: "read -r ADDSSH[0]DIGIT=(${ADDSSH[0]//[!0-9]/ })[ "${#DIGIT[@]}" != "4" ] && { echo "IP ADDRESS ERROR " exit 1}echo -n "Pleast Input SSH Host Port (Default 22): "read -r ADDSSH[1][ -z ${ADDSSH[1]} ] && ADDSSH[1]=22if (( 0>${ADDSSH[1]} && ${ADDSSH[1]}>65536 ));then echo "Port Error." exit 1fiecho -n "Pleast Input Login Username (Default root): "read -r ADDSSH[2][ -z ${ADDSSH[2]} ] && ADDSSH[2]=rootecho -n "Pleast Input Host Aliasname: "read -r ADDSSH[3][[ ${ADDSSH[0]} != 127.0.0.1 ]] && echo ${ADDSSH[@]}|sed -e 's/\ /\t/g' >>$LOCALFILEreturn 5}i=0while read LINE do var=(${LINE});((i++)) CONNECTING[$i]="$i '${var[0]}~${var[3]}'" done <${LOCALFILE}CONNECTING[0]="0 'ADD-SSH-HOST'"#25,50,20 height of outer border,width,height of inner borderdialog \ --backtitle "SSH Mangemet" \ --menu "SSH Accounts ... " 25 50 20 \ --output-fd 3 \ ${CONNECTING[@]} \ 3>/dev/shm/ssh-connect-tmpSSHNUM=$(</dev/shm/ssh-connect-tmp)[[ ${SSHNUM} == 0 ]] && ADDSSH_HOST[ $? = 5 ] && exec ${0}if [[ ${SSHNUM} > 0 ]];then SSHVAR=($(cat -n $LOCALFILE|grep -E "^\ +${SSHNUM}[^0-9]")) ssh -l ${SSHVAR[3]} -p ${SSHVAR[2]} ${SSHVAR[1]}firm -f /dev/shm/ssh-connect-tmpexit 0
上一篇:UCARP翻译文档
下一篇:加密备份一个文件
登录 注册