1、获取MFA_KEY , 笨方法:先使用authentictor扫描MFA二维码,然后下载备份文件,获取该认证的secret码
2、创建xxx.exp格式脚本文件

#!/usr/bin/expect
set kdauth [ exec oathtool --totp -b XXsecretXXX]

trap {
        set rows [stty rows]
        set cols [stty columns]
        stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH

spawn ssh xx@xx -p xx 
expect {
        "password*" { send "xxxxxxxx\r"; exp_continue }
        "auth*" { send "$kdauth\r"; interact }
}

2、再次,安装oathtool, 这个工具可以从命令行计算 MFA TOKEN
brew install oath-toolkit

3、执行

expect <你的脚本名称>.exp

4、简易命令 alias

echo "alias serv='expect <你的脚本名称>.exp '" >> ~/.bash_profile && source ~/.bash_profile

相关文章:

  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2021-11-07
猜你喜欢
  • 2022-02-10
  • 2021-07-20
  • 2022-02-12
  • 2022-12-23
  • 2021-05-15
  • 2022-01-21
  • 2021-09-30
相关资源
相似解决方案