Skip to content

Instantly share code, notes, and snippets.

@kithokit
Created July 9, 2015 01:45
Show Gist options
  • Save kithokit/adcddbda29838a292fb1 to your computer and use it in GitHub Desktop.
Save kithokit/adcddbda29838a292fb1 to your computer and use it in GitHub Desktop.
Change Password Automatically (Ubuntu)
#!/usr/bin/expect
# password first argument , IP second argument
set arg1 [lindex $argv 1]
set arg2 [lindex $argv 0]
set suffix "123!@#"
spawn ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 86 ihehaadmin@$arg1
expect "password:"
send "$arg2\n";
expect "\[ihehaadmin:"
send "passwd\n";
expect "(current)";
send "$arg2\n";
expect "New password:";
send "$arg2$suffix\n";
expect "Retype";
send "$arg2$suffix\n";
expect "successfully.";
send "exit”;
@kithokit
Copy link
Author

kithokit commented Jul 9, 2015

Need to install expect on ubuntu

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment