SSH自动登录脚本

使用otp 服务申请固定tokens标识码

otpauth://totp/[客户端显示的账户信息]?secret={密码}&{其他参数}

token动态获取命令

#使用上面的 secret 登录
oathtool --base32 --totp "{secret}"

SSH自动登录

#!/usr/bin/expect
 
set server     [lindex $argv 0] #参数1,登录参数
set tokencode  [lindex $argv 1] #参数2,登录token
puts "${tokencode}
"

spawn ssh $server 
expect "*Your_OTP*"  {
    send "$tokencode
"
}
 
interact
原文地址:https://www.cnblogs.com/lamp-lrh/p/14293255.html