Skip to content

Instantly share code, notes, and snippets.

@nettedfish
Last active December 14, 2015 01:09
Show Gist options
  • Save nettedfish/5003817 to your computer and use it in GitHub Desktop.
Save nettedfish/5003817 to your computer and use it in GitHub Desktop.
方便你登陆服务器
#!/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密码前缀,不可变部分"
@chenbinghuilove
Copy link

谢谢了 刚哥 呵呵,我的那个程序就是因为没有退出脚本的缘故,所以在后面加了一个exit就ok啦。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment