小编dwu*_*dwu的帖子

期望通过ssh提示脚本更改密码

目前我有一个bash脚本,在ssh上做一些事情时使用expect.看起来像:

#!/bin/bash
#some bash stuff here
...
/usr/bin/expect -c '
    spawn somescript.sh
    expect "password:"
    send "$PASSWD"
'
...
Run Code Online (Sandbox Code Playgroud)

somescript.sh通过ssh对远程服务器执行命令,但现在我的登录需要更改密码.我试过了

/usr/bin/expect -c '
    spawn somescript.sh
    expect "password:"
    send "$PASSWD"
    expect "current password"
    send "$PASSWD"
    expect "new password"
    send "$NEWPASSWD"
'
Run Code Online (Sandbox Code Playgroud)

但我得到一个错误说:

WARNING: Your password has expired.\n Password change required but 
no TTY available.
Run Code Online (Sandbox Code Playgroud)

ssh bash expect

6
推荐指数
1
解决办法
6437
查看次数

标签 统计

bash ×1

expect ×1

ssh ×1