获取MFA SECRET
git clone https://github.com/scito/extract_otp_secret_keys.git --depth=1 pip3 install protobuf pip3 install qrcode[pil] - 打开app -> 转移账号 -> 导出账号 -> 选择账号 -> 识别二维码 保存到a.txt
python3 extract_otp_secret_keys.py -p a.txt 获取secret
配置环境变量
SSH_TERMINAL_PORT='5678'
SSH_TERMINAL_USER='root'
SSH_TERMINAL_IP='192.168.50.50'
MFA_SECRET=***************
MY_PASSWORD=*****************
export SSH_TERMINAL_PORT
export SSH_TERMINAL_USER
export SSH_TERMINAL_IP
export MY_PASSWORD
export MFA_SECRET
alias mfa='oathtool --totp -b ${MFA_SECRET}'
expect 脚本
#!/usr/bin/expect
spawn ssh -p $env(SSH_TERMINAL_PORT) $env(SSH_TERMINAL_USER)@$env(SSH_TERMINAL_IP)
expect "*password*" {send "$env(MY_PASSWORD)\r"}
expect "*auth*" {
set code [exec oathtool --totp -b $env(MFA_SECRET) ]
send "$code\r"}
# expect "*Opt*" {send "p\r"}
interact
|