Skip to content

Instantly share code, notes, and snippets.

@beugley
Created August 1, 2018 18:04
Show Gist options
  • Save beugley/2bede66ff3fbe903a14d32d392a5239f to your computer and use it in GitHub Desktop.
Save beugley/2bede66ff3fbe903a14d32d392a5239f to your computer and use it in GitHub Desktop.
Expect script to automate login using password file
#!/usr/bin/expect
set password [exec cat .pwd]
set timeout -1
# Connect to host, enter password
spawn ssh -o ServerAliveInterval=5 -o ServerAliveCountMax=1 server-name.com
expect {
"Password: " {send "$password\r"; exp_continue}
"password: " {send "$password\r"; interact}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment