linux 打造ssh快捷连接

#!/usr/bin/expect 

send_user "
------------------------------------------------------------------------|
|\t 编号 \t|\t 名称 \t\t|\t\t IP \t\t|
------------------------------------------------------------------------|
|\t 1 \t|\t 开发机1 \t|\t xxx.xxx.xxx.xxx \t\t| 
|\t 2 \t|\t 开发机2 \t\t|\t xxx.xxx.xxx.xxx \t| 
------------------------------------------------------------------------|
选择需要连接的编号: \t\t\t\t\t\t
"

set login "\n===== 登录成功 =====\n"

expect {
	"1" {spawn ssh -i ~/.ssh/txy_rsa -o ServerAliveInterval=60 [email protected]; send_user $login; send "su - dp\r";interact}
	"2" {spawn ssh -o ServerAliveInterval=60 [email protected]; send_user $login; expect "*login*"; send "su - db2inst1\r"; send "cd /opt/IBM/InfoSphereDataReplication/AccessServer/bin/\r"; interact}

}



linux 打造ssh快捷连接_第1张图片

 

 

你可能感兴趣的:(Linux命令,实用工具,linux,ssh,运维)