Created
September 14, 2016 13:56
-
-
Save mrqaidi/3a1cb7c9b9e0744b2d42c4745c7b31ea to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
# wrapper to make passwd(1) be non-interactive | |
# username is passed as 1st arg, passwd as 2nd | |
set username [lindex $argv 0] | |
set password [lindex $argv 1] | |
set serverid [lindex $argv 2] | |
set newpassword [lindex $argv 3] | |
spawn ssh $serverid passwd | |
expect "assword:" | |
send "$password\r" | |
expect "UNIX password:" | |
send "$password\r" | |
expect "password:" | |
send "$newpassword\r" | |
expect "password:" | |
send "$newpassword\r" | |
expect eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment