Last active
December 14, 2015 01:09
-
-
Save nettedfish/5003817 to your computer and use it in GitHub Desktop.
方便你登陆服务器
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
read -p "请输入6位token动态密码: " token | |
sshcmd='ssh -o StrictHostKeyChecking=no -o NumberOfPasswordPrompts=1 -o ConnectTimeout=2' | |
online_login_ssh (){ | |
expect -c "set timeout -1; | |
spawn -noecho $sshcmd -tt $1 | |
expect "*password*"; | |
send -- 这儿是一长串密码,注意保留本行末尾的3个字符\r; | |
expect "*PASSCODE*"; | |
#token的可变部分 | |
send -- $2${token}\r; | |
interact;" | |
} | |
online_login_ssh "yinggang1@通道机ip地址" "这儿是你的token密码前缀,不可变部分" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
谢谢了 刚哥 呵呵,我的那个程序就是因为没有退出脚本的缘故,所以在后面加了一个exit就ok啦。