这是我在ST写的自动登陆ssh的脚本, 分两个文件
文件1: sssh
#!/bin/bash
#xql 2011/01/4
#auto ssh 138.198.230.170 case $1 in
"xql")
sssh.exp xql
;;
"root")
sssh.exp root
;;
"31")
ssh root@10.80.117.31
;;
"40")
ssh root@10.80.117.40
;;
*)
ssh $1@138.198.230.170
;;
esac
文件2: sssh.exp
#!/usr/bin/expect set USER [ lindex $argv 0 ]
set ADDR "138.198.230.170" switch $USER {
"xql" {set PASS "qianli1987"}
"root" {set PASS "bu60ff"}
default {exit 1}
} spawn ssh $USER@$ADDR expect {
"*password: " {send "$PASS\r"}
"*(yes/no)? " {send "yes\r"}
}
interact