Skip to content

Instantly share code, notes, and snippets.

@mrqaidi
Created September 14, 2016 13:56
Show Gist options
  • Save mrqaidi/3a1cb7c9b9e0744b2d42c4745c7b31ea to your computer and use it in GitHub Desktop.
Save mrqaidi/3a1cb7c9b9e0744b2d42c4745c7b31ea to your computer and use it in GitHub Desktop.
#!/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