Skip to content

Instantly share code, notes, and snippets.

@thewtex
Created May 3, 2011 21:18
Show Gist options
  • Save thewtex/954266 to your computer and use it in GitHub Desktop.
Save thewtex/954266 to your computer and use it in GitHub Desktop.
keyboard-interactive automatic password submission
#!/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