Reputation: 291
I made 2 Expect scripts to SSH to a list of servers and change passwords. One for AIX and one for RedHat Linux.
The AIX script is working fine, but the Linux script is giving me a problem. The reason is that on the Linux servers, when you are forced to change an expired password, after the password is changed the remote side kills the SSH session.
passwd: all authentication tokens updated successfully.
Connection to drm23rdv closed.
send: spawn id exp20 not open
while executing...
At this point the script stops completely and there are still lots of servers to log in to. (and the current password is just a temporary one, although I could modify the script to use my permanent password choice but I like to do that as root)
What I would like to do after the initial, forced password change is log back into the server and change the password again as root. I am pretty sure I can handle that, but first I need to figure out a way to have expect handle the closed SSH session with more dignity than just giving up.
Upvotes: 0
Views: 390
Reputation: 246744
use expect eof {do something}
, or the connection might close at any time, use expect_before {eof {do something}}
Upvotes: 1