任何人都可以帮助解决以下脚本的问题吗?它说密码更改成功,但密码仍然是旧密码。我正在运行这个脚本来更改检查点 SPLAT 防火墙专家密码,它使用 ssh 直接登录到专家模式。
#!/usr/bin/expect
set username admin
set oldpass sam$$$
set newpass abc.123
spawn ssh -l $username 192.168.1.10
expect "assword:"
send "$oldpass\r"
expect "# "
sleep 1
send "passwd\r"
expect "Enter new expert password:"
send "$newpass\r"
expect "Enter new expert password (again):"
send "$newpass\r"
expect eof"
expect "# "
send "exit\n"
[admin@localhost ~]$ ./test.sh
spawn ssh -l admin 192.168.1.10
[email protected]'s password:
Last login: Thu Oct 30 18:41:52 2014 from 192.168.1.5
[Expert@cpmodule]# passwd
Enter new expert password:
Enter new expert password (again):
Expert password has been changed
检查这个,这对我有用。
#!/usr/bin/expect
set timeout 20
set user user2
set password abc123
set new bac234qwe.1
set ip localhost
spawn -noecho ssh -q -o StrictHostKeychecking=no "$user\@$ip" "passwd"
expect "assword:"
send "$password\r"
expect "*UNIX password:"
send "$password\r"
expect "New password: "
send "$new\r"
expect "Retype new password:"
send "$new\r"