Created
May 3, 2011 21:18
-
-
Save thewtex/954266 to your computer and use it in GitHub Desktop.
keyboard-interactive automatic password submission
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/env python | |
# automatically give password to scripts that use ssh/scp and do not have public | |
# key authentification available. | |
PASSWORD = 'abc123' | |
import pexpect | |
import sys | |
if len(sys.argv) < 2: | |
print('usage: ' + sys.argv[0] + ' <script command to run>') | |
sys.exit(1) | |
command = '' | |
for arg in sys.argv[1:]: | |
command += arg + ' ' | |
output = pexpect.run(command, events={'(?i)password': PASSWORD + '\n'}) | |
print(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment