Skip to content

Instantly share code, notes, and snippets.

@tossmilestone
Last active December 16, 2019 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tossmilestone/c75e1b5244460dd49ae1f1565dc6defd to your computer and use it in GitHub Desktop.
Save tossmilestone/c75e1b5244460dd49ae1f1565dc6defd to your computer and use it in GitHub Desktop.
ssh with password from a file
dev MTIzNDU2Cg==
#!/usr/bin/expect
set timeout 20
set cmd [lrange $argv 1 end]
set password [lindex $argv 0]
eval spawn $cmd
set output [exec grep $password pwfile | awk {{print $2;}} | base64]
expect "assword:"
send "$output\r";
interact
@tossmilestone
Copy link
Author

The pwfile format is:

<name> <base64 encoded password>

every line is a single password config. You can add several password lines with different names.

Run:

sshp <name> ssh root@your.host

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